diff --git a/src/components/HomeGridScreen/HomeGridScreen.bs b/src/components/HomeGridScreen/HomeGridScreen.bs index 01f90652..08a141f1 100644 --- a/src/components/HomeGridScreen/HomeGridScreen.bs +++ b/src/components/HomeGridScreen/HomeGridScreen.bs @@ -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 diff --git a/src/components/HomeGridScreen/HomeGridScreenTask.bs b/src/components/HomeGridScreen/HomeGridScreenTask.bs index b2fd4e3a..9205892b 100644 --- a/src/components/HomeGridScreen/HomeGridScreenTask.bs +++ b/src/components/HomeGridScreen/HomeGridScreenTask.bs @@ -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 diff --git a/src/components/VideoRowCell/VideoRowCell.bs b/src/components/VideoRowCell/VideoRowCell.bs index 4cc10559..2f5f91c8 100644 --- a/src/components/VideoRowCell/VideoRowCell.bs +++ b/src/components/VideoRowCell/VideoRowCell.bs @@ -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 "" diff --git a/src/components/VideoRowCell/VideoRowCell.xml b/src/components/VideoRowCell/VideoRowCell.xml index 8db47007..90a03d92 100644 --- a/src/components/VideoRowCell/VideoRowCell.xml +++ b/src/components/VideoRowCell/VideoRowCell.xml @@ -32,6 +32,24 @@ inheritParentOpacity="true" /> + +