Bug fix for when video is restarted, remove embedded video dead code
This commit is contained in:
1 parent
b1efa457a2
commit
1b121d9ace
3 files changed
+10
-92
No files matched your search
@@ -46,8 +46,6 @@ function StartFetchTask() as void
|
|||||||
if m.sortedContent.Count() = m.defaultLayout.Count()
|
if m.sortedContent.Count() = m.defaultLayout.Count()
|
||||||
' All tasks are done
|
' All tasks are done
|
||||||
m.Delete("sortedContent")
|
m.Delete("sortedContent")
|
||||||
' TODO: uncommment if auto-play
|
|
||||||
' m.top.ObserveField("rowItemFocused", "OnHomeGridScreenVideoFocused")
|
|
||||||
end if
|
end if
|
||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
@@ -108,19 +106,8 @@ function OnHomeGridScreenVideoSelected(event as object) as void
|
|||||||
|
|
||||||
videoId = itemContent.videoId
|
videoId = itemContent.videoId
|
||||||
|
|
||||||
if m.videoPlayer <> invalid
|
CloseVideo()
|
||||||
if m.videoPlayer.videoId = videoId
|
ShowVideoScreen(videoId, m.top)
|
||||||
ExpandVideoScreenFull()
|
|
||||||
return
|
|
||||||
else
|
|
||||||
m.videoPlayer.control = "stop"
|
|
||||||
m.videoPlayer.visible = false
|
|
||||||
m.videoPlayer.getParent().removeChild(m.videoPlayer)
|
|
||||||
m.videoPlayer = invalid
|
|
||||||
end if
|
|
||||||
end if
|
|
||||||
|
|
||||||
ShowVideoScreenFull(videoId, m.top)
|
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function CloseVideo()
|
function CloseVideo()
|
||||||
@@ -135,39 +122,7 @@ end function
|
|||||||
function OnPlayVideoCommand()
|
function OnPlayVideoCommand()
|
||||||
videoId = m.top.playvideo
|
videoId = m.top.playvideo
|
||||||
CloseVideo()
|
CloseVideo()
|
||||||
ShowVideoScreenFull(videoId, m.top)
|
ShowVideoScreen(videoId, m.top)
|
||||||
end function
|
|
||||||
|
|
||||||
function OnHomeGridScreenVideoFocused(event as object) as void
|
|
||||||
if m.videoPlayer <> invalid
|
|
||||||
m.videoPlayer.control = "stop"
|
|
||||||
m.videoPlayer.visible = false
|
|
||||||
m.videoPlayer.getParent().removeChild(m.videoPlayer)
|
|
||||||
m.videoPlayer = invalid
|
|
||||||
end if
|
|
||||||
grid = event.GetRoSGNode()
|
|
||||||
|
|
||||||
selectedPair = event.GetData()
|
|
||||||
selectedRow = selectedPair[0]
|
|
||||||
selectedRowItem = selectedPair[1]
|
|
||||||
|
|
||||||
rowContent = grid.content.GetChild(selectedRow)
|
|
||||||
itemContent = rowContent.GetChild(selectedRowItem)
|
|
||||||
|
|
||||||
videoId = itemContent.videoId
|
|
||||||
thumbnail = GetThumbnailPoster(videoId)
|
|
||||||
ShowVideoScreenEmbedded(videoId, thumbnail)
|
|
||||||
end function
|
|
||||||
|
|
||||||
function GetThumbnailPoster(videoId as string) as object
|
|
||||||
' TODO: make this faster
|
|
||||||
all = m.top.getAll()
|
|
||||||
for each item in all
|
|
||||||
if item.id = `thumbnail-${videoId}`
|
|
||||||
return item
|
|
||||||
end if
|
|
||||||
end for
|
|
||||||
return invalid
|
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function OnkeyEvent(key as string, press as boolean) as boolean
|
function OnkeyEvent(key as string, press as boolean) as boolean
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ function OnSearchVideoSelected(event as object)
|
|||||||
itemContent = rowContent.GetChild(selectedRowItem)
|
itemContent = rowContent.GetChild(selectedRowItem)
|
||||||
|
|
||||||
videoId = itemContent.videoId
|
videoId = itemContent.videoId
|
||||||
ShowVideoScreenFull(videoId, m.top)
|
ShowVideoScreen(videoId, 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
|
||||||
|
|||||||
@@ -1,66 +1,28 @@
|
|||||||
import "pkg:/source/services/Invidious.bs"
|
import "pkg:/source/services/Invidious.bs"
|
||||||
|
|
||||||
function ShowVideoScreenEmbedded(videoId as string, thumbnailNode as object)
|
function ShowVideoScreen(videoId as string, sender as object)
|
||||||
m.videoPlayer = CreateObject("roSGNode", "VideoPlayer")
|
|
||||||
AddVideoFields()
|
|
||||||
m.videoPlayer.embedded = true
|
|
||||||
|
|
||||||
m.videoPlayer.enableUI = false
|
|
||||||
m.videoPlayer.width = thumbnailNode.width
|
|
||||||
m.videoPlayer.height = thumbnailNode.height
|
|
||||||
thumbnailNode.AppendChild(m.videoPlayer)
|
|
||||||
ShowVideoScreen(videoId)
|
|
||||||
end function
|
|
||||||
|
|
||||||
function ShowVideoScreenFull(videoId as string, sender as object)
|
|
||||||
m.videoPlayer = CreateObject("roSGNode", "VideoPlayer")
|
m.videoPlayer = CreateObject("roSGNode", "VideoPlayer")
|
||||||
m.videoPlayer.sender = sender
|
m.videoPlayer.sender = sender
|
||||||
AddVideoFields()
|
|
||||||
m.videoPlayer.embedded = false
|
|
||||||
|
|
||||||
' TODO: make sure video is at right node
|
|
||||||
m.top.getParent().AppendChild(m.videoPlayer)
|
|
||||||
ShowVideoScreen(videoId)
|
|
||||||
end function
|
|
||||||
|
|
||||||
function AddVideoFields()
|
|
||||||
m.videoPlayer.addFields({
|
m.videoPlayer.addFields({
|
||||||
embedded: false,
|
|
||||||
sponsorBlockTask: false,
|
sponsorBlockTask: false,
|
||||||
videoPlayingSuccess: false,
|
videoPlayingSuccess: false,
|
||||||
ignoreNextFinishedState: false
|
ignoreNextFinishedState: false,
|
||||||
|
videoId: videoId
|
||||||
})
|
})
|
||||||
end function
|
|
||||||
|
|
||||||
function ExpandVideoScreenFull()
|
m.videoPlayer.getScene().AppendChild(m.videoPlayer)
|
||||||
m.videoPlayer.embedded = true
|
|
||||||
m.videoPlayer.reparent(m.top, false)
|
|
||||||
m.videoPlayer.enableUI = true
|
|
||||||
m.videoPlayer.width = 1280
|
|
||||||
m.videoPlayer.height = 720
|
|
||||||
m.videoPlayer.SetFocus(true)
|
|
||||||
StartSponsorBlockTask(m.videoPlayer.videoId)
|
|
||||||
end function
|
|
||||||
|
|
||||||
function ShowVideoScreen(videoId as string)
|
|
||||||
m.videoPlayer.addFields({ videoId: videoId })
|
|
||||||
m.videoPlayer.trickPlayBar.filledBarBlendColor = "0xFF0000FF"
|
m.videoPlayer.trickPlayBar.filledBarBlendColor = "0xFF0000FF"
|
||||||
m.videoPlayer.bufferingBar.filledBarBlendColor = "0xFF0000FF"
|
m.videoPlayer.bufferingBar.filledBarBlendColor = "0xFF0000FF"
|
||||||
m.videoPlayer.retrievingBar.filledBarBlendColor = "0xFF0000FF"
|
m.videoPlayer.retrievingBar.filledBarBlendColor = "0xFF0000FF"
|
||||||
|
|
||||||
if not m.videoPlayer.embedded
|
|
||||||
m.videoPlayer.visible = true
|
m.videoPlayer.visible = true
|
||||||
m.videoPlayer.SetFocus(true)
|
m.videoPlayer.SetFocus(true)
|
||||||
else
|
|
||||||
m.videoPlayer.visible = false
|
|
||||||
end if
|
|
||||||
|
|
||||||
m.videoPlayer.ObserveField("state", "OnVideoPlayerStateChange")
|
m.videoPlayer.ObserveField("state", "OnVideoPlayerStateChange")
|
||||||
|
|
||||||
StartVideoDetailsTask(videoId)
|
StartVideoDetailsTask(videoId)
|
||||||
if not m.videoPlayer.embedded
|
|
||||||
StartSponsorBlockTask(videoId)
|
StartSponsorBlockTask(videoId)
|
||||||
end if
|
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function OnVideoPlayerStateChange() as void
|
function OnVideoPlayerStateChange() as void
|
||||||
@@ -112,11 +74,12 @@ function OnVideoPlayerStateChange() as void
|
|||||||
end function
|
end function
|
||||||
|
|
||||||
function CloseVideoPlayer()
|
function CloseVideoPlayer()
|
||||||
|
sender = m.videoPlayer.sender
|
||||||
m.videoPlayer.control = "stop"
|
m.videoPlayer.control = "stop"
|
||||||
m.videoPlayer.visible = false
|
m.videoPlayer.visible = false
|
||||||
m.videoPlayer.getParent().RemoveChild(m.videoPlayer)
|
m.videoPlayer.getParent().RemoveChild(m.videoPlayer)
|
||||||
m.videoPlayer = invalid
|
m.videoPlayer = invalid
|
||||||
m.top.focus = true
|
sender.focus = true
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function StartVideoDetailsTask(videoId as string)
|
function StartVideoDetailsTask(videoId as string)
|
||||||
|
|||||||
Reference in new issue
Block a user