Compare commits

..
13 Commits
Author SHA1 Message Date
Brahim Hadriche d7e5732fde Release v0.16.0 (#200) 2023-11-13 22:25:12 -05:00
Brahim Hadriche 9f5a605e8f Small cleanup on content nodes 2023-11-13 22:00:25 -05:00
Brahim Hadriche 45da0880ba Focus current item on queue open 2023-11-13 15:22:21 -05:00
Brahim Hadriche 9e47d4d42e Bug fixes 2023-11-13 15:01:31 -05:00
Brahim Hadriche 3312bbc56e Small refactor 2023-11-13 09:10:52 -05:00
Brahim Hadriche e1cda5cc5c tweak 2023-11-13 09:06:41 -05:00
Brahim Hadriche af0ddf68c5 Adjust queue ui 2023-11-12 17:57:28 -05:00
Brahim Hadricheandgithub-action linter 3559a3fff6 Queue UI (#199)
* Refactor long press

* Lint fix

* Queue UI, refactor PlayQueue to use ContentNode

* Add queue notification hint

* Play at index

* Play queue with highlight

* Priority

* Comment

---------

Co-authored-by: github-action linter <githubaction@githubaction.com>
2023-11-12 17:45:00 -05:00
Brahim Hadriche e0709452be Update README.md 2023-11-11 21:55:04 -05:00
Brahim Hadriche 9bbf8dd038 Update README.md 2023-11-11 21:53:54 -05:00
Brahim Hadriche 64d655fca9 Update README.md 2023-11-11 12:11:19 -05:00
Brahim Hadriche ecb738ab1f Small tweak to http retry logging 2023-11-10 18:23:13 -05:00
Brahim Hadriche c14fa7a1d3 [Perf] reduce some rendezvous 2023-11-10 18:14:26 -05:00
46 changed files with 642 additions and 136 deletions

No files matched your search

+11
View File
@@ -5,6 +5,17 @@ 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/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.16.0] - 2023-11-13
### Added
- User interface for the Queue: Press and hold `Options (*)` to show the queue
### Fixed
- Crash when video player has no content
- Execution timeout on cirlce posters
## [0.15.1] - 2023-11-10
### Added
+6 -3
View File
@@ -62,9 +62,12 @@ More under [Screenshots](./docs/screenshots/README.md)
### Customize Invidious instance
1. Open settings in Playlet
1. Scan QR Code with Phone
1. Change the Invidious instance
1. You can also do this from the settings tab
1. Select Invidious -> Instance
1. Set a custom instance, or choose a public one hosted by volunteers (from https://api.invidious.io/)
1. Optionally, Select `Test instance` to make sure it works
1. Hit save
> ℹ️ **Note**: If you are logged in when you change the instance, you will remain logged in to the old instance. In this case, Playlet will use the old instance to retrieve your subscriptions and your playlists, but will use the new instance for everything else. After switching to a new instance, you can log out and log in again to use your profile on the new instance.
## Development
+1 -1
View File
@@ -143,7 +143,7 @@ That's pretty much it.
There are a few reasons we made this separation:
- Playlet relies on [Invidious](https://github.com/iv-org/invidious). Invidious tries to keep up with Youtube making changes to their platform, but sometimes, a breaking change happens that requires Playlet to react quickly. Releasing through the Roku Channel store can take days, or a week. During this time, Playlet would be not functional, and that's not acceptable.
- The ability to roll back: Sometimes an app breaking bug gets released. Allowing users to choose a seperate version is a flexible way to keep things working. Although right now rollbacks are behind a - hidden by default - developer menu, the reasoning still stands.
- The ability to roll back: Sometimes an app breaking bug gets released. Allowing users to choose a seperate version is a flexible way to keep things working. For example, it's possible to choose a different verrsion from the developer settings in the web app.
- It is simply easier to release: Releasing Playlet Lib on Github, and everyone receives the latest version immediately, is very conveninct and less of a hassle, than going through the Roku Channel store.
- I've had instances where I was trying to pass the certfication for Playlet to publish it. One of the criterias is to pass a some automated tests. But the tests were failing because their system could not connect to their Roku test devices (connection keeps timing out). My only option was to keep trying over and over until it worked.
- It might sound that Playlet Lib is just a workaround for the Roku Channel release process. But phrased differently, Roku Channel release process is not good enough of what we need for Playlet.
+1 -1
View File
@@ -2,7 +2,7 @@ openapi: 3.0.0
info:
title: Playlet Web API
version: 0.15.1
version: 0.16.0
description:
Playlet Web API is a RESTful API for controlling the Playlet app on
Roku devices. The API is intended to be used by the Playlet web app, but can
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "playlet",
"version": "0.15.1",
"version": "0.16.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "playlet",
"version": "0.15.1",
"version": "0.16.0",
"hasInstallScript": true,
"devDependencies": {
"@rokucommunity/bslint": "^0.8.12",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "playlet",
"version": "0.15.1",
"version": "0.16.0",
"description": "Unofficial Youtube client for Roku",
"devDependencies": {
"@rokucommunity/bslint": "^0.8.12",
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "playlet-app",
"version": "0.15.1",
"version": "0.16.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "playlet-app",
"version": "0.15.1"
"version": "0.16.0"
}
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "playlet-app",
"version": "0.15.1",
"version": "0.16.0",
"description": "Unofficial Youtube client for Roku",
"scripts": {
"prebuild": "rm -rf build/playlet-app",
+2 -2
View File
@@ -2,8 +2,8 @@ title=Playlet
# Do not update version manually, it is auto updated from package.json
major_version=0
minor_version=15
build_version=00001
minor_version=16
build_version=00000
ui_resolutions=hd
+10 -17
View File
@@ -1,5 +1,5 @@
' Playlet (App to play videos from an Invidious server on Roku TVs)
' Copyright (C) 2022 Brahim Hadriche
' Copyright (C) 2023 Brahim Hadriche
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU Affero General Public License as published by
@@ -28,16 +28,16 @@ function Main(args as object) as void
scene.ObserveField("exitChannel", port)
scene.launchArgs = args
' These vars are needed to pass certification.
' The actual work is done in Playlet Lib
' bs:disable-next-line LINT1005
contentId = args.contentId
' bs:disable-next-line LINT1005
mediaType = args.mediaType
' Do not signal app launch complete here, we're doing it over at Playlet Lib
' This is needed to pass cetification
if false
' These vars are needed to pass certification.
' The actual work is done in Playlet Lib
' bs:disable-next-line LINT1005
contentId = args.contentId
' bs:disable-next-line LINT1005
mediaType = args.mediaType
' Do not signal app launch complete here, we're doing it over at Playlet Lib
' This is needed to pass cetification
scene.signalBeacon("AppLaunchComplete")
end if
@@ -85,10 +85,3 @@ function Main(args as object) as void
end while
end function
function ClearPlayletLibUrlsIfNeeded(launchArgs as object) as void
if launchArgs = invalid or launchArgs.clearPlayletLibUrls = invalid
return
end if
DeleteRegistryKey("playlet_lib_urls", "Playlet")
end function
+7
View File
@@ -20,3 +20,10 @@ function GetPlayletLibUrlsFromRegistry() as object
urls = ParseJson(urlsJson)
return urls
end function
function ClearPlayletLibUrlsIfNeeded(launchArgs as object) as void
if launchArgs = invalid or launchArgs.clearPlayletLibUrls = invalid
return
end if
DeleteRegistryKey("playlet_lib_urls", "Playlet")
end function
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "playlet-lib",
"version": "0.15.1",
"version": "0.16.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "playlet-lib",
"version": "0.15.1"
"version": "0.16.0"
}
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "playlet-lib",
"version": "0.15.1",
"version": "0.16.0",
"description": "Unofficial Youtube client for Roku",
"scripts": {
"prebuild": "rm -rf build/playlet-lib",
@@ -1,4 +1,6 @@
import "pkg:/components/Dialog/DialogUtils.bs"
import "pkg:/components/Navigation/LongPress.bs"
import "pkg:/components/PlayQueue/PlayQueueViewUtils.bs"
import "pkg:/components/VideoPlayer/VideoUtils.bs"
import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/Logging.bs"
@@ -10,6 +12,7 @@ function Init()
end function
function OnNodeReady()
InitializeLongPress(["options"])
NodeSetFocus(m.top.root, true)
end function
@@ -78,15 +81,26 @@ function GetRootScreen(screenName as string) as object
end function
function onKeyEvent(key as string, press as boolean) as boolean
if not press
return false
if LongPressHandler(key, press)
return true
end if
if key = "options"
if key = OPTIONS_LONG_PRESS_KEY and press
LogInfo("Opening PlayQueueView")
PlayQueueViewUtils.Open(m.top.playQueue, m.top)
return true
end if
if key = "options" and not press
if VideoUtils.ToggleVideoPictureInPicture()
return true
end if
end if
if not press
return false
end if
if key = "play"
if VideoUtils.TogglePause()
return true
@@ -2,6 +2,7 @@
<interface>
<field id="root" type="node" />
<field id="stack" type="node" />
<field id="playQueue" type="node" />
<function name="PushScreen" />
<function name="PopScreen" />
<function name="FocusTopScreen" />
@@ -7,17 +7,27 @@ function UpdateMaskSize()
width = m.top.width
height = m.top.height
m.top.maskSize = [width * GetScaleFactor(), height * GetScaleFactor()]
m.top.maskSize = [width * GetUIScaleFactor(), height * GetUIScaleFactor()]
end function
' MaskGroup component do not scale with with UI resolution
function GetScaleFactor() as float
if m.scaleFactor <> invalid
return m.scaleFactor
function GetUIScaleFactor() as float
if m.uiScaleFactor <> invalid
return m.uiScaleFactor
end if
if m.global.uiScaleFactor <> invalid
return m.global.uiScaleFactor
end if
deviceInfo = CreateObject("roDeviceInfo")
uiResolutionWidth = deviceInfo.GetUIResolution().width
' divide by 1280 because we have ui_resolutions=hd in manifest
m.scaleFactor = uiResolutionWidth / 1280
return m.scaleFactor
m.uiScaleFactor = uiResolutionWidth / 1280
if not m.global.hasField("uiScaleFactor")
m.global.addField("uiScaleFactor", "float", false)
end if
m.global.uiScaleFactor = m.uiScaleFactor
return m.uiScaleFactor
end function
@@ -1,23 +1,23 @@
<component name="ChannelContentNode" extends="ContentNode">
<interface>
<function name="LoadChannel" />
<field id="type" type="string" value="channel" />
<field id="loadState" type="string" />
<function name="LoadChannel" />
<!-- index in a feed -->
<field id="feedSourcesIndex" type="integer" value="-1" />
<field id="HDItemWidth" type="float" value="196" />
<!-- NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation -->
<field id="_author" type="string" />
<field id="authorId" type="string" />
<field id="banner" type="string" />
<field id="channelHandle" type="string" />
<field id="description" type="string" />
<field id="subCount" type="integer" />
<field id="subCountText" type="string" />
<field id="tabs" type="array" />
<field id="thumbnail" type="string" />
<field id="videoCount" type="integer" />
<field id="videoCountText" type="string" />
<field id="thumbnail" type="string" />
<field id="banner" type="string" />
<field id="tabs" type="array" />
<field id="HDItemWidth" type="float" value="196" />
</interface>
</component>
@@ -4,9 +4,7 @@
<field id="loadState" type="string" />
<!-- index in a feed -->
<field id="feedSourcesIndex" type="integer" value="-1" />
<!--
TODO:P0 see if the existance of the field "title" has anything to do with it
<!--
For some strange reason, the "author" field can only be set once.
If you try to set it again, it will not be updated, with type mismatch warning:
@@ -24,17 +22,19 @@
Although we use the field "author" in other components, this is the only place where we modify it after
we set it for the first time (because a saved Playlist belongs to the Invidious user at first, but then
we can query it's original owner)
The issue happens on PlaylistContentNode and ChannelContentNode, but not VideoContentNode.
-->
<field id="_author" type="string" />
<field id="authorId" type="string" />
<field id="playlistId" type="string" />
<field id="thumbnail" type="uri" />
<field id="thumbnailBackground" type="uri" />
<field id="updated" type="integer" />
<field id="updatedText" type="string" />
<field id="videoCount" type="integer" value="-1" />
<field id="videoCountText" type="string" />
<field id="viewCount" type="integer" />
<field id="viewCountText" type="string" />
<field id="updated" type="integer" />
<field id="updatedText" type="string" />
</interface>
</component>
@@ -1,14 +1,13 @@
<component name="VideoContentNode" extends="ContentNode">
<interface>
<field id="type" type="string" value="video" />
<field id="author" type="string" />
<field id="authorId" type="string" />
<field id="hlsUrl" type="uri" />
<!-- index in a playlist -->
<field id="index" type="integer" value="-1" />
<!-- index in a feed -->
<field id="feedSourcesIndex" type="integer" value="-1" />
<field id="author" type="string" />
<field id="authorId" type="string" />
<field id="isUpcoming" type="boolean" />
<field id="lengthSeconds" type="integer" />
<field id="lengthText" type="string" />
+4 -1
View File
@@ -2,7 +2,10 @@
<children>
<!-- Logger should remain the first child, to make sure it is initialized first in the scene -->
<Logger id="Logger" />
<AppController id="AppController" root="bind:./AppRoot" stack="bind:./Stack">
<AppController id="AppController"
root="bind:./AppRoot"
stack="bind:./Stack"
playQueue="bind:./PlayQueue">
<Group id="Stack">
<AppRoot id="AppRoot">
<NavBar id="NavBar" focusIndex="1" appController="bind:/AppController">
@@ -7,7 +7,8 @@ function InitializeBindings()
childProps: {
"AppController": {
"root": "./AppRoot",
"stack": "./Stack"
"stack": "./Stack",
"playQueue": "./PlayQueue"
},
"NavBar": {
"appController": "/AppController"
@@ -1,41 +1,79 @@
const LONG_PRESS_KEY = "OK_LONG_PRESS"
const OK_LONG_PRESS_KEY = "OK_LONG_PRESS"
const OPTIONS_LONG_PRESS_KEY = "OPTIONS_LONG_PRESS"
function InitializeLongPress(keys as object, duration = 1.0 as float)
longPressKeyMap = {
"OK": OK_LONG_PRESS_KEY,
"options": OPTIONS_LONG_PRESS_KEY
}
m._longPressKeyMap = {}
for each key in keys
m._longPressKeyMap[key] = longPressKeyMap[key]
end for
#if DEBUG
' This is for testing long press using the VSCode extension.
' Using the keyboard:
' - press K to simulate an "OK" long press on the remote.
' - press O to simulate an "options" long press on the remote.
simulatedLongPressKeyMap = {
"OK": "Lit_k",
"options": "Lit_o"
}
m._simulatedLongPressKeyMap = {}
for each key in keys
m._simulatedLongPressKeyMap[simulatedLongPressKeyMap[key]] = key
end for
#end if
function InitializeLongPressTimer(duration = 1.0 as float)
m._longPressTimer = CreateObject("roSGNode", "Timer")
m._longPressTimer.duration = duration
m._longPressFired = false
m._pressState = {}
m._longPressTimer.ObserveField("fire", FuncName(LongPressTimerFired))
end function
function LongPressHandler(key as string, press as boolean) as boolean
#if DEBUG
if key = "Lit_l"
LogInfo("Simulating long press using key:", key, "press:", press)
if m._simulatedLongPressKeyMap.DoesExist(key)
subtype = m.top.subtype()
simulatedKey = m._simulatedLongPressKeyMap[key]
LogInfo(`[${subtype}] Simulating`, simulatedKey, "long press using key:", key, "press:", press)
longPressKey = m._longPressKeyMap[simulatedKey]
m._longPressFired = true
return OnkeyEvent(LONG_PRESS_KEY, press)
return OnkeyEvent(longPressKey, press)
end if
#end if
if key = "OK" and press
isLongPressKey = m._longPressKeyMap.DoesExist(key)
if not isLongPressKey
return false
end if
if press
m._longPressTimer.control = "stop"
m._longPressTimer.control = "start"
m._longPressFired = false
m._okPressed = true
m._longPressKey = key
m._pressState[key] = true
return true
end if
if key = "OK" and not press
if not press
m._longPressTimer.control = "stop"
if m._longPressFired = true
m._longPressFired = false
m._okPressed = false
m._pressState[key] = false
return true
end if
' This case is for handling a dialog: The dialog will be dismissed with the OK down event,
' and we would trigger the action with the OK up event. The action should only happen if
' we detected both down and up events.
wasOkPressed = m._okPressed
m._okPressed = false
if wasOkPressed <> true
wasPressed = m._pressState[key]
m._pressState[key] = false
if wasPressed <> true
return true
end if
end if
@@ -43,7 +81,11 @@ function LongPressHandler(key as string, press as boolean) as boolean
return false
end function
function LongPressTimerFired()
function LongPressTimerFired() as void
m._longPressFired = true
OnkeyEvent(LONG_PRESS_KEY, true)
if StringUtils.IsNullOrEmpty(m._longPressKey) or not m._longPressKeyMap.DoesExist(m._longPressKey)
return
end if
OnkeyEvent(m._longPressKeyMap[m._longPressKey], true)
end function
@@ -0,0 +1,5 @@
<component name="ContentNodeReference" extends="ContentNode">
<interface>
<field id="refNode" type="node" />
</interface>
</component>
@@ -0,0 +1,41 @@
' NodeByRef: these functions provides the ability to "wrap" a node in
' another node, so it can be passed by reference. This is useful for
' when a node is required to be a child of multiple nodes at once,
' which is not possible.
' Instead, the node is wrapped, passed around, and unwrapped when needed.
import "pkg:/source/utils/StringUtils.bs"
namespace NodeByRef
function Wrap(node as object) as object
if node = invalid
return invalid
end if
if node.refNode <> invalid
return node
end if
ref = CreateObject("roSGNode", "ContentNodeReference")
ref.refNode = node
if not StringUtils.IsNullOrEmpty(node.id)
ref.id = node.id + "-ref"
end if
return ref
end function
function Unwrap(node as object) as object
if node = invalid
return invalid
end if
loopGuard = 0
while node.refNode <> invalid and loopGuard < 10
node = node.refNode
loopGuard += 1
end while
return node
end function
end namespace
@@ -1,3 +1,4 @@
import "pkg:/components/NodeByRef/NodeByRef.bs"
import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/Types.bs"
@@ -14,6 +15,7 @@ end function
function OnContentSet() as void
content = m.top.content
content = NodeByRef.Unwrap(content)
if content = invalid
return
end if
@@ -8,7 +8,7 @@
<children>
<Poster
width="500"
height="126"
height="144"
opacity="0.9"
uri="pkg:/images/white.9.png">
@@ -40,6 +40,12 @@
color="0x262626ff"
wrap="true" />
</LayoutGroup>
<Label
width="480"
font="font:SmallestSystemFont"
color="0x262626ff"
text="Press and hold Options (*) to open the queue"
translation="[10,120]" />
</Poster>
<Animation
id="translationAnimation"
@@ -1,4 +1,5 @@
import "pkg:/components/Dialog/DialogUtils.bs"
import "pkg:/components/NodeByRef/NodeByRef.bs"
import "pkg:/components/PlaylistView/PlaylistContentTask.bs"
import "pkg:/components/PlayQueue/Notifications/PlayQueueNotificationUtils.bs"
import "pkg:/components/VideoFeed/FeedLoadState.bs"
@@ -9,53 +10,74 @@ import "pkg:/source/utils/ErrorUtils.bs"
import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/Types.bs"
' TODO:P1 prevent adding duplicates of the same video/playlist
function Init()
m.pendingLoadTasks = {}
' TODO:P1 prevent adding duplicates of the same video/playlist
m.queue = CreateObject("roArray", 0, true)
m.content = m.top.findNode("Content")
m.top.content = m.content
m.content.addField("index", "integer", false)
m.content.index = m.top.index
end function
function Play(node as object, playlistIndex as integer)
m.top.index += 1
m.top.playlistIndex = playlistIndex
if m.top.index >= m.queue.Count()
m.queue.push(node)
m.top.index = m.queue.Count() - 1
node = WrapWithIndexField(node)
if m.top.index >= m.content.getChildCount()
m.content.appendChild(node)
m.top.index = m.content.getChildCount() - 1
else
ArrayUtils.Insert(m.queue, node, m.top.index)
m.content.insertChild(node, m.top.index)
end if
PlayItemAtCurrentIndex()
end function
function AddToQueue(node as object)
m.queue.push(node)
node = WrapWithIndexField(node)
m.content.appendChild(node)
queueNotifications = m.top.preferences["misc.queue_notifications"]
if queueNotifications
PlayQueue.ShowNotifcation(m.top.notifications, node)
end if
end function
' TODO:P1 better model of the queue (Now playing, etc)
function WrapWithIndexField(node as object) as object
node = NodeByRef.Wrap(node)
if not node.hasField("index")
node.addField("index", "integer", false)
end if
node.index = m.top.index
return node
end function
' TODO:P0 better model of the queue (Now playing, etc)
function GetQueue(unused as dynamic) as object
queueNodes = m.content.getChildren(-1, 0)
items = []
for each item in m.queue
if item.type = "video"
for each node in queueNodes
node = NodeByRef.Unwrap(node)
if node = invalid
continue for
end if
nodeType = node.type
if nodeType = "video"
items.push({
type: item.type,
videoId: item.videoId,
title: item.title,
author: item.author,
thumbnail: item.thumbnail
type: nodeType,
videoId: node.videoId,
title: node.title,
author: node.author,
thumbnail: node.thumbnail
})
else if item.type = "playlist"
else if node.type = "playlist"
items.push({
type: item.type,
playlistId: item.playlistId,
title: item.title,
thumbnail: item.thumbnail,
videoCountText: item.videoCountText
type: nodeType,
playlistId: node.playlistId,
title: node.title,
thumbnail: node.thumbnail,
videoCountText: node.videoCountText
})
end if
end for
@@ -68,21 +90,24 @@ function GetQueue(unused as dynamic) as object
end function
function Clear(unused as dynamic)
m.queue.Clear()
m.content.removeChildrenIndex(m.content.getChildCount(), 0)
m.top.index = -1
m.top.playlistIndex = -1
end function
function PlayNextItem(unused as dynamic) as boolean
if m.queue.Count() = 0
childCount = m.content.getChildCount()
if childCount = 0
return false
end if
if m.top.index <> -1
if m.top.index >= m.queue.Count()
index = m.top.index
if index <> -1
if index >= childCount
return false
end if
node = m.queue[m.top.index]
node = m.content.getChild(index)
node = NodeByRef.Unwrap(node)
if node.type = "playlist"
m.top.playlistIndex += 1
if PlayPlaylistAtCurrentIndex(node)
@@ -93,15 +118,22 @@ function PlayNextItem(unused as dynamic) as boolean
m.top.index += 1
m.top.playlistIndex = -1
if m.top.index >= m.queue.Count()
if m.top.index >= childCount
return false
end if
return PlayItemAtCurrentIndex()
end function
function PlayItemAtIndex(index as integer) as boolean
m.top.index = index
m.top.playlistIndex = -1
return PlayItemAtCurrentIndex()
end function
function PlayItemAtCurrentIndex() as boolean
node = m.queue[m.top.index]
node = m.content.getChild(m.top.index)
node = NodeByRef.Unwrap(node)
if node = invalid
return false
end if
@@ -118,17 +150,18 @@ function PlayItemAtCurrentIndex() as boolean
end function
function PlayPlaylistAtCurrentIndex(playlist as object) as boolean
playlist = NodeByRef.Unwrap(playlist)
if playlist.videoCount < 0
LoadPlaylist(playlist)
return true
end if
index = m.top.playlistIndex
if index < 0 or index >= playlist.videoCount
playlistIndex = m.top.playlistIndex
if playlistIndex < 0 or playlistIndex >= playlist.videoCount
return false
end if
if index < playlist.getChildCount()
child = playlist.getChild(index)
if playlistIndex < playlist.getChildCount()
child = playlist.getChild(playlistIndex)
VideoUtils.PlayVideo(child)
return true
end if
@@ -177,3 +210,12 @@ function OnPlaylistContentTaskResult(output as object) as void
PlayPlaylistAtCurrentIndex(playlist)
end function
function OnIndexChange()
index = m.top.index
m.content.index = index
children = m.top.content.getChildren(-1, 0)
for each child in children
child.index = index
end for
end function
@@ -1,7 +1,7 @@
<component name="PlayQueue" extends="Node">
<interface>
<field id="queue" type="array" />
<field id="index" type="integer" value="-1" />
<field id="content" type="node" />
<field id="index" type="integer" value="-1" onChange="OnIndexChange" />
<field id="playlistIndex" type="integer" value="-1" />
<field id="invidious" type="node" />
<field id="notifications" type="node" />
@@ -11,5 +11,9 @@
<function name="GetQueue" />
<function name="Clear" />
<function name="PlayNextItem" />
<function name="PlayItemAtIndex" />
</interface>
<children>
<ContentNode id="Content" />
</children>
</component>
@@ -0,0 +1,83 @@
import "pkg:/components/Navigation/Navigation.bs"
import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/Types.bs"
function Init()
m.queueList = m.top.findNode("queueList")
m.queueLabel = m.top.findNode("queueLabel")
m.clearButton = m.top.findNode("clearButton")
m.showAnimation = m.top.findNode("showAnimation")
m.clearButton.ObserveField("buttonSelected", FuncName(OnClearButtonSelected))
m.queueList.ObserveField("itemSelected", FuncName(OnItemSelected))
SetNavigation(m.queueList, "up", m.clearButton)
SetNavigation(m.clearButton, "down", m.queueList)
end function
function Show(unsued as dynamic)
m.showAnimation.control = "start"
end function
function OnFocusChange() as void
if not m.top.focus
return
end if
NodeSetFocus(m.queueList, true)
end function
function OnContentSet() as void
content = m.top.content
if content = invalid
return
end if
if not content.isSameNode(m.queueList.content)
m.queueList.content = content
end if
index = content.index
if IsInt(index) and index <> -1
m.queueLabel.text = `Queue (${index + 1}/${content.getChildCount()})`
else
m.queueLabel.text = `Queue (${content.getChildCount()})`
end if
end function
function OnkeyEvent(key as string, press as boolean) as boolean
if NavigationKeyHandler(key, press).handled
return true
end if
if press = false
return false
end if
if key = "back"
Close()
return true
end if
return false
end function
function Close()
m.top.appController@.PopScreen(invalid)
end function
function OnClearButtonSelected()
m.top.playQueue@.Clear(invalid)
end function
function OnItemSelected() as void
content = m.queueList.content
if content = invalid
return
end if
index = m.queueList.itemSelected
if index < 0 or index >= content.getChildCount()
return
end if
m.top.playQueue@.PlayItemAtIndex(index)
end function
@@ -0,0 +1,64 @@
<component name="PlayQueueView" extends="Group" includes="Focus">
<interface>
<field id="content" type="node" onChange="OnContentSet" />
<field id="jumpToItem" type="integer" alias="queueList.jumpToItem" />
<field id="playQueue" type="node" />
<field id="appController" type="node" />
<function name="Show" />
</interface>
<children>
<Rectangle
id="background"
width="1280"
height="720"
color="#000000"
opacity="0" />
<Rectangle
id="container"
width="470"
height="720"
translation="[-470,0]"
color="0x242424">
<Label
id="queueLabel"
width="270"
height="52"
text="Queue"
vertAlign="center"
font="font:MediumBoldSystemFont"
translation="[20,20]" />
<Button
id="clearButton"
minWidth="150"
height="52"
text="Clear"
showFocusFootprint="true"
translation="[295,15]" />
<MarkupGrid
id="queueList"
itemComponentName="PlayQueueViewCell"
itemSize="[432,90]"
itemSpacing="[0,15]"
numColumns="1"
numRows="6"
vertFocusAnimationStyle="floatingFocus"
translation="[20,90]" />
</Rectangle>
<Animation id="showAnimation"
duration="0.3"
optional="true">
<FloatFieldInterpolator
id="fadeInterpolator"
key="[0.0, 0.5, 1.0]"
keyValue="[0.0, 0.4, 0.8]"
fieldToInterp="background.opacity" />
<Vector2DFieldInterpolator
id="translationInterpolator"
key="[0.0, 0.5, 1.0]"
keyValue="[[-470,0], [-235,0], [0,0]]"
fieldToInterp="container.translation" />
</Animation>
</children>
</component>
@@ -0,0 +1,75 @@
import "pkg:/components/NodeByRef/NodeByRef.bs"
import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/TimeUtils.bs"
import "pkg:/source/utils/Types.bs"
function Init()
m.durationRect = m.top.FindNode("durationRect")
m.durationLabel = m.top.FindNode("durationLabel")
end function
function OnContentSet() as void
content = m.top.itemContent
content = NodeByRef.Unwrap(content)
if content = invalid
return
end if
m.top.title = content.title
m.top.thumbnailUri = content.thumbnail
contentType = ValidString(content.type)
if contentType = "video" and ValidInt(content.lengthSeconds) <> 0
SetDurationText(content.lengthText)
m.top.durationRectVisible = true
else if contentType = "playlist" and not StringUtils.IsNullOrEmpty(content.videoCountText)
SetDurationText(content.videoCountText)
m.top.durationRectVisible = true
else
m.top.durationRectVisible = false
end if
SetHighlight()
end function
function SetDurationText(text as string) as void
m.top.duration = text
label = m.durationLabel
rect = m.durationRect
if label = invalid or rect = invalid
return
end if
rectParent = rect.getParent()
size = label.localBoundingRect()
rect.width = size.width + 16
rect.translation = [rectParent.width - rect.width, rect.translation[1]]
end function
function SetHighlight() as void
content = m.top.itemContent
playQueueContent = content.getParent()
if playQueueContent = invalid
return
end if
playQueue = playQueueContent.getParent()
if playQueue = invalid
return
end if
playQueueIndex = playQueue.index
index = m.top.index
if playQueueIndex = index
m.top.thumbnailBlendColor = "#FFFFFFFF"
m.top.highlightUri = "pkg:/images/focus_grid.9.png"
else
m.top.thumbnailBlendColor = "#606060FF"
m.top.highlightUri = ""
end if
end function
@@ -0,0 +1,50 @@
<component name="PlayQueueViewCell" extends="Group">
<interface>
<field id="itemContent" type="node" onChange="OnContentSet" />
<field id="index" type="integer" />
<field id="title" type="string" alias="titleLabel.text" />
<field id="thumbnailUri" type="uri" alias="thumbnailPoster.uri" />
<field id="thumbnailBlendColor" type="color" alias="thumbnailPoster.blendColor" />
<field id="highlightUri" type="uri" alias="highlightPoster.uri" />
<field id="duration" type="string" alias="durationLabel.text" />
<field id="durationRectVisible" type="boolean" alias="durationRect.visible" />
</interface>
<children>
<Poster
id="thumbnailPoster"
loadDisplayMode="scaleToZoom"
width="160"
height="90"
failedBitmapUri="pkg:/images/thumbnail-missing.jpg"
translation="[2,2]">
<Rectangle
id="durationRect"
width="60"
height="26"
color="0x000000"
opacity="0.8"
translation="[100, 58]">
<Label
height="26"
id="durationLabel"
horizAlign="center"
vertAlign="center"
font="font:SmallestSystemFont"
translation="[8, 0]" />
</Rectangle>
</Poster>
<Poster
id="highlightPoster"
blendColor="0xFF0000"
width="164"
height="94" />
<Label
id="titleLabel"
width="260"
font="font:SmallestBoldSystemFont"
maxLines="3"
wrap="true"
translation="[172,2]" />
</children>
</component>
@@ -0,0 +1,23 @@
import "pkg:/components/Services/Invidious/InvidiousToContentNode.bs"
namespace PlayQueueViewUtils
function Open(playQueue as object, appController as object) as object
playQueueView = CreateObject("roSGNode", "PlayQueueView")
playQueueView.appController = appController
playQueueView.playQueue = playQueue
appController@.PushScreen(playQueueView)
content = playQueue.content
index = playQueue.index
playQueueView.content = content
if index > -1 and index < content.GetChildCount()
playQueueView.jumpToItem = index
end if
playQueueView@.Show(invalid)
return playQueueView
end function
end namespace
@@ -24,7 +24,7 @@ end function
function OnNodeReady()
m.list.ObserveField("itemFocused", FuncName(OnItemFocused))
InitializeLongPressTimer()
InitializeLongPress(["OK"])
end function
function OnFocusChange() as void
@@ -53,7 +53,9 @@ function OnContentSet() as void
m.background.uri = content.thumbnailBackground
itemFocused = m.list.itemFocused
m.list.content = content
if not content.isSameNode(m.list.content)
m.list.content = content
end if
if itemFocused > -1 and content.getChildCount() > itemFocused
m.list.jumpToItem = itemFocused
end if
@@ -65,7 +67,7 @@ function OnkeyEvent(key as string, press as boolean) as boolean
return true
end if
if key = LONG_PRESS_KEY and press
if key = OK_LONG_PRESS_KEY and press
OnItemLongPressed(m.list.itemFocused)
return true
end if
@@ -39,5 +39,5 @@ function SetDurationText(text as string) as void
size = label.localBoundingRect()
rect.width = size.width + 16
rect.translation = [rectParent.width - rect.width, 72]
rect.translation = [rectParent.width - rect.width, rect.translation[1]]
end function
@@ -35,7 +35,6 @@ namespace InvidiousContent
SetIfExists(node, "author", item, "author")
SetIfExists(node, "authorId", item, "authorId")
SetIfExists(node, "hlsUrl", item, "hlsUrl")
SetIfExists(node, "lengthSeconds", item, "lengthSeconds")
node.lengthText = TimeUtils.GetFormattedTime(item.lengthSeconds)
node.liveNow = VideoIsLive(item)
@@ -37,5 +37,5 @@ function SetVideoCount(videoCountText as string)
size = label.localBoundingRect()
rect.width = size.width + 16
rect.translation = [rectParent.width - rect.width, 162]
rect.translation = [rectParent.width - rect.width, rect.translation[1]]
end function
@@ -71,6 +71,6 @@ function SetDurationText(text as string)
size = label.localBoundingRect()
rect.width = size.width + 16
rect.translation = [rectParent.width - rect.width, 162]
rect.translation = [rectParent.width - rect.width, rect.translation[1]]
end function
@@ -25,7 +25,7 @@ function OnNodeReady()
' TODO:P1 Reload when subscriptions change
DisposableObserveFieldScoped(m.invidious, "authToken", FuncName(OnAuthTokenChange))
InitializeLongPressTimer()
InitializeLongPress(["OK"])
end function
function OnFocusedChildChange() as void
@@ -301,7 +301,7 @@ function OnkeyEvent(key as string, press as boolean) as boolean
return true
end if
if key = LONG_PRESS_KEY and press
if key = OK_LONG_PRESS_KEY and press
OnRowItemLongPressed(m.top.rowItemFocused)
return true
end if
@@ -154,15 +154,26 @@ function VideoRowListRowContentTask(input as object) as object
end function
function RemovePlaceHolderItems(contentNode as object)
childCount = contentNode.getChildCount()
removeIndex = childCount
removeCount = 0
index = childCount - 1
isLoading = true
while isLoading and contentNode.getChildCount() > 0
lastIndex = contentNode.getChildCount() - 1
child = contentNode.getChild(lastIndex)
isLoading = IsString(child.type) and child.type = "loading"
if isLoading = true
contentNode.removeChildIndex(lastIndex)
while isLoading and index >= 0
child = contentNode.getChild(index)
isLoading = ValidString(child.type) = "loading"
if not isLoading
exit while
end if
removeCount += 1
removeIndex -= 1
index -= 1
end while
if removeCount > 0
contentNode.removeChildrenIndex(removeCount, removeIndex)
end if
end function
function HandleFeedLoadErrorDialog(error as object, rowList as object) as void
@@ -4,6 +4,8 @@ function Init()
' We keep in memory the last videos we watched, to avoid a loop
' Sometimes recommended videos point to each other, and we're stuck watching
' The same 2 videos over and over again
' TODO:P1 get rid of `watchedVideos` and use the PlayQueue instead
m.watchedVideos = new RingBuffer(100)
end function
@@ -185,8 +185,18 @@ function OnVideoPlayerStateChange() as void
end if
if state = "finished"
if content = invalid
m.container@.watchedVideosClear(invalid)
VideoUtils.CloseVideo()
end if
metadata = content.metadata
if metadata <> invalid and not PlayNext(metadata.recommendedVideos)
if metadata = invalid
m.container@.watchedVideosClear(invalid)
VideoUtils.CloseVideo()
end if
if not PlayNext(metadata.recommendedVideos)
m.container@.watchedVideosClear(invalid)
VideoUtils.CloseVideo()
end if
@@ -221,6 +231,7 @@ function PlayNext(recommendedVideos as object) as boolean
return PlayNextRecommendedVideo(recommendedVideos)
end function
' TODO:P2 move this to the play queue
function PlayNextRecommendedVideo(recommendedVideos as object) as boolean
if m.preferences["playback.autoplay"] <> true
return false
@@ -240,8 +251,9 @@ function PlayNextRecommendedVideo(recommendedVideos as object) as boolean
end if
if not m.container@.watchedVideosContain(videoId)
LogInfo(`Playing next recommended video (${videoId})`)
node = InvidiousContent.ToVideoContentNode(invalid, metadata, invalid)
VideoUtils.PlayVideo(node)
instance = m.invidious@.GetCurrentInstance(invalid)
node = InvidiousContent.ToVideoContentNode(invalid, metadata, instance)
m.playQueue@.Play(node, -1)
return true
end if
end for
+2 -2
View File
@@ -2,8 +2,8 @@ title=PlayletLib
# Do not update version manually, it is auto updated from package.json
major_version=0
minor_version=15
build_version=00001
minor_version=16
build_version=00000
ui_resolutions=hd
@@ -284,18 +284,19 @@ namespace HttpClient
end function
function Await() as HttpResponse
tryCount = m._tryCount
triesLeft = m._tryCount
response = invalid
response = m.AwaitInternal()
if response.IsSuccess() or response.TimedOut() or response.IsCancelled() or response.StatusCode() < 500
return response
end if
tryCount -= 1
triesLeft -= 1
while tryCount > 0
while triesLeft > 0
backoffMs = 1000 + Rnd(2000)
LogInfo("Request failed ID:", m.urlTransfer.GetIdentity(), "ErrorMessage:", response.ErrorMessage(), `\nRetrying:`, m._tryCount - tryCount, "in", backoffMs, "ms")
tryNumber = m._tryCount - triesLeft + 1
LogInfo("Request failed ID:", m.urlTransfer.GetIdentity(), "ErrorMessage:", response.ErrorMessage(), `\nRetrying: (`, tryNumber, "/", m._tryCount, ") in", backoffMs, "ms")
m.urlTransfer = invalid
m._cache = invalid
@@ -307,7 +308,7 @@ namespace HttpClient
if response.IsSuccess() or response.TimedOut() or response.IsCancelled() or response.StatusCode() < 500
return response
end if
tryCount -= 1
triesLeft -= 1
end while
return response
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "playlet-web",
"version": "0.15.1",
"version": "0.16.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "playlet-web",
"version": "0.15.1",
"version": "0.16.0",
"devDependencies": {
"@sveltejs/vite-plugin-svelte": "^2.4.6",
"@tailwindcss/typography": "^0.5.10",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "playlet-web",
"version": "0.15.1",
"version": "0.16.0",
"type": "module",
"scripts": {
"dev": "vite",