play next video on fail
This commit is contained in:
1 parent
bb0a0725d6
commit
c334736325
6 files changed
+160
-7
No files matched your search
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- When a video error dialog shows, a timer with 10 seconds starts to play the next video
|
||||||
|
|
||||||
## [0.20.2] - 2024-02-26
|
## [0.20.2] - 2024-02-26
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -22,4 +22,31 @@ namespace DialogUtils
|
|||||||
m.top.getScene().dialog = dialog
|
m.top.getScene().dialog = dialog
|
||||||
return dialog
|
return dialog
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
function ShowTimedDialogButtons(message as dynamic, title as string, buttons as object, defaultButton as integer, timeoutSeconds as integer, large = false as boolean) as object
|
||||||
|
dialog = CreateObject("roSGNode", "TimedDialog")
|
||||||
|
if GetInterface(message, "ifArray") = invalid
|
||||||
|
message = message.Tokenize(`\n`).ToArray()
|
||||||
|
end if
|
||||||
|
dialog.message = message
|
||||||
|
dialog.title = title
|
||||||
|
dialog.actualButtons = buttons
|
||||||
|
|
||||||
|
if large
|
||||||
|
if m._deviceDisplayWidth = invalid
|
||||||
|
deviceInfo = CreateObject("roDeviceInfo")
|
||||||
|
displaySize = deviceInfo.GetDisplaySize()
|
||||||
|
m._deviceDisplayWidth = displaySize.w
|
||||||
|
end if
|
||||||
|
dialog.width = m._deviceDisplayWidth - 100
|
||||||
|
end if
|
||||||
|
|
||||||
|
dialog.defaultButtonIndex = defaultButton
|
||||||
|
dialog.defaultActionTimeoutSeconds = timeoutSeconds
|
||||||
|
dialog.startCountdown = true
|
||||||
|
|
||||||
|
m.top.getScene().dialog = dialog
|
||||||
|
|
||||||
|
return dialog
|
||||||
|
end function
|
||||||
end namespace
|
end namespace
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
import "DialogPalette.bs"
|
||||||
|
import "pkg:/source/utils/Types.bs"
|
||||||
|
import "pkg:/source/utils/Logging.bs"
|
||||||
|
|
||||||
|
function Init()
|
||||||
|
SetPalette(m.top)
|
||||||
|
m.top.observeField("buttonSelected", FuncName(OnButtonSelected))
|
||||||
|
m.top.observeField("wasClosed", FuncName(OnDialogClosed))
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnStartCountdown()
|
||||||
|
actualButtons = m.top.actualButtons
|
||||||
|
defaultButtonIndex = m.top.defaultButtonIndex
|
||||||
|
defaultActionTimeoutSeconds = m.top.defaultActionTimeoutSeconds
|
||||||
|
|
||||||
|
buttons = []
|
||||||
|
for i = 0 to actualButtons.Count() - 1
|
||||||
|
if i = defaultButtonIndex
|
||||||
|
buttons.push(`${actualButtons[i]} (${defaultActionTimeoutSeconds})`)
|
||||||
|
else
|
||||||
|
buttons.push(actualButtons[i])
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
m.top.buttons = buttons
|
||||||
|
|
||||||
|
CancelTimer()
|
||||||
|
m.timer = CreateObject("roSGNode", "Timer")
|
||||||
|
m.timer.repeat = true
|
||||||
|
m.timer.observeFieldScoped("fire", FuncName(TimerUpdateButtons))
|
||||||
|
m.currentCountDown = defaultActionTimeoutSeconds
|
||||||
|
m.timer.control = "start"
|
||||||
|
end function
|
||||||
|
|
||||||
|
function TimerUpdateButtons() as void
|
||||||
|
m.currentCountDown -= 1
|
||||||
|
if m.currentCountDown <= 0
|
||||||
|
m.top.actualButtonSelected = m.top.defaultButtonIndex
|
||||||
|
m.top.close = true
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
FindButtonComponents()
|
||||||
|
if m.buttonComponents = invalid
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
defaultButtonIndex = m.top.defaultButtonIndex
|
||||||
|
m.buttonComponents[defaultButtonIndex].text = `${m.top.actualButtons[defaultButtonIndex]} (${m.currentCountDown})`
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnButtonSelected()
|
||||||
|
m.top.actualButtonSelected = m.top.buttonSelected
|
||||||
|
m.top.close = true
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnDialogClosed()
|
||||||
|
CancelTimer()
|
||||||
|
end function
|
||||||
|
|
||||||
|
function onKeyEvent(key as string, press as boolean) as boolean
|
||||||
|
if m.timer = invalid
|
||||||
|
return false
|
||||||
|
end if
|
||||||
|
|
||||||
|
CancelTimer()
|
||||||
|
|
||||||
|
FindButtonComponents()
|
||||||
|
if m.buttonComponents = invalid
|
||||||
|
return false
|
||||||
|
end if
|
||||||
|
|
||||||
|
defaultButtonIndex = m.top.defaultButtonIndex
|
||||||
|
m.buttonComponents[defaultButtonIndex].text = m.top.actualButtons[defaultButtonIndex]
|
||||||
|
return false
|
||||||
|
end function
|
||||||
|
|
||||||
|
function CancelTimer()
|
||||||
|
if m.timer <> invalid
|
||||||
|
m.timer.control = "stop"
|
||||||
|
m.timer.unobserveFieldScoped("fire")
|
||||||
|
m.timer = invalid
|
||||||
|
end if
|
||||||
|
end function
|
||||||
|
|
||||||
|
function FindButtonComponents() as void
|
||||||
|
if m.buttonComponents <> invalid
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
areas = m.top.getChildren(-1, 0)
|
||||||
|
for each area in areas
|
||||||
|
if area.subtype() = "StdDlgButtonArea"
|
||||||
|
m.buttonComponents = area.getChildren(-1, 0)
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
LogWarn("No buttons found in dialog")
|
||||||
|
end function
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<component name="TimedDialog" extends="StandardMessageDialog">
|
||||||
|
<interface>
|
||||||
|
<field id="actualButtons" type="stringarray" />
|
||||||
|
<field id="defaultButtonIndex" type="integer" value="-1" />
|
||||||
|
<field id="defaultActionTimeoutSeconds" type="integer" value="10" />
|
||||||
|
<!-- Use actualButtonSelected because buttonSelected is read only and defaults to 0 -->
|
||||||
|
<field id="actualButtonSelected" type="integer" value="-1" />
|
||||||
|
<field id="startCountdown" type="boolean" alwaysNotify="true" onChange="OnStartCountdown" />
|
||||||
|
</interface>
|
||||||
|
</component>
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
import "pkg:/components/ChannelView/ChannelUtils.bs"
|
import "pkg:/components/ChannelView/ChannelUtils.bs"
|
||||||
import "pkg:/components/ContextMenu/ContextMenuUtils.bs"
|
import "pkg:/components/ContextMenu/ContextMenuUtils.bs"
|
||||||
import "pkg:/components/Dialog/DialogUtils.bs"
|
|
||||||
import "pkg:/components/Navigation/LongPress.bs"
|
import "pkg:/components/Navigation/LongPress.bs"
|
||||||
import "pkg:/components/Services/Invidious/InvidiousToContentNode.bs"
|
import "pkg:/components/Services/Invidious/InvidiousToContentNode.bs"
|
||||||
import "pkg:/components/VideoFeed/FeedLoadState.bs"
|
import "pkg:/components/VideoFeed/FeedLoadState.bs"
|
||||||
|
|||||||
@@ -124,9 +124,10 @@ function OnVideoContentTaskResults(output as object) as void
|
|||||||
LogError(error)
|
LogError(error)
|
||||||
videoId = output.task.input.content.videoId
|
videoId = output.task.input.content.videoId
|
||||||
message = `Failed to load video information for ${videoId}\n${error}`
|
message = `Failed to load video information for ${videoId}\n${error}`
|
||||||
DialogUtils.ShowDialog(message, "Video load fail", true)
|
|
||||||
' TODO:P1 play next video in the queue after showing the error dialog
|
dialog = DialogUtils.ShowTimedDialogButtons(message, "Video load fail", ["Play next video", "Cancel"], 0, 10, true)
|
||||||
m.videoQueue.closePlayer = true
|
dialog.observeFieldScoped("wasClosed", FuncName(OnVideoContentTaskErrorDialogResponse))
|
||||||
|
|
||||||
Lounge.SendOnStateChange()
|
Lounge.SendOnStateChange()
|
||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
@@ -139,6 +140,18 @@ function OnVideoContentTaskResults(output as object) as void
|
|||||||
end if
|
end if
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
function OnVideoContentTaskErrorDialogResponse(event as object)
|
||||||
|
dialog = event.getRoSGNode()
|
||||||
|
dialog.unobserveFieldScoped("wasClosed")
|
||||||
|
shouldPlayNext = dialog.actualButtonSelected = 0
|
||||||
|
|
||||||
|
if not shouldPlayNext or not VideoQueueUtils.PlayNext(m.videoQueue, m.invidious, m.preferences)
|
||||||
|
m.videoQueue.closePlayer = true
|
||||||
|
end if
|
||||||
|
|
||||||
|
Lounge.SendOnStateChange()
|
||||||
|
end function
|
||||||
|
|
||||||
function MarkVideoWatched(videoId as string)
|
function MarkVideoWatched(videoId as string)
|
||||||
if m.top.invidious.authToken <> invalid
|
if m.top.invidious.authToken <> invalid
|
||||||
AsyncTask.Start(Tasks.MarkVideoWatchedTask, {
|
AsyncTask.Start(Tasks.MarkVideoWatchedTask, {
|
||||||
@@ -247,9 +260,9 @@ function OnVideoPlayerStateChange() as void
|
|||||||
|
|
||||||
title = `Error playing video ${content.videoId}`
|
title = `Error playing video ${content.videoId}`
|
||||||
LogError(title, messageLines)
|
LogError(title, messageLines)
|
||||||
DialogUtils.ShowDialog(messageLines, title, true)
|
|
||||||
' TODO:P1 play next video in the queue after showing the error dialog
|
dialog = DialogUtils.ShowTimedDialogButtons(messageLines, title, ["Play next video", "Cancel"], 0, 10, true)
|
||||||
m.videoQueue.closePlayer = true
|
dialog.observeFieldScoped("wasClosed", FuncName(OnVideoContentTaskErrorDialogResponse))
|
||||||
end if
|
end if
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user