plexinc/plex-for-kodi

Music doesn't play in Kodi Matrix

wormvortex opened this issue · 16 comments

Since upgrading to matrix the plex-for-kodi app will not play music. Videos load fine but music just opens the player and stays at 0 seconds no matter what I try and play.

Details:

  • Add-on version: latest
  • Kodi version: matrix
  • OS Platform: libreleec
  • Hardware: pi4

I'm seeing the exact same thing, thanks in advance to those that can fix this!

Details:

Add-on version: latest
Kodi version: matrix
OS Platform: Android
Hardware: minix U1 (Amlogic S905)

Greetings. A similar problem. Hope for a solution soon. Thanks for your work.

Details:

Add-on version: latest
Kodi version: matrix
OS Platform: Android 9.0
Hardware: Ugoos AM6 Plus (Amlogic S922XJ)

I also have such a problem on nvidia shield in kodi 19.1

Buri commented

It looks like the playlist data coming in is wrong?

2021-09-18 10:51:25.306 T:2641    ERROR <general>: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                                    - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                                   Error Type: <class 'TypeError'>
                                                   Error Contents: a bytes-like object is required, not 'str'
                                                   Traceback (most recent call last):
                                                     File "/home/buri/.kodi/addons/script.plex/lib/windows/kodigui.py", line 105, in onInit
                                                       self.onFirstInit()
                                                     File "/home/buri/.kodi/addons/script.plex/lib/windows/musicplayer.py", line 64, in onFirstInit
                                                       self.play()
                                                     File "/home/buri/.kodi/addons/script.plex/lib/windows/musicplayer.py", line 152, in play
                                                       player.PLAYER.playAudioPlaylist(self.playlist, startpos=list(self.playlist.items()).index(self.track), fanart=fanart)
                                                     File "/home/buri/.kodi/addons/script.plex/lib/player.py", line 858, in playAudioPlaylist
                                                       url, li = self.createTrackListItem(track, fanart, index=index)
                                                     File "/home/buri/.kodi/addons/script.plex/lib/player.py", line 874, in createTrackListItem
                                                       data = base64.urlsafe_b64encode(track.serialize())
                                                     File "/usr/lib64/python3.6/base64.py", line 118, in urlsafe_b64encode
                                                       return b64encode(s).translate(_urlsafe_encode_translation)
                                                     File "/usr/lib64/python3.6/base64.py", line 58, in b64encode
                                                       encoded = binascii.b2a_base64(s, newline=False)
                                                   TypeError: a bytes-like object is required, not 'str'
                                                   -->End of Python script error report<--
jhoms commented

Found a way to fix it. Not sure it is the best though. I made changes in plugin.py and player.py:

~/.kodi/addons/script.plex/plugin.py

play()
#44
-        plexObject = plexobjects.PlexObject.deSerialize(base64.urlsafe_b64decode(data))
+        plexObject = plexobjects.PlexObject.deSerialize(base64.urlsafe_b64decode(data[1:]))

~/.kodi/addons/script.plexli/player.py

extractTrackInfo()

#516
-            track = plexobjects.PlexObject.deSerialize(base64.urlsafe_b64decode(data.encode('utf-8')))
+            track = plexobjects.PlexObject.deSerialize(base64.urlsafe_b64decode(data[1:].encode('utf-8')))

createTrackListItem()

#870
-        data = base64.urlsafe_b64encode(track.serialize())
+        data = base64.urlsafe_b64encode(bytearray(track.serialize(),'utf-8'))

Hope it helps.

Found a way to fix it. Not sure it is the best though. I made changes in plugin.py and player.py:

~/.kodi/addons/script.plex/plugin.py

play()
#44
-        plexObject = plexobjects.PlexObject.deSerialize(base64.urlsafe_b64decode(data))
+        plexObject = plexobjects.PlexObject.deSerialize(base64.urlsafe_b64decode(data[1:]))

~/.kodi/addons/script.plexli/player.py

extractTrackInfo()

#516
-            track = plexobjects.PlexObject.deSerialize(base64.urlsafe_b64decode(data.encode('utf-8')))
+            track = plexobjects.PlexObject.deSerialize(base64.urlsafe_b64decode(data[1:].encode('utf-8')))

createTrackListItem()

#870
-        data = base64.urlsafe_b64encode(track.serialize())
+        data = base64.urlsafe_b64encode(bytearray(track.serialize(),'utf-8'))

Hope it helps.

I have an Nvidia Shield running Kodi / Plex. Where and how would I even find these files?

jhoms commented

Found a way to fix it. Not sure it is the best though. I made changes in plugin.py and player.py:

~/.kodi/addons/script.plex/plugin.py

play()
#44
-        plexObject = plexobjects.PlexObject.deSerialize(base64.urlsafe_b64decode(data))
+        plexObject = plexobjects.PlexObject.deSerialize(base64.urlsafe_b64decode(data[1:]))

~/.kodi/addons/script.plexli/player.py

extractTrackInfo()

#516
-            track = plexobjects.PlexObject.deSerialize(base64.urlsafe_b64decode(data.encode('utf-8')))
+            track = plexobjects.PlexObject.deSerialize(base64.urlsafe_b64decode(data[1:].encode('utf-8')))

createTrackListItem()

#870
-        data = base64.urlsafe_b64encode(track.serialize())
+        data = base64.urlsafe_b64encode(bytearray(track.serialize(),'utf-8'))

Hope it helps.

I have an Nvidia Shield running Kodi / Plex. Where and how would I even find these files?

Maybe this could help

https://forum.kodi.tv/showthread.php?tid=285399

@jhoms That worked PERFECTLY! Thank you.
I am now able to use Plex for the first time since this summer!

I do have some questions. Why did it break in the first place? And why not put this fix in the production code?

Also, my Shield says the current version is 0.3.4, but GitHub says latest version is 0.1.6.
I just want to have this work - permanently and understand what the situation is.

And thanks for responding!

jhoms commented

Why did it break in the first place?

My guess is that with Matrix upgrade some python libraries got upgraded to and they work different.

And why not put this fix in the production code?

I don't know. I was just in the same situation as you, but with my little knowledge of python found a workaround. I am glad it is working for you too.

Regarding the versions, I don't know. Maybe the people who takes care of this piece of code can. They can also make this change in the original code (even find a better fix) so future upgrades work fine out of the box.

This solution worked for me.

Details:

Add-on version: latest (0.3.4)
Kodi version: Matrix v19.3
OS Platform: Android 11.0
Hardware: Nvidia Shield

Thx @jhoms

Found a way to fix it. Not sure it is the best though. I made changes in plugin.py and player.py:

~/.kodi/addons/script.plex/plugin.py

play()
#44
-        plexObject = plexobjects.PlexObject.deSerialize(base64.urlsafe_b64decode(data))
+        plexObject = plexobjects.PlexObject.deSerialize(base64.urlsafe_b64decode(data[1:]))

~/.kodi/addons/script.plexli/player.py

extractTrackInfo()

#516
-            track = plexobjects.PlexObject.deSerialize(base64.urlsafe_b64decode(data.encode('utf-8')))
+            track = plexobjects.PlexObject.deSerialize(base64.urlsafe_b64decode(data[1:].encode('utf-8')))

createTrackListItem()

#870
-        data = base64.urlsafe_b64encode(track.serialize())
+        data = base64.urlsafe_b64encode(bytearray(track.serialize(),'utf-8'))

Hope it helps.

it's worked!Thank you very much!!
But,have a new issues.
when click “Next Track” or “Previous Track” button,plex Add-on will crash.

jhoms commented

Found a way to fix it. Not sure it is the best though. I made changes in plugin.py and player.py:

~/.kodi/addons/script.plex/plugin.py

play()
#44
-        plexObject = plexobjects.PlexObject.deSerialize(base64.urlsafe_b64decode(data))
+        plexObject = plexobjects.PlexObject.deSerialize(base64.urlsafe_b64decode(data[1:]))

~/.kodi/addons/script.plexli/player.py

extractTrackInfo()

#516
-            track = plexobjects.PlexObject.deSerialize(base64.urlsafe_b64decode(data.encode('utf-8')))
+            track = plexobjects.PlexObject.deSerialize(base64.urlsafe_b64decode(data[1:].encode('utf-8')))

createTrackListItem()

#870
-        data = base64.urlsafe_b64encode(track.serialize())
+        data = base64.urlsafe_b64encode(bytearray(track.serialize(),'utf-8'))

Hope it helps.

it's worked!Thank you very much!! But,have a new issues. when click “Next Track” or “Previous Track” button,plex Add-on will crash.

I was trying to reproduce your problem but in my installation is working fine, so it is hard for me to find a way to fix it. Sorry.

I have the same problem which as you can see has been there since 2021 ... today I installed the new libreelec on RPi4 and the plex script on it, everything works except the music itself. Is it such a problem for the developers to care and fix this bug? When I download the Composite add-on I can play the audio in it without any problems.

when click “Next Track” or “Previous Track” button,plex Add-on will crash.

me too.it's worked.but when click “Next Track” or “Previous Track” button,plex Add-on will crash.

Same

Add-on version: latest
Kodi version: matrix
OS Platform: libreleec
Hardware: pi4

Still have the problem with Plex-Addon. I haven't tried the workaround yet.