Skip to content

Commit

Permalink
Merge pull request #871 from 1hitsong/additionalPartResume
Browse files Browse the repository at this point in the history
Fix lockup on Additional Parts resume
  • Loading branch information
1hitsong authored Dec 9, 2022
2 parents 1989314 + 1b2392b commit cc8d74d
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 103 deletions.
7 changes: 6 additions & 1 deletion source/Main.brs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,12 @@ sub Main (args as dynamic) as void
dialog.title = tr("Loading Channel Data")
m.scene.dialog = dialog

video = CreateVideoPlayerGroup(video_id)
if LCase(selectedItem.subtype()) = "extrasdata"
video = CreateVideoPlayerGroup(video_id, invalid, 1, false, true, false)
else
video = CreateVideoPlayerGroup(video_id)
end if

dialog.close = true

if video <> invalid and video.errorMsg <> "introaborted"
Expand Down
4 changes: 2 additions & 2 deletions source/ShowScenes.brs
Original file line number Diff line number Diff line change
Expand Up @@ -498,10 +498,10 @@ sub CreateSidePanel(buttons, options)
group.options = options
end sub

function CreateVideoPlayerGroup(video_id, mediaSourceId = invalid, audio_stream_idx = 1, forceTranscoding = false, showIntro = true)
function CreateVideoPlayerGroup(video_id, mediaSourceId = invalid, audio_stream_idx = 1, forceTranscoding = false, showIntro = true, allowResumeDialog = true)

' Video is Playing
video = VideoPlayer(video_id, mediaSourceId, audio_stream_idx, defaultSubtitleTrackFromVid(video_id), forceTranscoding, showIntro)
video = VideoPlayer(video_id, mediaSourceId, audio_stream_idx, defaultSubtitleTrackFromVid(video_id), forceTranscoding, showIntro, allowResumeDialog)

if video = invalid then return invalid
if video.errorMsg = "introaborted" then return video
Expand Down
202 changes: 102 additions & 100 deletions source/VideoPlayer.brs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
function VideoPlayer(id, mediaSourceId = invalid, audio_stream_idx = 1, subtitle_idx = -1, forceTranscoding = false, showIntro = true)
function VideoPlayer(id, mediaSourceId = invalid, audio_stream_idx = 1, subtitle_idx = -1, forceTranscoding = false, showIntro = true, allowResumeDialog = true)
' Get video controls and UI
video = CreateObject("roSGNode", "JFVideo")
video.id = id
AddVideoContent(video, mediaSourceId, audio_stream_idx, subtitle_idx, -1, forceTranscoding, showIntro)
AddVideoContent(video, mediaSourceId, audio_stream_idx, subtitle_idx, -1, forceTranscoding, showIntro, allowResumeDialog)

if video.errorMsg = "introaborted"
return video
Expand All @@ -19,7 +19,7 @@ function VideoPlayer(id, mediaSourceId = invalid, audio_stream_idx = 1, subtitle
return video
end function

sub AddVideoContent(video, mediaSourceId, audio_stream_idx = 1, subtitle_idx = -1, playbackPosition = -1, forceTranscoding = false, showIntro = true)
sub AddVideoContent(video, mediaSourceId, audio_stream_idx = 1, subtitle_idx = -1, playbackPosition = -1, forceTranscoding = false, showIntro = true, allowResumeDialog = true)
video.content = createObject("RoSGNode", "ContentNode")
meta = ItemMetaData(video.id)
m.videotype = meta.type
Expand Down Expand Up @@ -55,103 +55,105 @@ sub AddVideoContent(video, mediaSourceId, audio_stream_idx = 1, subtitle_idx = -

if playbackPosition = -1
playbackPosition = meta.json.UserData.PlaybackPositionTicks
if playbackPosition > 0
dialogResult = startPlayBackOver(playbackPosition)
'Dialog returns -1 when back pressed, 0 for resume, and 1 for start over
if dialogResult = -1
'User pressed back, return invalid and don't load video
video.content = invalid
return
else if dialogResult = 1
'Start Over selected, change position to 0
playbackPosition = 0
else if dialogResult = 2
'Mark this item as watched, refresh the page, and return invalid so we don't load the video
MarkItemWatched(video.id)
video.content.watched = not video.content.watched
group = m.scene.focusedChild
group.timeLastRefresh = CreateObject("roDateTime").AsSeconds()
group.callFunc("refresh")
video.content = invalid
return
else if dialogResult = 3
'get series ID based off episiode ID
params = {
ids: video.Id
}
url = Substitute("Users/{0}/Items/", get_setting("active_user"))
resp = APIRequest(url, params)
data = getJson(resp)
for each item in data.Items
m.series_id = item.SeriesId
end for
'Get series json data
params = {
ids: m.series_id
}
url = Substitute("Users/{0}/Items/", get_setting("active_user"))
resp = APIRequest(url, params)
data = getJson(resp)
for each item in data.Items
m.tmp = item
end for
'Create Series Scene
CreateSeriesDetailsGroup(m.tmp)
video.content = invalid
return

else if dialogResult = 4
'get Season/Series ID based off episiode ID
params = {
ids: video.Id
}
url = Substitute("Users/{0}/Items/", get_setting("active_user"))
resp = APIRequest(url, params)
data = getJson(resp)
for each item in data.Items
m.season_id = item.SeasonId
m.series_id = item.SeriesId
end for
'Get Series json data
params = {
ids: m.season_id
}
url = Substitute("Users/{0}/Items/", get_setting("active_user"))
resp = APIRequest(url, params)
data = getJson(resp)
for each item in data.Items
m.Season_tmp = item
end for
'Get Season json data
params = {
ids: m.series_id
}
url = Substitute("Users/{0}/Items/", get_setting("active_user"))
resp = APIRequest(url, params)
data = getJson(resp)
for each item in data.Items
m.Series_tmp = item
end for
'Create Season Scene
CreateSeasonDetailsGroup(m.Series_tmp, m.Season_tmp)
video.content = invalid
return

else if dialogResult = 5
'get episiode ID
params = {
ids: video.Id
}
url = Substitute("Users/{0}/Items/", get_setting("active_user"))
resp = APIRequest(url, params)
data = getJson(resp)
for each item in data.Items
m.episode_id = item
end for
'Create Episode Scene
CreateMovieDetailsGroup(m.episode_id)
video.content = invalid
return
if allowResumeDialog
if playbackPosition > 0
dialogResult = startPlayBackOver(playbackPosition)
'Dialog returns -1 when back pressed, 0 for resume, and 1 for start over
if dialogResult = -1
'User pressed back, return invalid and don't load video
video.content = invalid
return
else if dialogResult = 1
'Start Over selected, change position to 0
playbackPosition = 0
else if dialogResult = 2
'Mark this item as watched, refresh the page, and return invalid so we don't load the video
MarkItemWatched(video.id)
video.content.watched = not video.content.watched
group = m.scene.focusedChild
group.timeLastRefresh = CreateObject("roDateTime").AsSeconds()
group.callFunc("refresh")
video.content = invalid
return
else if dialogResult = 3
'get series ID based off episiode ID
params = {
ids: video.Id
}
url = Substitute("Users/{0}/Items/", get_setting("active_user"))
resp = APIRequest(url, params)
data = getJson(resp)
for each item in data.Items
m.series_id = item.SeriesId
end for
'Get series json data
params = {
ids: m.series_id
}
url = Substitute("Users/{0}/Items/", get_setting("active_user"))
resp = APIRequest(url, params)
data = getJson(resp)
for each item in data.Items
m.tmp = item
end for
'Create Series Scene
CreateSeriesDetailsGroup(m.tmp)
video.content = invalid
return

else if dialogResult = 4
'get Season/Series ID based off episiode ID
params = {
ids: video.Id
}
url = Substitute("Users/{0}/Items/", get_setting("active_user"))
resp = APIRequest(url, params)
data = getJson(resp)
for each item in data.Items
m.season_id = item.SeasonId
m.series_id = item.SeriesId
end for
'Get Series json data
params = {
ids: m.season_id
}
url = Substitute("Users/{0}/Items/", get_setting("active_user"))
resp = APIRequest(url, params)
data = getJson(resp)
for each item in data.Items
m.Season_tmp = item
end for
'Get Season json data
params = {
ids: m.series_id
}
url = Substitute("Users/{0}/Items/", get_setting("active_user"))
resp = APIRequest(url, params)
data = getJson(resp)
for each item in data.Items
m.Series_tmp = item
end for
'Create Season Scene
CreateSeasonDetailsGroup(m.Series_tmp, m.Season_tmp)
video.content = invalid
return

else if dialogResult = 5
'get episiode ID
params = {
ids: video.Id
}
url = Substitute("Users/{0}/Items/", get_setting("active_user"))
resp = APIRequest(url, params)
data = getJson(resp)
for each item in data.Items
m.episode_id = item
end for
'Create Episode Scene
CreateMovieDetailsGroup(m.episode_id)
video.content = invalid
return
end if
end if
end if
end if
Expand Down

0 comments on commit cc8d74d

Please sign in to comment.