diff --git a/components/JFVideo.brs b/components/JFVideo.brs index 500853b6..c8a0540b 100644 --- a/components/JFVideo.brs +++ b/components/JFVideo.brs @@ -30,8 +30,12 @@ sub init() m.top.observeField("state", "onState") m.top.observeField("content", "onContentChange") + m.top.observeField("allowCaptions", "onAllowCaptionsChange") +end sub + +sub onAllowCaptionsChange() + if not m.top.allowCaptions then return - 'Captions m.captionGroup = m.top.findNode("captionGroup") m.captionGroup.createchildren(9, "LayoutGroup") m.captionTask = createObject("roSGNode", "captionTask") @@ -129,7 +133,9 @@ end sub ' When Video Player state changes sub onPositionChanged() - m.captionTask.currentPos = Int(m.top.position * 1000) + if isValid(m.captionTask) + m.captionTask.currentPos = Int(m.top.position * 1000) + end if ' Check if dialog is open m.dialog = m.top.getScene().findNode("dialogBackground") if not isValid(m.dialog) @@ -140,7 +146,9 @@ end sub ' ' When Video Player state changes sub onState(msg) - m.captionTask.playerState = m.top.state + m.top.globalCaptionMode + if isValid(m.captionTask) + m.captionTask.playerState = m.top.state + m.top.globalCaptionMode + end if ' When buffering, start timer to monitor buffering process if m.top.state = "buffering" and m.bufferCheckTimer <> invalid diff --git a/components/JFVideo.xml b/components/JFVideo.xml index 3a122e1d..16325998 100644 --- a/components/JFVideo.xml +++ b/components/JFVideo.xml @@ -16,6 +16,7 @@ + diff --git a/components/captionTask.brs b/components/captionTask.brs index 5a58b20a..8eb34ef3 100644 --- a/components/captionTask.brs +++ b/components/captionTask.brs @@ -28,13 +28,12 @@ end sub sub setFont() fs = CreateObject("roFileSystem") - fontlist = fs.Find("tmp:/", "font") - if fontlist.count() > 0 - m.font.uri = "tmp:/" + fontlist[0] + + if fs.Exists("tmp:/font") + m.font.uri = "tmp:/font" m.font.size = m.fontSize else - reg = CreateObject("roFontRegistry") - m.font = reg.GetDefaultFont(m.fontSize, false, false) + m.font = "font:LargeSystemFont" end if end sub @@ -56,6 +55,7 @@ function newlabel(txt) label = CreateObject("roSGNode", "Label") label.text = txt label.font = m.font + label.font.size = m.fontSize label.color = m.textColor label.opacity = m.textOpac return label @@ -89,7 +89,7 @@ function newRect(lg) end function -sub updateCaption () +sub updateCaption() m.top.currentCaption = [] if LCase(m.top.playerState) = "playingon" m.top.currentPos = m.top.currentPos + 100 diff --git a/source/ShowScenes.brs b/source/ShowScenes.brs index 7f8502fe..6d777ef2 100644 --- a/source/ShowScenes.brs +++ b/source/ShowScenes.brs @@ -542,6 +542,9 @@ function CreateVideoPlayerGroup(video_id, mediaSourceId = invalid, audio_stream_ video = VideoPlayer(video_id, mediaSourceId, audio_stream_idx, defaultSubtitleTrackFromVid(video_id), forceTranscoding, showIntro, allowResumeDialog) if video = invalid then return invalid + + video.allowCaptions = true + if video.errorMsg = "introaborted" then return video video.observeField("selectSubtitlePressed", m.port) video.observeField("selectPlaybackInfoPressed", m.port) diff --git a/source/VideoPlayer.brs b/source/VideoPlayer.brs index 7d3e1e22..171bf7f1 100644 --- a/source/VideoPlayer.brs +++ b/source/VideoPlayer.brs @@ -332,6 +332,9 @@ function PlayIntroVideo(video_id, audio_stream_idx) as boolean if lcase(introVideos.items[0].name) = "rick roll'd" then return true introVideo = VideoPlayer(introVideos.items[0].id, introVideos.items[0].id, audio_stream_idx, defaultSubtitleTrackFromVid(video_id), false, false) + if isValid(introVideo) + introVideo.allowCaptions = false + end if port = CreateObject("roMessagePort") introVideo.observeField("state", port)