plex-for-kodi icon indicating copy to clipboard operation
plex-for-kodi copied to clipboard

Music doesn't play in Kodi Matrix

Open wormvortex opened this issue 3 years ago • 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

wormvortex avatar Jul 26 '21 19:07 wormvortex

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)

Asgardsurfer avatar Jul 27 '21 16:07 Asgardsurfer

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)

Indrikis480 avatar Aug 13 '21 05:08 Indrikis480

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

SonGoku90 avatar Aug 15 '21 19:08 SonGoku90

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<--

Buri avatar Sep 18 '21 08:09 Buri

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.

jhoms avatar Sep 26 '21 09:09 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.

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

basildane avatar Nov 27 '21 00:11 basildane

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 avatar Nov 27 '21 08:11 jhoms

@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!

basildane avatar Nov 27 '21 17:11 basildane

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.

jhoms avatar Nov 28 '21 07:11 jhoms

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

DarkissGit avatar Feb 23 '22 14:02 DarkissGit

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.

jaysh-yin avatar Jun 03 '22 06:06 jaysh-yin

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.

jhoms avatar Jun 18 '22 07:06 jhoms

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.

Kotva666 avatar Jun 19 '22 12:06 Kotva666

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.

yangn0 avatar Aug 05 '22 19:08 yangn0

Same

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

ericconnelly avatar Aug 24 '22 18:08 ericconnelly

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

mike-d-b avatar Nov 02 '22 12:11 mike-d-b