Skip to content

Commit

Permalink
Added Settings for Remaining Time Display
Browse files Browse the repository at this point in the history
This adds a setting with controls the type of data displayed for remaining time: remaining time, completion time of day, or both.
  • Loading branch information
Renbo2024 committed Oct 11, 2024
1 parent 34b0978 commit 97961b3
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 2 deletions.
12 changes: 11 additions & 1 deletion components/video/OSD.bs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,17 @@ end sub
'
sub onProgressPercentageChanged()
m.videoPositionTime.text = secondsToHuman(m.top.positionTime, true)
m.videoRemainingTime.text = secondsToHuman(m.top.remainingPositionTime, true)

osdmode = m.global.session.user.settings["ui.general.osdremainingtime"]

if osdmode = "remaining"
m.videoRemainingTime.text = secondsToHuman(m.top.remainingPositionTime, true)
else if osdmode = "timeofday"
m.videoRemainingTime.text = secondsToEndTime(m.top.remainingPositionTime)
else if osdmode = "both"
m.videoRemainingTime.text = secondsToHuman(m.top.remainingPositionTime, true) + " | " + secondsToEndTime(m.top.remainingPositionTime)
end if

m.progressBar.width = m.progressBarBackground.width * m.top.progressPercentage
end sub

Expand Down
2 changes: 1 addition & 1 deletion components/video/OSD.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</Rectangle>

<Label id="videoPositionTime" font="font:MediumSystemFont" color="0xffffffFF" translation="[103,985]" />
<Label id="videoRemainingTime" font="font:MediumSystemFont" color="0xffffffFF" horizAlign="right" width="200" translation="[1617,985]" />
<Label id="videoRemainingTime" font="font:MediumSystemFont" color="0xffffffFF" horizAlign="right" width="400" translation="[1450,985]" />

<Timer id="inactivityTimer" duration="1" repeat="true" />
</children>
Expand Down
25 changes: 25 additions & 0 deletions locale/en_US/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1346,5 +1346,30 @@
<translation>View Season Details</translation>
<extracomment>User Setting - Setting option title</extracomment>
</message>
<message>
<source>OSD Remaining Time</source>
<translation>OSD Remaining Time</translation>
<extracomment>User Setting - Setting option title</extracomment>
</message>
<message>
<source>How is remaining time represented. Remaining time shows hours, minutes, and seconds remaining. Time of day shows what time the video will complete.</source>
<translation>How is remaining time represented. Remaining time shows hours, minutes, and seconds remaining. Time of day shows what time the video will complete.</translation>
<extracomment>User Setting - Setting description</extracomment>
</message>
<message>
<source>Remaining Time</source>
<translation>Remaining Time</translation>
<extracomment>User Setting - Setting option title</extracomment>
</message>
<message>
<source>Time of Day</source>
<translation>Time of Day</translation>
<extracomment>User Setting - Setting option title</extracomment>
</message>
<message>
<source>Both</source>
<translation>Both</translation>
<extracomment>User Setting - Setting option title</extracomment>
</message>
</context>
</TS>
21 changes: 21 additions & 0 deletions settings/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,27 @@
"type": "integer",
"default": "365"
},
{
"title": "OSD Remaining Time",
"description": "How is remaining time represented. Remaining time shows hours, minutes, and seconds remaining. Time of day shows what time the video will complete.",
"settingName": "ui.general.osdremainingtime",
"type": "radio",
"default": "remaining",
"options": [
{
"title": "Remaining Time",
"id": "remaining"
},
{
"title": "Time of Day",
"id": "timeofday"
},
{
"title": "Both",
"id": "both"
}
]
},
{
"title": "Rewatching Next Up",
"description": "Show already watched episodes in 'Next Up' sections.",
Expand Down
18 changes: 18 additions & 0 deletions source/utils/misc.bs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,24 @@ function secondsToHuman(totalSeconds as integer, addLeadingMinuteZero as boolean
return humanTime
end function

function secondsToEndTime(totalSeconds) as string
' Get the current time in seconds since midnight UTC (Unix Epoch Time)
currentUTCTime = CreateObject("roDateTime").AsSeconds()

' Calculate the target time in seconds by adding the number of seconds
targetTimeInSeconds = currentUTCTime + totalSeconds

' Create a new roDateTime object for the target time
targetDateTime = CreateObject("roDateTime")
targetDateTime.FromSeconds(targetTimeInSeconds)
targetDateTime.ToLocalTime()

formattedTime = formatTime(targetDateTime)

return formattedTime
end function


' Format time as 12 or 24 hour format based on system clock setting
function formatTime(time) as string
hours = time.getHours()
Expand Down

0 comments on commit 97961b3

Please sign in to comment.