jellyfin / jellyfin-roku

The Official Roku Client for Jellyfin
https://jellyfin.org
GNU General Public License v2.0
412 stars 129 forks source link

Fix proposed: App crash on when attempting to playback from Emby server #467

Closed chaosloth closed 2 years ago

chaosloth commented 3 years ago

Application hangs when playing any media from Emby server due to server responding with NoCompatibleStream . There are two bugs that need to be fixed (see below)

Steps to Reproduce

  1. Load JellyFin client on Roku box, in my case Telstra TV
  2. Connect to server
  3. Choose any media file to play
  4. Once Play button is clicked, application hangs
  5. Roku debug output shows crash with pkg:/source/VideoPlayer.brs

Resolution for crash

The issue is caused by uncaught error in AddVideoContent(), in response to a POST {server}/Items/{0}/PlaybackInfo the server returns {"MediaSources":[],"ErrorCode":"NoCompatibleStream"} The fix to stop the app crash is to add a check on the returned error code and to bail out of the function.

After VideoPlayer.brs:61 playbackInfo = ItemPostPlaybackInfo(video.id, mediaSourceId, audio_stream_idx, subtitle_idx, playbackPosition)

Add something like this

  if playbackinfo.ErrorCode = "NoCompatibleStream"
    video.content = invalid
    return
  end if

Resolution for root cause

The underlying cause to the NoCompatibleStream is due to mediasourceid being passed with an invalid value. The value being passed is the video.id, where as it should either be blank or the actual media source id. A simple fix is to simply force it to be null.

Simply replace, near line VideoPlayer.brs:59 with comment: ' Call PlayInfo from server mediaSourceId = video.id

with mediaSourceId = ""

-Enjoy. Conno

jimdogx commented 2 years ago

Thank you! This fixed my inability to play anything on my new TCL Roku TV (jellyfin worked just fine with a previous TV and a Roku USB stick).

neilsb commented 2 years ago

Thank you! This fixed my inability to play anything on my new TCL Roku TV (jellyfin worked just fine with a previous TV and a Roku USB stick).

Can I just check if you were having problems playing from a Jellyfin server, or were you using an Emby server?

crobibero commented 2 years ago

Thank you! This fixed my inability to play anything on my new TCL Roku TV (jellyfin worked just fine with a previous TV and a Roku USB stick).

Can I just check if you were having problems playing from a Jellyfin server, or were you using an Emby server?

It’s (my) Jellyfin server, currently running 10.8-alpha2

jimdogx commented 2 years ago

Can I just check if you were having problems playing from a Jellyfin server, or were you using an Emby server?

Sorry, I should have been more clear, this is connecting to a Jellyfin server. I know this issue is specific to the Emby server, but after debugging the latest master branch I found it was crashing for the same reason (NoCompatibleStream error). Also note that the latest jellyfin-roku from the Roku store was working fine with an old Roku USB stick. This only started happening when I upgraded to a TCL Roku TV.

neilsb commented 2 years ago

OK - thanks - that's great. I see your comment on #397 too. I'll look check exactly what's happening and get that fix in place as long as it doesn't look like it will affect anything else.

neilsb commented 2 years ago

There were 2 lines (in one place) that was setting the MediaSourceId to the video id. All other references in the app appear to be setting to the correct MediaSourceId (or empty string).

Updated the 2 lines that were setting it incorrectly to use the correct MediaSourceId.

jimdogx commented 2 years ago

FYI @neilsb, I pulled down your branch with the fix and it worked on my TCL Roku TV. 👍