Background poster in dev player
This commit is contained in:
1 parent
38e8856b09
commit
37b3e88b93
3 files changed
+64
-17
No files matched your search
@@ -5,19 +5,25 @@ import "pkg:/components/Services/Invidious/InvidiousToContentNode.bs"
|
|||||||
function VideoContentTaskDev(input as object) as object
|
function VideoContentTaskDev(input as object) as object
|
||||||
titleLabel = input.titleLabel
|
titleLabel = input.titleLabel
|
||||||
secondaryTitleLabel = input.secondaryTitleLabel
|
secondaryTitleLabel = input.secondaryTitleLabel
|
||||||
|
backgroundPoster = input.backgroundPoster
|
||||||
contentNode = input.content
|
contentNode = input.content
|
||||||
invidiousNode = input.invidious
|
invidiousNode = input.invidious
|
||||||
|
|
||||||
titleLabel.text = contentNode.title
|
titleLabel.text = contentNode.title
|
||||||
secondaryTitleLabel.text = contentNode.secondaryTitle
|
secondaryTitleLabel.text = contentNode.secondaryTitle
|
||||||
|
|
||||||
if StringUtils.IsNullOrEmpty(contentNode.videoId)
|
videoId = contentNode.videoId
|
||||||
|
|
||||||
|
if StringUtils.IsNullOrEmpty(videoId)
|
||||||
throw "Can't load video information: videoId is missing"
|
throw "Can't load video information: videoId is missing"
|
||||||
end if
|
end if
|
||||||
|
|
||||||
service = new Invidious.InvidiousService(invidiousNode)
|
service = new Invidious.InvidiousService(invidiousNode)
|
||||||
|
instance = service.GetInstance()
|
||||||
|
|
||||||
response = service.GetVideoMetadata(contentNode.videoId, { cancellation: m.top.cancellation })
|
backgroundPoster.uri = `${instance}/vi/${videoId}/maxresdefault.jpg`
|
||||||
|
|
||||||
|
response = service.GetVideoMetadata(videoId, { cancellation: m.top.cancellation })
|
||||||
|
|
||||||
if m.top.cancel
|
if m.top.cancel
|
||||||
return invalid
|
return invalid
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ function Init()
|
|||||||
m.clock = m.top.findNode("Clock")
|
m.clock = m.top.findNode("Clock")
|
||||||
m.titleLabel = m.top.findNode("TitleLabel")
|
m.titleLabel = m.top.findNode("TitleLabel")
|
||||||
m.secondaryTitleLabel = m.top.findNode("SecondaryTitleLabel")
|
m.secondaryTitleLabel = m.top.findNode("SecondaryTitleLabel")
|
||||||
|
m.backgroundPoster = m.top.findNode("BackgroundPoster")
|
||||||
|
m.backgroundPosterSmall = m.top.findNode("BackgroundPosterSmall")
|
||||||
m.previousButton = m.top.findNode("PreviousButton")
|
m.previousButton = m.top.findNode("PreviousButton")
|
||||||
m.playButton = m.top.findNode("PlayButton")
|
m.playButton = m.top.findNode("PlayButton")
|
||||||
m.nextButton = m.top.findNode("NextButton")
|
m.nextButton = m.top.findNode("NextButton")
|
||||||
@@ -71,15 +73,25 @@ end function
|
|||||||
function PlayWithContent(contentNode as object)
|
function PlayWithContent(contentNode as object)
|
||||||
videoContentNode = CreateObject("roSGNode", "ContentNode")
|
videoContentNode = CreateObject("roSGNode", "ContentNode")
|
||||||
|
|
||||||
if not StringUtils.IsNullOrEmpty(contentNode.videoId)
|
videoId = contentNode.videoId
|
||||||
videoContentNode.AddFields({ videoId: contentNode.videoId })
|
title = contentNode.title
|
||||||
|
author = contentNode._author
|
||||||
|
thumbnail = contentNode.thumbnail
|
||||||
|
|
||||||
|
if not StringUtils.IsNullOrEmpty(videoId)
|
||||||
|
videoContentNode.AddFields({ videoId: videoId })
|
||||||
end if
|
end if
|
||||||
if not StringUtils.IsNullOrEmpty(contentNode.title)
|
if not StringUtils.IsNullOrEmpty(title)
|
||||||
videoContentNode.title = contentNode.title
|
videoContentNode.title = title
|
||||||
end if
|
end if
|
||||||
' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
|
' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
|
||||||
if not StringUtils.IsNullOrEmpty(contentNode._author)
|
if not StringUtils.IsNullOrEmpty(author)
|
||||||
videoContentNode.secondaryTitle = contentNode._author
|
videoContentNode.secondaryTitle = author
|
||||||
|
end if
|
||||||
|
|
||||||
|
if not StringUtils.IsNullOrEmpty(thumbnail)
|
||||||
|
videoContentNode.thumbnail = thumbnail
|
||||||
|
m.backgroundPosterSmall.uri = thumbnail
|
||||||
end if
|
end if
|
||||||
|
|
||||||
StartVideoContentTask(videoContentNode)
|
StartVideoContentTask(videoContentNode)
|
||||||
@@ -94,7 +106,7 @@ function StartVideoContentTask(videoContentNode as object)
|
|||||||
|
|
||||||
m.loadingLabel.text = Tr(Locale.VideoPlayer.Loading)
|
m.loadingLabel.text = Tr(Locale.VideoPlayer.Loading)
|
||||||
m.loadingPercentLabel.text = ""
|
m.loadingPercentLabel.text = ""
|
||||||
m.loadingSpinner.visible = true
|
m.loadingUi.visible = true
|
||||||
m.loadingSpinner.control = "start"
|
m.loadingSpinner.control = "start"
|
||||||
|
|
||||||
m.videoContentTask = AsyncTask.Start(Tasks.VideoContentTaskDev, {
|
m.videoContentTask = AsyncTask.Start(Tasks.VideoContentTaskDev, {
|
||||||
@@ -102,6 +114,7 @@ function StartVideoContentTask(videoContentNode as object)
|
|||||||
secondaryTitleLabel: m.secondaryTitleLabel
|
secondaryTitleLabel: m.secondaryTitleLabel
|
||||||
content: videoContentNode
|
content: videoContentNode
|
||||||
invidious: m.top.invidious
|
invidious: m.top.invidious
|
||||||
|
backgroundPoster: m.backgroundPoster
|
||||||
}, OnVideoContentTaskResults)
|
}, OnVideoContentTaskResults)
|
||||||
end function
|
end function
|
||||||
|
|
||||||
@@ -202,7 +215,7 @@ function OnPlayerStateChange() as void
|
|||||||
state = m.top.state
|
state = m.top.state
|
||||||
|
|
||||||
if state = "stopping" or state = "stopped"
|
if state = "stopping" or state = "stopped"
|
||||||
m.videoUi.Visible = false
|
m.videoUi.visible = false
|
||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
|
|
||||||
@@ -221,10 +234,14 @@ function OnPlayerStateChange() as void
|
|||||||
if state = "buffering"
|
if state = "buffering"
|
||||||
m.loadingLabel.text = Tr(Locale.VideoPlayer.Buffering)
|
m.loadingLabel.text = Tr(Locale.VideoPlayer.Buffering)
|
||||||
m.loadingSpinner.control = "start"
|
m.loadingSpinner.control = "start"
|
||||||
m.loadingSpinner.visible = true
|
m.loadingUi.visible = true
|
||||||
|
m.backgroundPoster.visible = true
|
||||||
|
m.backgroundPosterSmall.visible = true
|
||||||
else
|
else
|
||||||
m.loadingSpinner.control = "stop"
|
m.loadingSpinner.control = "stop"
|
||||||
m.loadingSpinner.visible = false
|
m.loadingUi.visible = false
|
||||||
|
m.backgroundPoster.visible = false
|
||||||
|
m.backgroundPosterSmall.visible = false
|
||||||
end if
|
end if
|
||||||
end function
|
end function
|
||||||
|
|
||||||
@@ -261,7 +278,9 @@ function OnDispose()
|
|||||||
end function
|
end function
|
||||||
|
|
||||||
function SetupLoadingSpinner()
|
function SetupLoadingSpinner()
|
||||||
m.loadingSpinner = m.top.findNode("LoadingSpinner")
|
m.loadingUi = m.top.findNode("LoadingUI")
|
||||||
|
m.loadingSpinnerBackground = m.loadingUi.findNode("LoadingSpinnerBackground")
|
||||||
|
m.loadingSpinner = m.loadingUi.findNode("LoadingSpinner")
|
||||||
poster = m.loadingSpinner.poster
|
poster = m.loadingSpinner.poster
|
||||||
|
|
||||||
size = 150
|
size = 150
|
||||||
@@ -273,6 +292,11 @@ function SetupLoadingSpinner()
|
|||||||
poster.opacity = 0.8
|
poster.opacity = 0.8
|
||||||
poster.uri = "pkg:/images/spinner.png"
|
poster.uri = "pkg:/images/spinner.png"
|
||||||
|
|
||||||
|
size = 80
|
||||||
|
centerx = (1280 - size) / 2
|
||||||
|
centery = (720 - size) / 2
|
||||||
|
m.loadingSpinnerBackground.translation = [centerx, centery]
|
||||||
|
|
||||||
m.loadingLabel = m.loadingSpinner.findNode("LoadingLabel")
|
m.loadingLabel = m.loadingSpinner.findNode("LoadingLabel")
|
||||||
m.loadingPercentLabel = m.loadingSpinner.findNode("LoadingPercentLabel")
|
m.loadingPercentLabel = m.loadingSpinner.findNode("LoadingPercentLabel")
|
||||||
end function
|
end function
|
||||||
|
|||||||
@@ -26,7 +26,16 @@
|
|||||||
translation="[1280,0]" />
|
translation="[1280,0]" />
|
||||||
|
|
||||||
<Group id="VideoUI">
|
<Group id="VideoUI">
|
||||||
|
<Poster
|
||||||
|
id="BackgroundPosterSmall"
|
||||||
|
width="1280"
|
||||||
|
height="720"
|
||||||
|
blendColor="0x323232" />
|
||||||
|
<Poster
|
||||||
|
id="BackgroundPoster"
|
||||||
|
width="1280"
|
||||||
|
height="720"
|
||||||
|
blendColor="0x323232" />
|
||||||
<Group id="TopUI">
|
<Group id="TopUI">
|
||||||
<Poster
|
<Poster
|
||||||
uri="pkg:/images/black-gradient.png"
|
uri="pkg:/images/black-gradient.png"
|
||||||
@@ -86,11 +95,19 @@
|
|||||||
iconUri="pkg:/images/icons/player/minimize.png" />
|
iconUri="pkg:/images/icons/player/minimize.png" />
|
||||||
</LayoutGroup>
|
</LayoutGroup>
|
||||||
</Group>
|
</Group>
|
||||||
<Group>
|
<Group
|
||||||
|
id="LoadingUI"
|
||||||
|
visible="false">
|
||||||
|
<Poster
|
||||||
|
id="LoadingSpinnerBackground"
|
||||||
|
width="80"
|
||||||
|
height="80"
|
||||||
|
uri="pkg:/images/white-circle.png"
|
||||||
|
opacity="0.4"
|
||||||
|
blendColor="0x000000" />
|
||||||
<BusySpinner
|
<BusySpinner
|
||||||
id="LoadingSpinner"
|
id="LoadingSpinner"
|
||||||
spinInterval="1"
|
spinInterval="1">
|
||||||
visible="false">
|
|
||||||
<Label
|
<Label
|
||||||
id="LoadingPercentLabel"
|
id="LoadingPercentLabel"
|
||||||
horizAlign="center"
|
horizAlign="center"
|
||||||
|
|||||||
Reference in new issue
Block a user