diff --git a/components/JFVideo.brs b/components/JFVideo.brs index b2b1c40c6..6d65b7c11 100644 --- a/components/JFVideo.brs +++ b/components/JFVideo.brs @@ -38,21 +38,24 @@ sub init() m.captionTask.observeField("useThis", "checkCaptionMode") m.top.observeField("currentSubtitleTrack", "loadCaption") m.top.observeField("globalCaptionMode", "toggleCaption") - - m.top.suppressCaptions = True - 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() - m.top.suppressCaptions = m.captionTask.useThis - m.captionTask.url = m.top.currentSubtitleTrack + 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 m.top.globalCaptionMode = "On" - m.captionTask.playerState = m.captionTask.playerState + "Wait" + 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 @@ -60,8 +63,7 @@ sub toggleCaption() end sub sub updateCaption () - while m.captionGroup.removeChildIndex(0) - end while + m.captionGroup.removeChildrenIndex(m.captionGroup.getChildCount(), 0) m.captionGroup.appendChildren(m.captionTask.currentCaption) end sub @@ -71,10 +73,6 @@ 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() @@ -86,12 +84,11 @@ end sub ' ' Runs Next Episode button animation and sets focus to button sub showNextEpisodeButton() - if m.top.content.contenttype = 4 - if not m.nextEpisodeButton.visible - m.showNextEpisodeButtonAnimation.control = "start" - m.nextEpisodeButton.setFocus(true) - m.nextEpisodeButton.visible = true - end if + if m.top.content.contenttype <> 4 then return + if not m.nextEpisodeButton.visible + m.showNextEpisodeButtonAnimation.control = "start" + m.nextEpisodeButton.setFocus(true) + m.nextEpisodeButton.visible = true end if end sub @@ -111,24 +108,24 @@ end sub ' Checks if we need to display the Next Episode button sub checkTimeToDisplayNextEpisode() - if m.top.content.contenttype = 4 + if m.top.content.contenttype <> 4 then return - if int(m.top.position) >= (m.top.runTime - 30) - showNextEpisodeButton() - updateCount() - return - end if + if int(m.top.position) >= (m.top.runTime - 30) + showNextEpisodeButton() + updateCount() + return + end if - if m.nextEpisodeButton.visible or m.nextEpisodeButton.hasFocus() - m.nextEpisodeButton.visible = false - m.nextEpisodeButton.setFocus(false) - end if + if m.nextEpisodeButton.visible or m.nextEpisodeButton.hasFocus() + m.nextEpisodeButton.visible = false + m.nextEpisodeButton.setFocus(false) end if 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) checkTimeToDisplayNextEpisode() diff --git a/components/captionTask.brs b/components/captionTask.brs index f285857d5..5a58b20a8 100644 --- a/components/captionTask.brs +++ b/components/captionTask.brs @@ -32,28 +32,27 @@ sub setFont() if fontlist.count() > 0 m.font.uri = "tmp:/" + fontlist[0] m.font.size = m.fontSize - m.top.useThis = True + else + reg = CreateObject("roFontRegistry") + m.font = reg.GetDefaultFont(m.fontSize, false, false) end if end sub sub fetchCaption() - if m.top.useThis + m.captionTimer.control = "stop" + re = CreateObject("roRegex", "(http.*?\.vtt)", "s") + url = re.match(m.top.url)[0] + if url <> invalid + m.reader.setUrl(url) + text = m.reader.GetToString() + m.captionList = parseVTT(text) + m.captionTimer.control = "start" + else m.captionTimer.control = "stop" - re = CreateObject("roRegex", "(http.*?\.vtt)", "s") - url = re.match(m.top.url)[0] - ?url - if url <> invalid - m.reader.setUrl(url) - text = m.reader.GetToString() - m.captionList = parseVTT(text) - m.captionTimer.control = "start" - else - m.captionTimer.control = "stop" - end if end if end sub -function newlabel(txt): +function newlabel(txt) label = CreateObject("roSGNode", "Label") label.text = txt label.font = m.font @@ -82,8 +81,9 @@ function newRect(lg) rect.width = 0 rect.height = 0 end if + rectLG.translation = [0, -rect.height / 2] rectLG.horizalignment = "center" - rectLG.vertalignment = "bottom" + rectLG.vertalignment = "center" rectLG.appendchild(rect) return rectLG end function @@ -91,7 +91,7 @@ end function sub updateCaption () m.top.currentCaption = [] - if m.top.playerState = "playingOn" + if LCase(m.top.playerState) = "playingon" m.top.currentPos = m.top.currentPos + 100 texts = [] for each entry in m.captionList @@ -107,10 +107,8 @@ sub updateCaption () lines = newLayoutGroup(labels) rect = newRect(lines) m.top.currentCaption = [rect, lines] - else if right(m.top.playerState, 4) = "Wait" - m.top.playerState = "playingOn" - else - m.top.currentCaption = [] + else if LCase(m.top.playerState.right(1)) = "w" + m.top.playerState = m.top.playerState.left(len (m.top.playerState) - 1) end if end sub diff --git a/components/captionTask.xml b/components/captionTask.xml index 20bef482f..167b9936d 100644 --- a/components/captionTask.xml +++ b/components/captionTask.xml @@ -5,7 +5,6 @@ -