Pass metadata to player
This commit is contained in:
1 parent
bad84da75a
commit
29651fee1f
7 files changed
+42
-8
No files matched your search
@@ -1,7 +1,14 @@
|
||||
import "pkg:/source/services/Invidious.bs"
|
||||
import "pkg:/components/Dialog/DialogUtils.bs"
|
||||
|
||||
function PlayVideo(videoId as string, sender as object)
|
||||
function PlayVideo(videoId as string, args = invalid as object)
|
||||
sender = args?.sender
|
||||
metadata = args?.metadata
|
||||
|
||||
if metadata <> invalid and GetInterface(metadata, "ifSGNodeField") <> invalid
|
||||
metadata = args.metadata.getFields()
|
||||
end if
|
||||
|
||||
width = 1280
|
||||
height = 720
|
||||
translation = [0.0, 0.0]
|
||||
@@ -17,6 +24,7 @@ function PlayVideo(videoId as string, sender as object)
|
||||
end if
|
||||
videoContainer.videoPlayer = videoContainer.createChild("VideoPlayer")
|
||||
videoContainer.videoPlayer.id = "VideoPlayer"
|
||||
videoContainer.videoPlayer.metadata = metadata
|
||||
videoContainer.videoPlayer.videoId = videoId
|
||||
videoContainer.videoPlayer.width = width
|
||||
videoContainer.videoPlayer.height = height
|
||||
|
||||
@@ -55,11 +55,27 @@ function OnControlChange()
|
||||
end if
|
||||
end function
|
||||
|
||||
function SetMetadata() as void
|
||||
if m.top.metadata = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
metadata = m.top.metadata
|
||||
contentNode = CreateObject("roSGNode", "ContentNode")
|
||||
contentNode.addFields({ metadata: metadata })
|
||||
|
||||
contentNode.title = metadata.title
|
||||
contentNode.secondaryTitle = metadata.author
|
||||
|
||||
m.top.content = contentNode
|
||||
end function
|
||||
|
||||
function StartVideoDetailsTask()
|
||||
if m.videoDetailsTask <> invalid
|
||||
m.videoDetailsTask.control = "stop"
|
||||
end if
|
||||
|
||||
SetMetadata()
|
||||
m.videoDetailsTask = StartAsyncTask(VideoDetailsTask, { videoId: m.top.videoId }, OnVideoDetailsTaskResults)
|
||||
end function
|
||||
|
||||
@@ -253,9 +269,10 @@ function OnVideoPlayerStateChange() as void
|
||||
|
||||
if state = "finished"
|
||||
metadata = m.top.content?.metadata
|
||||
videoId = metadata?.recommendedVideos?.GetEntry(0)?.videoId
|
||||
metadata = metadata?.recommendedVideos?.GetEntry(0)
|
||||
videoId = metadata?.videoId
|
||||
if videoId <> invalid
|
||||
PlayVideo(videoId, invalid)
|
||||
PlayVideo(videoId, { metadata: metadata })
|
||||
else
|
||||
CloseVideo()
|
||||
end if
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<interface>
|
||||
<field id="chapter" type="string" alias="chapterLabel.text" />
|
||||
<field id="videoId" type="string" />
|
||||
<field id="metadata" type="assocarray" />
|
||||
</interface>
|
||||
<children>
|
||||
<Label
|
||||
|
||||
Reference in new issue
Block a user