Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graceful episode playback failure #997

Merged
merged 8 commits into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions components/JFVideo.brs
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,10 @@ sub onState(msg)
m.top.retryWithTranscoding = true ' If playback was not reported, retry with transcoding
else
' If an error was encountered, Display dialog
dialog = createObject("roSGNode", "Dialog")
dialog = createObject("roSGNode", "PlaybackDialog")
dialog.title = tr("Error During Playback")
dialog.buttons = [tr("OK")]
dialog.message = tr("An error was encountered while playing this item.")
dialog.observeField("buttonSelected", "dialogClosed")
m.top.getScene().dialog = dialog
end if

Expand Down Expand Up @@ -197,11 +196,10 @@ sub bufferCheck(msg)
m.top.callFunc("refresh")
else
' If buffering has stopped Display dialog
dialog = createObject("roSGNode", "Dialog")
dialog = createObject("roSGNode", "PlaybackDialog")
dialog.title = tr("Error Retrieving Content")
dialog.buttons = [tr("OK")]
dialog.message = tr("There was an error retrieving the data for this item from the server.")
dialog.observeField("buttonSelected", "dialogClosed")
m.top.getScene().dialog = dialog

' Stop playback and exit player
Expand All @@ -212,14 +210,6 @@ sub bufferCheck(msg)

end sub

'
' Clean up on Dialog Closed
sub dialogClosed(msg)
sourceNode = msg.getRoSGNode()
sourceNode.unobserveField("buttonSelected")
sourceNode.close = true
end sub

function onKeyEvent(key as string, press as boolean) as boolean

if key = "OK" and m.nextEpisodeButton.hasfocus() and not m.top.trickPlayBar.visible
Expand Down
8 changes: 8 additions & 0 deletions components/PlaybackDialog.brs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function onKeyEvent(key as string, press as boolean) as boolean

if key = "OK"
m.top.close = true
sevenrats marked this conversation as resolved.
Show resolved Hide resolved
end if

return true
end function
6 changes: 6 additions & 0 deletions components/PlaybackDialog.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- A PlaybackDialog is a regular dialog, except it takes key releases -->
<!-- instead of presses so that key releases don't fall into other listeners -->
<component name="PlaybackDialog" extends="Dialog">
<script type="text/brightscript" uri="PlaybackDialog.brs" />
</component>
6 changes: 5 additions & 1 deletion source/Main.brs
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,11 @@ sub Main (args as dynamic) as void
else if node.showID = invalid
sceneManager.callFunc("popScene")
else
autoPlayNextEpisode(node.id, node.showID)
if video.errorMsg = ""
autoPlayNextEpisode(node.id, node.showID)
else
sceneManager.callFunc("popScene")
end if
end if
end if
else if type(msg) = "roDeviceInfoEvent"
Expand Down
4 changes: 3 additions & 1 deletion source/VideoPlayer.brs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ sub AddVideoContent(video, mediaSourceId, audio_stream_idx = 1, subtitle_idx = -
end if

if m.videotype = "Episode" or m.videotype = "Series"
video.runTime = (meta.json.RunTimeTicks / 10000000.0)
if isValid(meta.json.RunTimeTicks)
video.runTime = (meta.json.RunTimeTicks / 10000000.0)
end if
video.content.contenttype = "episode"
end if

Expand Down