Skip to content

Commit

Permalink
Add captionStyle support
Browse files Browse the repository at this point in the history
  • Loading branch information
jkim2492 committed Feb 7, 2023
1 parent 6e5e144 commit cc2b966
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
1 change: 1 addition & 0 deletions components/JFVideo.brs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ sub init()
m.captionTask.observeField("useThis", "checkCaptionMode")
m.top.observeField("currentSubtitleTrack", "loadCaption")
m.top.observeField("globalCaptionMode", "toggleCaption")

m.top.suppressCaptions = True
toggleCaption()

Expand Down
1 change: 0 additions & 1 deletion components/JFVideo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<field id="PlaySessionId" type="string" />
<field id="Subtitles" type="array" />
<field id="SelectedSubtitle" type="integer" />
<field id="captionMode" type="string" />
<field id="container" type="string" />
<field id="directPlaySupported" type="boolean" />
<field id="systemOverlay" type="boolean" value="false" />
Expand Down
22 changes: 17 additions & 5 deletions components/captionTask.brs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ sub init()
m.font = CreateObject("roSGNode", "Font")
m.tags = CreateObject("roRegex", "{\\an\d*}|&lt;.*?&gt;|<.*?>", "s")

' Caption Style
m.fontSizeDict = { "Default": 60, "Large": 60, "Extra Large": 70, "Medium": 50, "Small": 40 }
m.percentageDict = { "Default": 1.0, "100%": 1.0, "75%": 0.75, "25%": 0.25, "Off": 0 }
m.textColorDict = { "Default": &HFFFFFFFF, "White": &HFFFFFFFF, "Black": &H000000FF, "Red": &HFF0000FF, "Green": &H008000FF, "Blue": &H0000FFFF, "Yellow": &HFFFF00FF, "Magenta": &HFF00FFFF, "Cyan": &H00FFFFFF }
m.outlColorDict = { "Default": &H000000FF, "White": &HFFFFFFFF, "Black": &H000000FF, "Red": &HFF0000FF, "Green": &H008000FF, "Blue": &H0000FFFF, "Yellow": &HFFFF00FF, "Magenta": &HFF00FFFF, "Cyan": &H00FFFFFF }

m.settings = CreateObject("roDeviceInfo")
m.fontSize = m.fontSizeDict[m.settings.GetCaptionsOption("Text/Size")]
m.textColor = m.textColorDict[m.settings.GetCaptionsOption("Text/Color")]
m.textOpac = m.percentageDict[m.settings.GetCaptionsOption("Text/Opacity")]
m.outlColor = m.outlColorDict[m.settings.GetCaptionsOption("Background/Color")]
m.outlOpac = m.percentageDict[m.settings.GetCaptionsOption("Background/Opacity")]
setFont()
end sub

Expand All @@ -19,7 +31,7 @@ sub setFont()
fontlist = fs.Find("tmp:/", "font")
if fontlist.count() > 0
m.font.uri = "tmp:/" + fontlist[0]
m.font.size = 60
m.font.size = m.fontSize
m.top.useThis = True
end if
end sub
Expand All @@ -45,7 +57,8 @@ function newlabel(txt):
label = CreateObject("roSGNode", "Label")
label.text = txt
label.font = m.font
label.color = &H000000FF
label.color = m.outlColor
label.opacity = m.outlOpac
label.height = 108
return label
end function
Expand Down Expand Up @@ -73,8 +86,6 @@ sub updateCaption ()
texts = []
for each entry in m.captionList
if entry["start"] <= m.top.currentPos and m.top.currentPos < entry["end"]
' ?m.top.currentPos
' ?entry
t = m.tags.replaceAll(entry["text"], "")
texts.push(t)
end if
Expand All @@ -92,7 +103,8 @@ sub updateCaption ()
lglist.push(lgg)
end for
for q = 0 to 7
lglist[8].getchild(q).color = &HFFFFFFFF
lglist[8].getchild(q).color = m.textColor
lglist[8].getchild(q).opacity = m.textOpac
end for
m.top.currentCaption = lglist
else if right(m.top.playerState, 4) = "Wait"
Expand Down

0 comments on commit cc2b966

Please sign in to comment.