Add view counter
This commit is contained in:
1 parent
8aa17a0b6a
commit
3032023e87
4 files changed
+33
-2
No files matched your search
@@ -16,7 +16,7 @@
|
|||||||
rowitemSize="[[320,180]]"
|
rowitemSize="[[320,180]]"
|
||||||
rowItemSpacing="[[20,0]]"
|
rowItemSpacing="[[20,0]]"
|
||||||
itemSize="[1160,270]"
|
itemSize="[1160,270]"
|
||||||
itemSpacing="[0,45]"
|
itemSpacing="[0,65]"
|
||||||
rowLabelOffset="[[50,20]]"
|
rowLabelOffset="[[50,20]]"
|
||||||
focusXOffset="[50]"
|
focusXOffset="[50]"
|
||||||
showRowLabel="[true]"
|
showRowLabel="[true]"
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ sub OnContentSet()
|
|||||||
m.top.FindNode("titleLabel").text = content.title
|
m.top.FindNode("titleLabel").text = content.title
|
||||||
m.top.FindNode("authorLabel").text = content.author
|
m.top.FindNode("authorLabel").text = content.author
|
||||||
m.top.FindNode("dateLabel").text = content.releaseDate
|
m.top.FindNode("dateLabel").text = content.releaseDate
|
||||||
|
m.top.FindNode("viewCountLabel").text = FormatViewCount(content.viewCount)
|
||||||
m.top.FindNode("poster").uri = content.hdPosterUrl
|
m.top.FindNode("poster").uri = content.hdPosterUrl
|
||||||
if content.length <> invalid and content.length <> 0
|
if content.length <> invalid and content.length <> 0
|
||||||
m.top.FindNode("durationLabel").text = RokuYoutube.Utils.GetFormattedTime(content.length)
|
m.top.FindNode("durationLabel").text = RokuYoutube.Utils.GetFormattedTime(content.length)
|
||||||
@@ -15,3 +16,25 @@ sub OnContentSet()
|
|||||||
end if
|
end if
|
||||||
end if
|
end if
|
||||||
end sub
|
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"
|
height="25"
|
||||||
horizAlign="right"
|
horizAlign="right"
|
||||||
font="font:SmallestSystemFont"
|
font="font:SmallestSystemFont"
|
||||||
translation="[0, 225]"
|
translation="[0, 250]"
|
||||||
|
/>
|
||||||
|
<Label
|
||||||
|
id="viewCountLabel"
|
||||||
|
width="320"
|
||||||
|
height="25"
|
||||||
|
font="font:SmallestSystemFont"
|
||||||
|
translation="[0, 250]"
|
||||||
/>
|
/>
|
||||||
</children>
|
</children>
|
||||||
</component>
|
</component>
|
||||||
@@ -79,5 +79,6 @@ function GetItemData(video as object) as object
|
|||||||
item.id = video.videoId
|
item.id = video.videoId
|
||||||
item.length = video.lengthSeconds
|
item.length = video.lengthSeconds
|
||||||
item.author = video.author
|
item.author = video.author
|
||||||
|
item.viewCount = video.viewCount
|
||||||
return item
|
return item
|
||||||
end function
|
end function
|
||||||
Reference in new issue
Block a user