Live banner on live videos
This commit is contained in:
1 parent
b113fcfe7e
commit
8aa1d1ae51
4 files changed
+56
-30
No files matched your search
@@ -107,7 +107,7 @@ function OnHomeGridScreenVideoSelected(event as object) as void
|
|||||||
rowContent = grid.content.GetChild(selectedRow)
|
rowContent = grid.content.GetChild(selectedRow)
|
||||||
itemContent = rowContent.GetChild(selectedRowItem)
|
itemContent = rowContent.GetChild(selectedRowItem)
|
||||||
|
|
||||||
videoId = itemContent.id
|
videoId = itemContent.videoId
|
||||||
|
|
||||||
if m.videoPlayer <> invalid
|
if m.videoPlayer <> invalid
|
||||||
if m.videoPlayer.videoId = videoId
|
if m.videoPlayer.videoId = videoId
|
||||||
@@ -160,7 +160,7 @@ function OnHomeGridScreenVideoFocused(event as object) as void
|
|||||||
rowContent = grid.content.GetChild(selectedRow)
|
rowContent = grid.content.GetChild(selectedRow)
|
||||||
itemContent = rowContent.GetChild(selectedRowItem)
|
itemContent = rowContent.GetChild(selectedRowItem)
|
||||||
|
|
||||||
videoId = itemContent.id
|
videoId = itemContent.videoId
|
||||||
thumbnail = GetThumbnailPoster(videoId)
|
thumbnail = GetThumbnailPoster(videoId)
|
||||||
ShowVideoScreenEmbedded(videoId, thumbnail)
|
ShowVideoScreenEmbedded(videoId, thumbnail)
|
||||||
end function
|
end function
|
||||||
|
|||||||
@@ -56,27 +56,7 @@ function GetItemData(video as object) as object
|
|||||||
if video.videoId = invalid
|
if video.videoId = invalid
|
||||||
return invalid
|
return invalid
|
||||||
end if
|
end if
|
||||||
item = {}
|
|
||||||
|
|
||||||
item.title = video.title
|
return video
|
||||||
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
|
|
||||||
end function
|
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,23 +7,51 @@ function 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
|
||||||
|
|
||||||
releaseDate = validstr(content.releaseDate)
|
publishedText = validstr(content.publishedText)
|
||||||
viewCount = FormatViewCount(content.viewCount)
|
viewCount = FormatViewCount(content.viewCount)
|
||||||
if releaseDate = "" and viewCount = ""
|
if publishedText = "" and viewCount = ""
|
||||||
m.top.FindNode("viewCountDateLabel").text = ""
|
m.top.FindNode("viewCountDateLabel").text = ""
|
||||||
else
|
else
|
||||||
m.top.FindNode("viewCountDateLabel").text = `${releaseDate} • ${viewCount}`
|
m.top.FindNode("viewCountDateLabel").text = `${publishedText} • ${viewCount}`
|
||||||
end if
|
end if
|
||||||
|
|
||||||
thumbnail = m.top.FindNode("thumbnail")
|
thumbnail = m.top.FindNode("thumbnail")
|
||||||
thumbnail.uri = content.hdPosterUrl
|
thumbnail.uri = GetThumbnailUrl(content.videoThumbnails)
|
||||||
thumbnail.id = `thumbnail-${content.id}`
|
thumbnail.id = `thumbnail-${content.videoId}`
|
||||||
if content.length <> invalid and content.length <> 0
|
|
||||||
m.top.FindNode("durationLabel").text = TimeUtils.GetFormattedTime(content.length)
|
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
|
else
|
||||||
m.top.FindNode("durationRect").visible = false
|
m.top.FindNode("durationRect").visible = false
|
||||||
end if
|
end if
|
||||||
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
|
end function
|
||||||
|
|
||||||
function FormatViewCount(viewCount as dynamic) as string
|
function FormatViewCount(viewCount as dynamic) as string
|
||||||
|
|||||||
@@ -32,6 +32,24 @@
|
|||||||
inheritParentOpacity="true"
|
inheritParentOpacity="true"
|
||||||
/>
|
/>
|
||||||
</Rectangle>
|
</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>
|
</Poster>
|
||||||
|
|
||||||
<Label
|
<Label
|
||||||
|
|||||||
Reference in new issue
Block a user