diff --git a/components/JFVideo.brs b/components/JFVideo.brs index 7054bfd6..37ff237e 100644 --- a/components/JFVideo.brs +++ b/components/JFVideo.brs @@ -28,6 +28,44 @@ sub init() m.getNextEpisodeTask = createObject("roSGNode", "GetNextEpisodeTask") m.getNextEpisodeTask.observeField("nextEpisodeData", "onNextEpisodeDataLoaded") + m.top.observeField("state", "onState") + m.top.observeField("content", "onContentChange") + + 'Captions + m.captionGroup = m.top.findNode("captionGroup") + m.captionGroup.createchildren(9, "LayoutGroup") + m.captionTask = createObject("roSGNode", "captionTask") + m.captionTask.observeField("currentCaption", "updateCaption") + m.captionTask.observeField("useThis", "checkCaptionMode") + m.top.observeField("currentSubtitleTrack", "loadCaption") + m.top.observeField("globalCaptionMode", "toggleCaption") + if get_user_setting("playback.subs.custom") = "false" + m.top.suppressCaptions = false + else + m.top.suppressCaptions = true + toggleCaption() + end if +end sub + +sub loadCaption() + if m.top.suppressCaptions + m.captionTask.url = m.top.currentSubtitleTrack + end if +end sub + +sub toggleCaption() + m.captionTask.playerState = m.top.state + m.top.globalCaptionMode + if LCase(m.top.globalCaptionMode) = "on" + m.captionTask.playerState = m.top.state + m.top.globalCaptionMode + "w" + m.captionGroup.visible = true + else + m.captionGroup.visible = false + end if +end sub + +sub updateCaption () + m.captionGroup.removeChildrenIndex(m.captionGroup.getChildCount(), 0) + m.captionGroup.appendChildren(m.captionTask.currentCaption) end sub ' Event handler for when video content field changes @@ -36,25 +74,18 @@ sub onContentChange() m.top.observeField("position", "onPositionChanged") - ' If video content type is not episode, remove position observer - if m.top.content.contenttype <> 4 - m.top.unobserveField("position") - end if end sub sub onNextEpisodeDataLoaded() m.checkedForNextEpisode = true m.top.observeField("position", "onPositionChanged") - - if m.getNextEpisodeTask.nextEpisodeData.Items.count() <> 2 - m.top.unobserveField("position") - end if end sub ' ' Runs Next Episode button animation and sets focus to button sub showNextEpisodeButton() + if m.top.content.contenttype <> 4 then return if not m.nextEpisodeButton.visible m.showNextEpisodeButtonAnimation.control = "start" m.nextEpisodeButton.setFocus(true) @@ -82,13 +113,9 @@ end sub ' Checks if we need to display the Next Episode button sub checkTimeToDisplayNextEpisode() - nextEpisodeCountdown = Int(m.top.runTime - m.top.position) - if nextEpisodeCountdown < 0 - hideNextEpisodeButton() - return - end if + if m.top.content.contenttype <> 4 then return - if int(m.top.position) >= (m.top.runTime - Val(m.nextupbuttonseconds)) + if int(m.top.position) >= (m.top.runTime - 30) showNextEpisodeButton() updateCount() return @@ -102,6 +129,7 @@ end sub ' When Video Player state changes sub onPositionChanged() + m.captionTask.currentPos = Int(m.top.position * 1000) ' Check if dialog is open m.dialog = m.top.getScene().findNode("dialogBackground") if not isValid(m.dialog) @@ -112,6 +140,7 @@ end sub ' ' When Video Player state changes sub onState(msg) + m.captionTask.playerState = m.top.state + m.top.globalCaptionMode ' When buffering, start timer to monitor buffering process if m.top.state = "buffering" and m.bufferCheckTimer <> invalid @@ -134,7 +163,6 @@ sub onState(msg) m.top.control = "stop" m.top.backPressed = true else if m.top.state = "playing" - ' Check if next episde is available if isValid(m.top.showID) if m.top.showID <> "" and not m.checkedForNextEpisode and m.top.content.contenttype = 4 diff --git a/components/JFVideo.xml b/components/JFVideo.xml index 3d444f16..7b3ca425 100644 --- a/components/JFVideo.xml +++ b/components/JFVideo.xml @@ -1,4 +1,4 @@ - + @@ -7,7 +7,6 @@ - @@ -23,6 +22,7 @@ +