Pass metadata to player

This commit is contained in:
Brahim Hadriche committed 2023-01-03 18:19:29 -05:00
1 parent bad84da75a
commit 29651fee1f
7 files changed
+42 -8

No files matched your search

+2
View File
@@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- WebSocket server for realtime events - WebSocket server for realtime events
- SponsorBlock tracking - SponsorBlock tracking
- Auto-generated tasks and the @asynctask annotation - Auto-generated tasks and the @asynctask annotation
- Show known video metadata while loading video details
- Caching for video details
### Changed ### Changed
- The License has changed from MIT to AGPL - The License has changed from MIT to AGPL
@@ -110,7 +110,10 @@ function OnHomeGridScreenVideoSelected(event as object) as void
videoId = itemContent.videoId videoId = itemContent.videoId
PlayVideo(videoId, m.top) PlayVideo(videoId, {
metadata: itemContent,
sender: m.top
})
end function end function
function OnkeyEvent(key as string, press as boolean) as boolean function OnkeyEvent(key as string, press as boolean) as boolean
+3 -3
View File
@@ -93,7 +93,7 @@ end function
function OnWebServerCommand() function OnWebServerCommand()
if m.serverTask.command.StartsWith("play:") if m.serverTask.command.StartsWith("play:")
sender = m.videoContainer.sender ?? m.currentFocued sender = m.videoContainer.sender ?? m.currentFocued
PlayVideo(m.serverTask.command.Mid(5), sender) PlayVideo(m.serverTask.command.Mid(5), {sender: sender})
end if end if
end function end function
@@ -112,7 +112,7 @@ function LaunchArgumentsReceived()
? "LaunchArgumentsReceived" m.top.launchArgs ? "LaunchArgumentsReceived" m.top.launchArgs
if m.top.launchArgs <> invalid and m.top.launchArgs.contentId <> invalid if m.top.launchArgs <> invalid and m.top.launchArgs.contentId <> invalid
sender = m.videoContainer.sender ?? m.currentFocued sender = m.videoContainer.sender ?? m.currentFocued
PlayVideo(m.top.launchArgs.contentId, sender) PlayVideo(m.top.launchArgs.contentId, {sender: sender})
end if end if
end function end function
@@ -120,6 +120,6 @@ function InputArgumentsReceived()
? "InputArgumentsReceived" m.top.inputArgs ? "InputArgumentsReceived" m.top.inputArgs
if m.top.inputArgs <> invalid and m.top.inputArgs.contentId <> invalid if m.top.inputArgs <> invalid and m.top.inputArgs.contentId <> invalid
sender = m.videoContainer.sender ?? m.currentFocued sender = m.videoContainer.sender ?? m.currentFocued
PlayVideo(m.top.inputArgs.contentId, sender) PlayVideo(m.top.inputArgs.contentId, {sender: sender})
end if end if
end function end function
+4 -1
View File
@@ -172,7 +172,10 @@ function OnSearchVideoSelected(event as object)
itemContent = rowContent.GetChild(selectedRowItem) itemContent = rowContent.GetChild(selectedRowItem)
videoId = itemContent.videoId videoId = itemContent.videoId
PlayVideo(videoId, m.top) PlayVideo(videoId, {
metadata: itemContent,
sender: m.top
})
end function end function
function OnkeyEvent(key as string, press as boolean) as boolean function OnkeyEvent(key as string, press as boolean) as boolean
+9 -1
View File
@@ -1,7 +1,14 @@
import "pkg:/source/services/Invidious.bs" import "pkg:/source/services/Invidious.bs"
import "pkg:/components/Dialog/DialogUtils.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 width = 1280
height = 720 height = 720
translation = [0.0, 0.0] translation = [0.0, 0.0]
@@ -17,6 +24,7 @@ function PlayVideo(videoId as string, sender as object)
end if end if
videoContainer.videoPlayer = videoContainer.createChild("VideoPlayer") videoContainer.videoPlayer = videoContainer.createChild("VideoPlayer")
videoContainer.videoPlayer.id = "VideoPlayer" videoContainer.videoPlayer.id = "VideoPlayer"
videoContainer.videoPlayer.metadata = metadata
videoContainer.videoPlayer.videoId = videoId videoContainer.videoPlayer.videoId = videoId
videoContainer.videoPlayer.width = width videoContainer.videoPlayer.width = width
videoContainer.videoPlayer.height = height videoContainer.videoPlayer.height = height
+19 -2
View File
@@ -55,11 +55,27 @@ function OnControlChange()
end if end if
end function 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() function StartVideoDetailsTask()
if m.videoDetailsTask <> invalid if m.videoDetailsTask <> invalid
m.videoDetailsTask.control = "stop" m.videoDetailsTask.control = "stop"
end if end if
SetMetadata()
m.videoDetailsTask = StartAsyncTask(VideoDetailsTask, { videoId: m.top.videoId }, OnVideoDetailsTaskResults) m.videoDetailsTask = StartAsyncTask(VideoDetailsTask, { videoId: m.top.videoId }, OnVideoDetailsTaskResults)
end function end function
@@ -253,9 +269,10 @@ function OnVideoPlayerStateChange() as void
if state = "finished" if state = "finished"
metadata = m.top.content?.metadata metadata = m.top.content?.metadata
videoId = metadata?.recommendedVideos?.GetEntry(0)?.videoId metadata = metadata?.recommendedVideos?.GetEntry(0)
videoId = metadata?.videoId
if videoId <> invalid if videoId <> invalid
PlayVideo(videoId, invalid) PlayVideo(videoId, { metadata: metadata })
else else
CloseVideo() CloseVideo()
end if end if
@@ -6,6 +6,7 @@
<interface> <interface>
<field id="chapter" type="string" alias="chapterLabel.text" /> <field id="chapter" type="string" alias="chapterLabel.text" />
<field id="videoId" type="string" /> <field id="videoId" type="string" />
<field id="metadata" type="assocarray" />
</interface> </interface>
<children> <children>
<Label <Label