Watching progress (#609)
* Watching progress * watch time endpoint * Lint fix * Changelog * options mandatory * tweak * tweak --------- Co-authored-by: github-action linter <githubaction@githubaction.com>
This commit is contained in:
1 parent
158788b42e
commit
8b123b18f5
14 files changed
+273
-95
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import "pkg:/source/utils/Locale.bs"
|
||||
import "pkg:/source/utils/MathUtils.bs"
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
import "pkg:/source/utils/TimeUtils.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
@@ -8,6 +9,7 @@ function Init()
|
||||
m.durationLabel = m.top.FindNode("durationLabel")
|
||||
m.smallestSystemFont = m.top.FindNode("smallestSystemFont")
|
||||
m.smallestBoldSystemFont = m.top.FindNode("smallestBoldSystemFont")
|
||||
m.progressRect = m.top.FindNode("progressRect")
|
||||
end function
|
||||
|
||||
function OnContentSet() as void
|
||||
@@ -53,6 +55,8 @@ function OnContentSet() as void
|
||||
|
||||
m.top.thumbnailUri = content.thumbnail
|
||||
|
||||
m.top.percentDurationWatched = content.percentDurationWatched
|
||||
|
||||
if not StringUtils.IsNullOrEmpty(content.lengthText)
|
||||
SetDurationLabel(content.lengthText, "#161616FF", 0.8, m.smallestSystemFont)
|
||||
m.top.durationRectVisible = true
|
||||
@@ -90,3 +94,11 @@ function SetDurationLabel(text as string, bgColor as string, bgOpacity as float,
|
||||
rect.opacity = bgOpacity
|
||||
end function
|
||||
|
||||
function OnPercentDurationWatched() as void
|
||||
if m.progressRect = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
percent = MathUtils.Clamp(m.top.percentDurationWatched, 0, 100) / 100.0
|
||||
m.progressRect.scale = [percent, 1]
|
||||
end function
|
||||
@@ -8,6 +8,7 @@
|
||||
<field id="durationRectVisible" type="boolean" alias="durationRect.visible" />
|
||||
<field id="duration" type="string" alias="durationLabel.text" />
|
||||
<field id="thumbnailUri" type="string" alias="thumbnail.uri" />
|
||||
<field id="percentDurationWatched" type="float" onChange="OnPercentDurationWatched" />
|
||||
</interface>
|
||||
<children>
|
||||
<Font id="smallestSystemFont" uri="font:SystemFontFile" size="18" />
|
||||
@@ -36,6 +37,14 @@
|
||||
font="font:SmallestSystemFont"
|
||||
translation="[8, 0]" />
|
||||
</Rectangle>
|
||||
<Rectangle
|
||||
id="progressRect"
|
||||
width="350"
|
||||
height="5"
|
||||
color="#FF0000"
|
||||
translation="[0, 192]"
|
||||
scale="[0, 1]">
|
||||
</Rectangle>
|
||||
</Poster>
|
||||
<Label
|
||||
id="titleLabel"
|
||||
|
||||
Reference in new issue
Block a user