From 2fc121fc504c20b5836f699eac498dc4973cfd59 Mon Sep 17 00:00:00 2001 From: Jinho Kim Date: Thu, 26 Jan 2023 19:03:09 -0500 Subject: [PATCH 01/16] Subtitle rendering using a task node Crude subtitle renderer piggybacking on the JFVideo component --- components/JFVideo.brs | 32 ++++++++++++++- components/JFVideo.xml | 10 +++++ components/captionTask.brs | 82 +++++++++++++++++++++++++++++++++++++ components/captionTask.xml | 13 ++++++ fonts/noto.otf | Bin 0 -> 4744692 bytes fonts/notoB.otf | Bin 0 -> 4909668 bytes 6 files changed, 136 insertions(+), 1 deletion(-) create mode 100644 components/captionTask.brs create mode 100644 components/captionTask.xml create mode 100644 fonts/noto.otf create mode 100644 fonts/notoB.otf diff --git a/components/JFVideo.brs b/components/JFVideo.brs index a6fe67fc1..b4de92963 100644 --- a/components/JFVideo.brs +++ b/components/JFVideo.brs @@ -27,6 +27,36 @@ sub init() m.getNextEpisodeTask = createObject("roSGNode", "GetNextEpisodeTask") m.getNextEpisodeTask.observeField("nextEpisodeData", "onNextEpisodeDataLoaded") + m.top.observeField("state", "onState") + m.top.observeField("content", "onContentChange") + + 'Captions + m.captionBG = m.top.findNode("captionBG") + m.captionGroup = m.top.findNode("captionGroup") + + m.captionTask = createObject("roSGNode", "captionTask") + m.captionTask.observeField("currentCaption", "updateCaption") + m.top.observeField("captionVisible", "toggleCaption") + m.top.observeField("currentSubtitleTrack", "loadCaption") +end sub + +sub loadCaption() + ' if type (m.top.currentSubtitleTrack) <> invalid then + m.captionTask.url = m.top.currentSubtitleTrack + ' end if +end sub + +sub toggleCaption() + m.captionGroup.visible = m.top.captionVisible + m.captionBG.visible = m.top.captionVisible +end sub + +sub updateCaption () + while m.captionGroup.removeChildIndex(0) + end while + m.captionGroup.appendChildren(m.captionTask.currentCaption) + m.captionBG.height = m.captionGroup.BoundingRect().height + m.captionBG.width = m.captionGroup.BoundingRect().width end sub ' Event handler for when video content field changes @@ -91,7 +121,7 @@ end sub ' When Video Player state changes sub onPositionChanged() - ' Check if dialog is open + m.captionTask.currentPos = Cint(m.top.position * 1000) m.dialog = m.top.getScene().findNode("dialogBackground") if not isValid(m.dialog) checkTimeToDisplayNextEpisode() diff --git a/components/JFVideo.xml b/components/JFVideo.xml index 3d444f162..1c5530d4d 100644 --- a/components/JFVideo.xml +++ b/components/JFVideo.xml @@ -23,6 +23,8 @@ + +