Support playing a video from a specific time (cast from phone, drag a… (#88)
* Support playing a video from a specific time (cast from phone, drag and drop, open in Invidious) * Remove a console log
This commit is contained in:
1 parent
6c84630cec
commit
3acf733eec
14 files changed
+220
-45
No files matched your search
@@ -113,8 +113,11 @@ function OnWebServerLogin()
|
||||
m.homeGridScreen.refresh = true
|
||||
end function
|
||||
|
||||
function OnWebServerCommand()
|
||||
if m.serverTask.command.StartsWith("play:")
|
||||
function OnWebServerCommand() as void
|
||||
if m.serverTask.command = invalid or m.serverTask.command.command = invalid
|
||||
return
|
||||
end if
|
||||
if m.serverTask.command.command = "play"
|
||||
sender = m.videoContainer.sender ?? m.currentFocued
|
||||
if m.videoContainer.fullscreen
|
||||
dialog = m.top.getScene().dialog
|
||||
@@ -122,7 +125,7 @@ function OnWebServerCommand()
|
||||
dialog.close = true
|
||||
end if
|
||||
end if
|
||||
PlayVideo(m.serverTask.command.Mid(5), { sender: sender })
|
||||
PlayVideo(m.serverTask.command.videoId, { sender: sender, timestamp: m.serverTask.command.timestamp })
|
||||
end if
|
||||
end function
|
||||
|
||||
@@ -146,5 +149,5 @@ function PlayVideoFromArgs(args as object) as void
|
||||
end if
|
||||
|
||||
sender = m.videoContainer.sender ?? m.currentFocued
|
||||
PlayVideo(args.contentId, { sender: sender })
|
||||
PlayVideo(args.contentId, { sender: sender, timestamp: args.timestamp })
|
||||
end function
|
||||
@@ -7,11 +7,16 @@ import "pkg:/components/VideoPlayer/MarkVideoWatchedTask.bs"
|
||||
function PlayVideo(videoId as string, args = invalid as object)
|
||||
sender = args?.sender
|
||||
metadata = args?.metadata
|
||||
timestamp = args?.timestamp
|
||||
|
||||
if metadata <> invalid and GetInterface(metadata, "ifSGNodeField") <> invalid
|
||||
metadata = args.metadata.getFields()
|
||||
end if
|
||||
|
||||
if timestamp = invalid
|
||||
timestamp = 0
|
||||
end if
|
||||
|
||||
width = 1280
|
||||
height = 720
|
||||
translation = [0.0, 0.0]
|
||||
@@ -29,6 +34,7 @@ function PlayVideo(videoId as string, args = invalid as object)
|
||||
videoContainer.insertChild(videoContainer.videoPlayer, 0)
|
||||
videoContainer.videoPlayer.id = "VideoPlayer"
|
||||
videoContainer.videoPlayer.metadata = metadata
|
||||
videoContainer.videoPlayer.timestamp = timestamp
|
||||
videoContainer.videoPlayer.videoId = videoId
|
||||
videoContainer.videoPlayer.width = width
|
||||
videoContainer.videoPlayer.height = height
|
||||
|
||||
@@ -286,8 +286,11 @@ function OnVideoPlayerStateChange() as void
|
||||
|
||||
' If we successfully played the video, then any error that comes later is not due to a 403 (FORBIDDEN).
|
||||
' This is to reduce false positives, as we do not want retry another link if the first link is working fine.
|
||||
if state = "playing"
|
||||
if state = "playing" and not m.videoPlayingSuccess
|
||||
m.videoPlayingSuccess = true
|
||||
if m.top.timestamp <> 0
|
||||
m.top.seek = m.top.timestamp
|
||||
end if
|
||||
end if
|
||||
|
||||
if state = "error"
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
<field id="chapter" type="string" alias="chapterLabel.text" />
|
||||
<field id="videoId" type="string" />
|
||||
<field id="metadata" type="assocarray" />
|
||||
<field id="timestamp" type="integer" />
|
||||
</interface>
|
||||
<children>
|
||||
<Label
|
||||
|
||||
@@ -23,8 +23,7 @@ namespace Http
|
||||
response.Default(204, "OK")
|
||||
return true
|
||||
else if payload.command = "play"
|
||||
videoId = payload.videoId
|
||||
server.task.top.command = `play:${videoId}`
|
||||
server.task.top.command = payload
|
||||
response.Default(204, "OK")
|
||||
return true
|
||||
else if payload.command = "set-playlet-lib-urls"
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
<component name="WebServerTask" extends="Task">
|
||||
<interface>
|
||||
<field id="login" type="boolean" alwaysNotify="true" />
|
||||
<field id="command" type="string" alwaysNotify="true" />
|
||||
<field id="command" type="assocarray" alwaysNotify="true" />
|
||||
</interface>
|
||||
</component>
|
||||
Reference in new issue
Block a user