Fix to alternate version playback

This commit is contained in:
Jimi 2022-03-13 08:22:55 -06:00
parent 129be19a07
commit 1e1b396f85
4 changed files with 20 additions and 14 deletions

View File

@ -202,13 +202,13 @@ sub Main (args as dynamic) as void
end if
' Check to see if a specific video "version" was selected
mediaSourceId = invalid
if group.selectedVideoStreamId <> invalid
video_id = group.selectedVideoStreamId
else
video_id = group.id
mediaSourceId = group.selectedVideoStreamId
end if
video_id = group.id
video = CreateVideoPlayerGroup(video_id, audio_stream_idx)
video = CreateVideoPlayerGroup(video_id, mediaSourceId, audio_stream_idx)
if video <> invalid
sceneManager.callFunc("pushScene", video)
end if

View File

@ -373,9 +373,9 @@ sub CreateSidePanel(buttons, options)
group.options = options
end sub
function CreateVideoPlayerGroup(video_id, audio_stream_idx = 1)
function CreateVideoPlayerGroup(video_id, mediaSourceId = invalid, audio_stream_idx = 1)
' Video is Playing
video = VideoPlayer(video_id, audio_stream_idx)
video = VideoPlayer(video_id, mediaSourceId, audio_stream_idx)
if video = invalid then return invalid
video.observeField("selectSubtitlePressed", m.port)
video.observeField("state", m.port)

View File

@ -1,9 +1,9 @@
function VideoPlayer(id, audio_stream_idx = 1, subtitle_idx = -1)
function VideoPlayer(id, mediaSourceId = invalid, audio_stream_idx = 1, subtitle_idx = -1)
' Get video controls and UI
video = CreateObject("roSGNode", "JFVideo")
video.id = id
AddVideoContent(video, audio_stream_idx, subtitle_idx)
AddVideoContent(video, mediaSourceId, audio_stream_idx, subtitle_idx)
if video.content = invalid
return invalid
@ -16,7 +16,7 @@ function VideoPlayer(id, audio_stream_idx = 1, subtitle_idx = -1)
return video
end function
sub AddVideoContent(video, audio_stream_idx = 1, subtitle_idx = -1, playbackPosition = -1)
sub AddVideoContent(video, mediaSourceId, audio_stream_idx = 1, subtitle_idx = -1, playbackPosition = -1)
video.content = createObject("RoSGNode", "ContentNode")
@ -64,12 +64,15 @@ sub AddVideoContent(video, audio_stream_idx = 1, subtitle_idx = -1, playbackPosi
video.content.PlayStart = int(playbackPosition / 10000000)
' Call PlayInfo from server
mediaSourceId = video.id
if mediaSourceId = invalid
mediaSourceId = video.id
end if
if meta.live then mediaSourceId = "" ' Don't send mediaSourceId for Live media
playbackInfo = ItemPostPlaybackInfo(video.id, mediaSourceId, audio_stream_idx, subtitle_idx, playbackPosition)
video.videoId = video.id
video.mediaSourceId = video.id
video.mediaSourceId = mediaSourceId
video.audioIndex = audio_stream_idx
if playbackInfo = invalid
@ -112,6 +115,9 @@ sub AddVideoContent(video, audio_stream_idx = 1, subtitle_idx = -1, playbackPosi
"PlaySessionId": video.PlaySessionId,
"AudioStreamIndex": audio_stream_idx
})
if mediaSourceId <> ""
params.MediaSourceId = mediaSourceId
end if
video.content.url = buildURL(Substitute("Videos/{0}/stream", video.id), params)
video.isTranscoded = false
video.audioTrack = (audio_stream_idx + 1).ToStr() ' Roku's track indexes count from 1. Our index is zero based

View File

@ -49,7 +49,7 @@ sub changeSubtitleDuringPlayback(newid)
' Switching to Encoded Subtitle stream
video.control = "stop"
AddVideoContent(video, video.audioIndex, newSubtitles.Index, video.position * 10000000)
AddVideoContent(video, video.mediaSourceId, video.audioIndex, newSubtitles.Index, video.position * 10000000)
video.control = "play"
video.globalCaptionMode = "Off" ' Using encoded subtitles - so turn off text subtitles
@ -57,7 +57,7 @@ sub changeSubtitleDuringPlayback(newid)
' Switching from an Encoded stream to a text stream
video.control = "stop"
AddVideoContent(video, video.audioIndex, -1, video.position * 10000000)
AddVideoContent(video, video.mediaSourceId, video.audioIndex, -1, video.position * 10000000)
video.control = "play"
video.globalCaptionMode = "On"
video.subtitleTrack = video.availableSubtitleTracks[newSubtitles.TextIndex].TrackName
@ -82,7 +82,7 @@ sub turnoffSubtitles()
' Check if Enoded subtitles are being displayed, and turn off
if current > -1 and video.Subtitles[current].IsEncoded
video.control = "stop"
AddVideoContent(video, video.audioIndex, -1, video.position * 10000000)
AddVideoContent(video, video.mediaSourceId, video.audioIndex, -1, video.position * 10000000)
video.control = "play"
end if
end sub