Live banner on live videos
This commit is contained in:
1 parent
b113fcfe7e
commit
8aa1d1ae51
4 files changed
+57
-31
No files matched your search
@@ -107,7 +107,7 @@ function OnHomeGridScreenVideoSelected(event as object) as void
|
||||
rowContent = grid.content.GetChild(selectedRow)
|
||||
itemContent = rowContent.GetChild(selectedRowItem)
|
||||
|
||||
videoId = itemContent.id
|
||||
videoId = itemContent.videoId
|
||||
|
||||
if m.videoPlayer <> invalid
|
||||
if m.videoPlayer.videoId = videoId
|
||||
@@ -160,7 +160,7 @@ function OnHomeGridScreenVideoFocused(event as object) as void
|
||||
rowContent = grid.content.GetChild(selectedRow)
|
||||
itemContent = rowContent.GetChild(selectedRowItem)
|
||||
|
||||
videoId = itemContent.id
|
||||
videoId = itemContent.videoId
|
||||
thumbnail = GetThumbnailPoster(videoId)
|
||||
ShowVideoScreenEmbedded(videoId, thumbnail)
|
||||
end function
|
||||
|
||||
@@ -56,27 +56,7 @@ function GetItemData(video as object) as object
|
||||
if video.videoId = invalid
|
||||
return invalid
|
||||
end if
|
||||
item = {}
|
||||
|
||||
item.title = video.title
|
||||
item.description = video.description
|
||||
item.hdPosterURL = GetThumbnailUrl(video.videoThumbnails)
|
||||
item.releaseDate = video.publishedText
|
||||
item.id = video.videoId
|
||||
item.length = video.lengthSeconds
|
||||
item.author = video.author
|
||||
item.viewCount = video.viewCount
|
||||
return item
|
||||
return video
|
||||
end function
|
||||
|
||||
function GetThumbnailUrl(videoThumbnails as object, quality = "medium" as string) as string
|
||||
if videoThumbnails.Count() = 0
|
||||
return ""
|
||||
end if
|
||||
for each thumbnail in videoThumbnails
|
||||
if thumbnail.quality = quality
|
||||
return thumbnail.url
|
||||
end if
|
||||
end for
|
||||
return videoThumbnails[0].url
|
||||
end function
|
||||
@@ -7,25 +7,53 @@ function OnContentSet()
|
||||
m.top.FindNode("titleLabel").text = content.title
|
||||
m.top.FindNode("authorLabel").text = content.author
|
||||
|
||||
releaseDate = validstr(content.releaseDate)
|
||||
publishedText = validstr(content.publishedText)
|
||||
viewCount = FormatViewCount(content.viewCount)
|
||||
if releaseDate = "" and viewCount = ""
|
||||
if publishedText = "" and viewCount = ""
|
||||
m.top.FindNode("viewCountDateLabel").text = ""
|
||||
else
|
||||
m.top.FindNode("viewCountDateLabel").text = `${releaseDate} • ${viewCount}`
|
||||
m.top.FindNode("viewCountDateLabel").text = `${publishedText} • ${viewCount}`
|
||||
end if
|
||||
|
||||
thumbnail = m.top.FindNode("thumbnail")
|
||||
thumbnail.uri = content.hdPosterUrl
|
||||
thumbnail.id = `thumbnail-${content.id}`
|
||||
if content.length <> invalid and content.length <> 0
|
||||
m.top.FindNode("durationLabel").text = TimeUtils.GetFormattedTime(content.length)
|
||||
else
|
||||
thumbnail.uri = GetThumbnailUrl(content.videoThumbnails)
|
||||
thumbnail.id = `thumbnail-${content.videoId}`
|
||||
|
||||
if IsVideoLive(content)
|
||||
m.top.FindNode("liveRect").visible = true
|
||||
m.top.FindNode("durationRect").visible = false
|
||||
else
|
||||
m.top.FindNode("liveRect").visible = false
|
||||
if content.lengthSeconds <> invalid and content.lengthSeconds <> 0
|
||||
m.top.FindNode("durationLabel").text = TimeUtils.GetFormattedTime(content.lengthSeconds)
|
||||
m.top.FindNode("durationRect").visible = true
|
||||
else
|
||||
m.top.FindNode("durationRect").visible = false
|
||||
end if
|
||||
end if
|
||||
end if
|
||||
end function
|
||||
|
||||
function GetThumbnailUrl(videoThumbnails as object, quality = "medium" as string) as string
|
||||
if videoThumbnails.Count() = 0
|
||||
return ""
|
||||
end if
|
||||
for each thumbnail in videoThumbnails
|
||||
if thumbnail.quality = quality
|
||||
return thumbnail.url
|
||||
end if
|
||||
end for
|
||||
return videoThumbnails[0].url
|
||||
end function
|
||||
|
||||
function IsVideoLive(metadata as object) as boolean
|
||||
if metadata.liveNow = true
|
||||
return true
|
||||
end if
|
||||
' TODO: metadata.liveNow is returning false for live videos...
|
||||
return metadata.lengthSeconds = 0 and metadata.viewCount = 0
|
||||
end function
|
||||
|
||||
function FormatViewCount(viewCount as dynamic) as string
|
||||
if viewCount = invalid
|
||||
return ""
|
||||
|
||||
@@ -32,6 +32,24 @@
|
||||
inheritParentOpacity="true"
|
||||
/>
|
||||
</Rectangle>
|
||||
<Rectangle
|
||||
id="liveRect"
|
||||
width="60"
|
||||
height="25"
|
||||
color="0xFF0000"
|
||||
translation="[290, 162]"
|
||||
>
|
||||
<Label
|
||||
width="60"
|
||||
height="25"
|
||||
id="liveLabel"
|
||||
horizAlign="center"
|
||||
vertAlign="center"
|
||||
font="font:SmallestBoldSystemFont"
|
||||
inheritParentOpacity="true"
|
||||
text="LIVE"
|
||||
/>
|
||||
</Rectangle>
|
||||
</Poster>
|
||||
|
||||
<Label
|
||||
|
||||
Reference in new issue
Block a user