Add view counter

This commit is contained in:
Brahim Hadriche committed 2022-11-05 17:39:26 -04:00
1 parent 8aa17a0b6a
commit 3032023e87
4 files changed
+33 -2

No files matched your search

+1 -1
View File
@@ -16,7 +16,7 @@
rowitemSize="[[320,180]]"
rowItemSpacing="[[20,0]]"
itemSize="[1160,270]"
itemSpacing="[0,45]"
itemSpacing="[0,65]"
rowLabelOffset="[[50,20]]"
focusXOffset="[50]"
showRowLabel="[true]"
@@ -7,6 +7,7 @@ sub OnContentSet()
m.top.FindNode("titleLabel").text = content.title
m.top.FindNode("authorLabel").text = content.author
m.top.FindNode("dateLabel").text = content.releaseDate
m.top.FindNode("viewCountLabel").text = FormatViewCount(content.viewCount)
m.top.FindNode("poster").uri = content.hdPosterUrl
if content.length <> invalid and content.length <> 0
m.top.FindNode("durationLabel").text = RokuYoutube.Utils.GetFormattedTime(content.length)
@@ -15,3 +16,25 @@ sub OnContentSet()
end if
end if
end sub
function FormatViewCount(viewCount)
if viewCount < 1000
return `${FormatFloat(viewCount)} views`
end if
viewCount = viewCount / 1000
if viewCount < 1000
return `${FormatFloat(viewCount)}K views`
end if
viewCount = viewCount / 1000
return `${FormatFloat(viewCount)}M views`
end function
function FormatFloat(X)
X = X * 10
X = X + 0.5
X = Fix(X)
X = X / 10
return X
end function
@@ -52,7 +52,14 @@
height="25"
horizAlign="right"
font="font:SmallestSystemFont"
translation="[0, 225]"
translation="[0, 250]"
/>
<Label
id="viewCountLabel"
width="320"
height="25"
font="font:SmallestSystemFont"
translation="[0, 250]"
/>
</children>
</component>
+1
View File
@@ -79,5 +79,6 @@ function GetItemData(video as object) as object
item.id = video.videoId
item.length = video.lengthSeconds
item.author = video.author
item.viewCount = video.viewCount
return item
end function