Pass metadata to player
This commit is contained in:
1 parent
bad84da75a
commit
29651fee1f
7 files changed
+42
-8
No files matched your search
@@ -110,7 +110,10 @@ function OnHomeGridScreenVideoSelected(event as object) as void
|
||||
|
||||
videoId = itemContent.videoId
|
||||
|
||||
PlayVideo(videoId, m.top)
|
||||
PlayVideo(videoId, {
|
||||
metadata: itemContent,
|
||||
sender: m.top
|
||||
})
|
||||
end function
|
||||
|
||||
function OnkeyEvent(key as string, press as boolean) as boolean
|
||||
|
||||
@@ -93,7 +93,7 @@ end function
|
||||
function OnWebServerCommand()
|
||||
if m.serverTask.command.StartsWith("play:")
|
||||
sender = m.videoContainer.sender ?? m.currentFocued
|
||||
PlayVideo(m.serverTask.command.Mid(5), sender)
|
||||
PlayVideo(m.serverTask.command.Mid(5), {sender: sender})
|
||||
end if
|
||||
end function
|
||||
|
||||
@@ -112,7 +112,7 @@ function LaunchArgumentsReceived()
|
||||
? "LaunchArgumentsReceived" m.top.launchArgs
|
||||
if m.top.launchArgs <> invalid and m.top.launchArgs.contentId <> invalid
|
||||
sender = m.videoContainer.sender ?? m.currentFocued
|
||||
PlayVideo(m.top.launchArgs.contentId, sender)
|
||||
PlayVideo(m.top.launchArgs.contentId, {sender: sender})
|
||||
end if
|
||||
end function
|
||||
|
||||
@@ -120,6 +120,6 @@ function InputArgumentsReceived()
|
||||
? "InputArgumentsReceived" m.top.inputArgs
|
||||
if m.top.inputArgs <> invalid and m.top.inputArgs.contentId <> invalid
|
||||
sender = m.videoContainer.sender ?? m.currentFocued
|
||||
PlayVideo(m.top.inputArgs.contentId, sender)
|
||||
PlayVideo(m.top.inputArgs.contentId, {sender: sender})
|
||||
end if
|
||||
end function
|
||||
@@ -172,7 +172,10 @@ function OnSearchVideoSelected(event as object)
|
||||
itemContent = rowContent.GetChild(selectedRowItem)
|
||||
|
||||
videoId = itemContent.videoId
|
||||
PlayVideo(videoId, m.top)
|
||||
PlayVideo(videoId, {
|
||||
metadata: itemContent,
|
||||
sender: m.top
|
||||
})
|
||||
end function
|
||||
|
||||
function OnkeyEvent(key as string, press as boolean) as boolean
|
||||
|
||||
@@ -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