Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 33 additions & 26 deletions components/video/OSD.bs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ sub init()
m.videoInfo = m.top.findNode("videoInfo")
m.itemTitle = m.top.findNode("itemTitle")
m.videoPlayPause = m.top.findNode("videoPlayPause")
m.videoRemainingTime = m.top.findNode("videoRemainingTime")
m.videoEndingTime = m.top.findNode("videoEndingTime")
m.belowLeft = m.top.findNode("belowLeft")
m.aboveRight = m.top.findNode("aboveRight")
m.belowRight = m.top.findNode("belowRight")
m.aboveLeft = m.top.findNode("aboveLeft")
m.clock = m.top.findNode("clock")
m.progressBar = m.top.findNode("progressBar")
m.progressBarBackground = m.top.findNode("progressBarBackground")
m.progressIndicator = m.top.findNode("progressIndicator")
Expand All @@ -34,7 +37,8 @@ sub init()
m.top.observeField("hasFocus", "onFocusChanged")
m.top.observeField("progressPercentage", "onProgressPercentageChanged")
m.top.observeField("playbackState", "onPlaybackStateChanged")
m.top.observeField("videoEndingTime", "setVideoEndingTime")
' Ends-at is recalculated on a clock timer, so it moves while paused when position doesn't
m.top.observeField("videoEndingTime", "updateOSDTime")

m.top.observeField("itemTitleText", "onItemTitleTextChanged")
m.top.observeField("itemSubtitleText", "onItemSubtitleTextChanged")
Expand Down Expand Up @@ -83,51 +87,54 @@ sub init()
positionSecondaryControls()
end sub

function formatOSDTimeSlot(slotKey as string) as string
' A previewPosition below zero means use the live playback position
function formatOSDTimeSlot(slotKey as string, previewPosition as float) as string
slotMode = m.global.session.user.settings[slotKey] ?? "none"
if slotMode = "none" or slotMode = "" then return ""
if slotMode = "elapsed" then return secondsToHuman(m.top.positionTime, true)
if slotMode = "remaining" then return "-" + secondsToHuman(m.top.remainingPositionTime, true)

totalTime = m.top.positionTime + m.top.remainingPositionTime
position = previewPosition >= 0 ? previewPosition : m.top.positionTime

if slotMode = "elapsed" then return secondsToHuman(position, true)
if slotMode = "endsAt" then return "Ends at " + m.top.videoEndingTime
if slotMode = "time" then return m.top.videoEndingTime
if slotMode = "time" then return m.clock.callFunc("getFormattedTime", m.clock.callFunc("getCurrentTime"), true)
' Both spellings are accepted because either can be the stored value
if slotMode = "timeRemaining" or slotMode = "remaining" then return "-" + secondsToHuman(totalTime - position, true)
if slotMode = "totalDuration" or slotMode = "totalTime" then return secondsToHuman(totalTime, true)
return ""
end function

' Every slot is assigned so that switching one to None clears whatever it was holding
sub renderOSDTimeSlots(previewPosition as float)
m.aboveLeft.text = formatOSDTimeSlot("playback.timeAboveLeft", previewPosition)
m.aboveRight.text = formatOSDTimeSlot("playback.timeAboveRight", previewPosition)
m.belowLeft.text = formatOSDTimeSlot("playback.timeBelowLeft", previewPosition)
m.belowRight.text = formatOSDTimeSlot("playback.timeBelowRight", previewPosition)
end sub

' Observer callbacks receive an event argument when they declare a parameter, so this stays bare
sub updateOSDTime()
renderOSDTimeSlots(-1)
end sub

' onProgressPercentageChanged: Handler for changes to m.top.progressPercentage param
'
sub onProgressPercentageChanged()
totalTime = m.top.positionTime + m.top.remainingPositionTime
m.progressBar.width = m.progressBarBackground.width * m.top.progressPercentage

aboveLeft = formatOSDTimeSlot("playback.timeAboveLeft")
aboveRight = formatOSDTimeSlot("playback.timeAboveRight")
if aboveLeft <> "" or aboveRight <> ""
m.videoRemainingTime.text = (aboveLeft <> "" ? aboveLeft : "") + (aboveRight <> "" ? " / " + aboveRight : "")
else
m.videoRemainingTime.text = secondsToHuman(m.top.positionTime, true) + " / " + secondsToHuman(totalTime, true)
end if
updateOSDTime()

' Update circle indicator position (centered on progress, offset by circle radius)
indicatorX = 103 + (m.progressBarBackground.width * m.top.progressPercentage) - 10
m.progressIndicator.translation = [indicatorX, 812]
end sub

sub setVideoEndingTime()
belowRight = formatOSDTimeSlot("playback.timeBelowRight")
if belowRight <> ""
m.videoEndingTime.text = belowRight
else
m.videoEndingTime.text = "Ends at " + m.top.videoEndingTime
end if
end sub

sub updateSeekPreview(totalTime as float)
newPosition = totalTime * m.seekPercentage
m.progressBar.width = m.progressBarBackground.width * m.seekPercentage
renderOSDTimeSlots(newPosition)

indicatorX = 103 + (m.progressBarBackground.width * m.seekPercentage) - 10
m.progressIndicator.translation = [indicatorX, 812]
m.videoRemainingTime.text = secondsToHuman(newPosition, true) + " / " + secondsToHuman(totalTime, true)
m.top.action = "seek," + newPosition.ToStr()
end sub

Expand Down
8 changes: 5 additions & 3 deletions components/video/OSD.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@
</Group>
<Poster id="progressIndicator" uri="pkg:/images/icons/circle.png" width="20" height="20" translation="[103,812]" loadDisplayMode="scaleToFit" />

<Text id="videoEndingTime" font="font:SmallSystemFont" color="0xffffffFF" horizAlign="right" width="300" translation="[1517,780]" />
<Text id="videoRemainingTime" font="font:MediumSystemFont" color="0xffffffFF" horizAlign="left" width="300" translation="[103,855]" />
<Text id="aboveRight" font="font:MediumSystemFont" color="0xffffffFF" horizAlign="right" width="300" translation="[1517,780]" />
<Text id="belowLeft" font="font:MediumSystemFont" color="0xffffffFF" horizAlign="left" width="300" translation="[103,855]" />
<Text id="belowRight" font="font:MediumSystemFont" color="0xffffffFF" horizAlign="right" width="300" translation="[1517,855]" />
<Text id="aboveLeft" font="font:MediumSystemFont" color="0xffffffFF" horizAlign="left" width="300" translation="[103,780]" />

<!-- Secondary controls (same row as transport, positioned dynamically) -->
<LayoutGroup id="secondaryControls" itemSpacings="[20]" layoutDirection="horiz" horizAlignment="left" translation="[843,920]">
Expand Down Expand Up @@ -101,4 +103,4 @@
<field id="hasFocus" type="boolean" alwaysNotify="true" />
<field id="focusTarget" type="string" value="seekbar" />
</interface>
</component>
</component>
66 changes: 21 additions & 45 deletions settings/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -1975,87 +1975,63 @@
]
},
{
"title": "Media Bar Playback Time Above Left",
"title": "Progress Bar Time Above Left",
"description": "Select information to display above the progress bar on the left side",
"settingName": "playback.timeAboveLeft",
"type": "radio",
"default": "elapsed",
"options": [
{ "title": "None", "id": "none" },
{ "title": "Current Time", "id": "time" },
{ "title": "Elapsed Time", "id": "elapsed" },
{ "title": "Remaining Time", "id": "remaining" },
{ "title": "Ends At Time", "id": "endsAt" }
]
},
{
"title": "Media Bar Playback Time Above Center",
"description": "Select information to display above the progress bar in the center",
"settingName": "playback.timeAboveCenter",
"type": "radio",
"default": "none",
"options": [
{ "title": "None", "id": "none" },
{ "title": "Current Time", "id": "time" },
{ "title": "Elapsed Time", "id": "elapsed" },
{ "title": "Remaining Time", "id": "remaining" },
{ "title": "Ends At Time", "id": "endsAt" }
]
},
{
"title": "Media Bar Playback Time Above Right",
"description": "Select information to display above the progress bar on the right side",
"settingName": "playback.timeAboveRight",
"type": "radio",
"default": "remaining",
"options": [
{ "title": "None", "id": "none" },
{ "title": "Current Time", "id": "time" },
{ "title": "Elapsed Time", "id": "elapsed" },
{ "title": "Remaining Time", "id": "remaining" },
{ "title": "Ends At Time", "id": "endsAt" }
{ "title": "Remaining Time", "id": "timeRemaining" },
{ "title": "Ends At Time", "id": "endsAt" },
{ "title": "Total Duration", "id": "totalDuration" }
]
},
{
"title": "Media Bar Playback Time Below Left",
"title": "Progress Bar Time Below Left",
"description": "Select information to display below the progress bar on the left side",
"settingName": "playback.timeBelowLeft",
"type": "radio",
"default": "none",
"default": "elapsed",
"options": [
{ "title": "None", "id": "none" },
{ "title": "Current Time", "id": "time" },
{ "title": "Elapsed Time", "id": "elapsed" },
{ "title": "Remaining Time", "id": "remaining" },
{ "title": "Ends At Time", "id": "endsAt" }
{ "title": "Remaining Time", "id": "timeRemaining" },
{ "title": "Ends At Time", "id": "endsAt" },
{ "title": "Total Duration", "id": "totalDuration" }
]
},
{
"title": "Media Bar Playback Time Below Center",
"description": "Select information to display below the progress bar in the center",
"settingName": "playback.timeBelowCenter",
"title": "Progress Bar Time Above Right",
"description": "Select information to display above the progress bar on the right side",
"settingName": "playback.timeAboveRight",
"type": "radio",
"default": "none",
"default": "endsAt",
"options": [
{ "title": "None", "id": "none" },
{ "title": "Current Time", "id": "time" },
{ "title": "Elapsed Time", "id": "elapsed" },
{ "title": "Remaining Time", "id": "remaining" },
{ "title": "Ends At Time", "id": "endsAt" }
{ "title": "Remaining Time", "id": "timeRemaining" },
{ "title": "Ends At Time", "id": "endsAt" },
{ "title": "Total Duration", "id": "totalDuration" }
]
},
{
"title": "Media Bar Playback Time Below Right",
"title": "Progress Bar Time Below Right",
"description": "Select information to display below the progress bar on the right side",
"settingName": "playback.timeBelowRight",
"type": "radio",
"default": "endsAt",
"default": "totalDuration",
"options": [
{ "title": "None", "id": "none" },
{ "title": "Current Time", "id": "time" },
{ "title": "Elapsed Time", "id": "elapsed" },
{ "title": "Remaining Time", "id": "remaining" },
{ "title": "Ends At Time", "id": "endsAt" }
{ "title": "Remaining Time", "id": "timeRemaining" },
{ "title": "Ends At Time", "id": "endsAt" },
{ "title": "Total Duration", "id": "totalDuration" }
]
}
]
Expand Down
2 changes: 0 additions & 2 deletions source/utils/settingsSync.bs
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,8 @@ namespace settingsSync
{ pluginKey: "mergeRadarrSonarrCalendars", rokuKey: "calendar.merge", type: "bool" },

{ pluginKey: "playbackTimeAboveLeft", rokuKey: "playback.timeAboveLeft", type: "direct" },
{ pluginKey: "playbackTimeAboveCenter", rokuKey: "playback.timeAboveCenter", type: "direct" },
{ pluginKey: "playbackTimeAboveRight", rokuKey: "playback.timeAboveRight", type: "direct" },
{ pluginKey: "playbackTimeBelowLeft", rokuKey: "playback.timeBelowLeft", type: "direct" },
{ pluginKey: "playbackTimeBelowCenter", rokuKey: "playback.timeBelowCenter", type: "direct" },
{ pluginKey: "playbackTimeBelowRight", rokuKey: "playback.timeBelowRight", type: "direct" },
{ pluginKey: "musicPlaybackTimeDisplay", rokuKey: "playback.musicTimeDisplay", type: "direct" },

Expand Down