Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1112070f63 | ||
|
|
37dde57c67 | ||
|
|
b52cd6f01b | ||
|
|
aa5be75e06 | ||
|
|
188463c6a7 | ||
|
|
793842f4dd | ||
|
|
7ca98e7ef2 | ||
|
|
77204c4449 | ||
|
|
190548245a | ||
|
|
71f9820ed6 | ||
|
|
87e50e713f | ||
|
|
2d55569614 | ||
|
|
83a59a5e9c | ||
|
|
7d1ba07286 | ||
|
|
ec9178d687 | ||
|
|
84c6d822e2 | ||
|
|
7503c2dbd6 | ||
|
|
ca3cad4058 | ||
|
|
c7f14dfc38 | ||
|
|
ac3d1cea17 | ||
|
|
93ea822f27 | ||
|
|
d73a03d3bf | ||
|
|
45736dd8ec | ||
|
|
90565ccb07 | ||
|
|
b72173f588 | ||
|
|
2d759c1c39 | ||
|
|
11fb644fc6 | ||
|
|
b076517c1b | ||
|
|
74082f406a | ||
|
|
f3aeb58b38 | ||
|
|
44ee6681c5 | ||
|
|
85e30c8b22 | ||
|
|
80d3d24e39 | ||
|
|
a7bdab30bc | ||
|
|
3858681b80 | ||
|
|
e0cf59d90f | ||
|
|
d9b8aaa222 | ||
|
|
b1a373f98d | ||
|
|
1078459eb7 | ||
|
|
14cc537032 | ||
|
|
db755c4158 | ||
|
|
ed068f6599 | ||
|
|
45011a54f0 | ||
|
|
8c71a5be88 | ||
|
|
d059fced58 | ||
|
|
ea2be153b0 | ||
|
|
7e5b2246fa | ||
|
|
a710a23444 | ||
|
|
a3b3a143a5 |
No files matched your search
+44
-3
@@ -5,6 +5,47 @@ 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).
|
||||||
|
|
||||||
|
## [0.20.0] - 2024-02-21
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Support for casting from the YouTube app (also known as Lounge API, or LeanBack)
|
||||||
|
- Connect to Playlet from the YouTube mobile app or from certain browsers (such as Chrome)
|
||||||
|
- Connect to Playlet from local network, or through the TV code.
|
||||||
|
- On the cast dialog in your YouTube mobile app, you might see two listings for the same device. E.g. `Roku TV` and `Playlet on Roku TV`. Use the `Playlet on` one to cast to Playlet, and the other one to cast to the regular YouTube TV app.
|
||||||
|
- The functionality is still experiemntal, and has some limitations. To name a few:
|
||||||
|
- The queue does not perfectly sync between the mobile app and Playlet, espeically if it gets modified by the web app or in Playlet.
|
||||||
|
- Many functions (such as d-pad controls or setting the volume) are not working due to OS limitations
|
||||||
|
- Many functions (such as changing the subtitle settings) are not currently implemented
|
||||||
|
- **ATTENTION**: This feature is not very privacy friendly. When connected to a lounge, all network traffic (videos played, queued, etc) go through YouTube servers. For this reason, certain measures are taken:
|
||||||
|
- While Playlet broadcasts its casting capabilities to the local network, it does not connect to a lounge for the first time until:
|
||||||
|
- A device connects to Playlet (using DIAL/Connect using Wi-Fi)
|
||||||
|
- A `Link with TV code` is generated, by visiting the `Remote` -> `Link with TV code` tab.
|
||||||
|
- Playlet disconnects from previous lounge sessions on start, and joins a new one instead of one continous session. In other words, restarting Playlet will disconnect your second device. This is a feature, not a bug.
|
||||||
|
- Playlet does not expose device details, and uses a randomly generated id on each start, instead of consistent device id.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- The queue no longer contains playlists. When a playlist is added to the queue, the entire playlist is loaded.
|
||||||
|
- It can take a few seconds to load large playlist before it can be added to the queue
|
||||||
|
- This is done to be more compatible more the lounge, which does not contain "Playlists in the queue" concept.
|
||||||
|
- The `Web App` tab is now called `Remote`. It can be used to open the web app, or connect using Lounge (cast from YouTube)
|
||||||
|
- Removed `fields` from Invidious requests, as per [https://github.com/iv-org/invidious/pull/4276](https://github.com/iv-org/invidious/pull/4276)
|
||||||
|
- The `POST /api/queue/` no longer returns the current queue. Instead it returns a 204.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- [Perf] improved some caching of videos in the queue
|
||||||
|
|
||||||
|
## [0.19.2] - 2024-02-11
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- [Attempt #2] to fix a crash caused by execution timeout when stopping a video takes too long
|
||||||
|
- Wrong hint on the "added to queue" notification when in fullscreen
|
||||||
|
- A rare crash when listing Invidious public instances
|
||||||
|
- Restoring video to full screen not working when on certain screens
|
||||||
|
|
||||||
## [0.19.1] - 2024-01-13
|
## [0.19.1] - 2024-01-13
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
@@ -348,7 +389,7 @@ This version went through a major refactor, which resulted in a different arcite
|
|||||||
- Dark mode
|
- Dark mode
|
||||||
- Also includes a dev menu
|
- Also includes a dev menu
|
||||||
- Hidden by default, use `dev=1` in the browser to show it
|
- Hidden by default, use `dev=1` in the browser to show it
|
||||||
- Improved drag and drop functionality (drag and drop a link from Youtube into the web app)
|
- Improved drag and drop functionality (drag and drop a link from YouTube into the web app)
|
||||||
- New settings page, available on TV and web app
|
- New settings page, available on TV and web app
|
||||||
- New preferences system
|
- New preferences system
|
||||||
- Unified settings between TV and web app
|
- Unified settings between TV and web app
|
||||||
@@ -405,7 +446,7 @@ This version went through a major refactor, which resulted in a different arcite
|
|||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- A script to sync between Youtube profile and and Invidious profile
|
- A script to sync between YouTube profile and and Invidious profile
|
||||||
- Moved most of Playlet logic to Playlet Lib
|
- Moved most of Playlet logic to Playlet Lib
|
||||||
- Support for multiple caption languages
|
- Support for multiple caption languages
|
||||||
|
|
||||||
@@ -453,7 +494,7 @@ This version went through a major refactor, which resulted in a different arcite
|
|||||||
- Loading spinner
|
- Loading spinner
|
||||||
- Picture in picture support
|
- Picture in picture support
|
||||||
- [Deep linking support](https://developer.roku.com/en-ca/docs/developer-program/discovery/implementing-deep-linking.md)
|
- [Deep linking support](https://developer.roku.com/en-ca/docs/developer-program/discovery/implementing-deep-linking.md)
|
||||||
- Both Launch arguments and Input arguments are supported, using the "contentId" key as the Youtube video id
|
- Both Launch arguments and Input arguments are supported, using the "contentId" key as the YouTube video id
|
||||||
- Error and Exit dialogs
|
- Error and Exit dialogs
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
+14
-1
@@ -1,12 +1,14 @@
|
|||||||
# PRIVACY POLICY
|
# PRIVACY POLICY
|
||||||
|
|
||||||
## Playlet
|
## Playlet
|
||||||
|
|
||||||
Playlet, the Roku app, does not collect any user information whatsoever.
|
Playlet, the Roku app, does not collect any user information whatsoever.
|
||||||
In fact, it does not have any servers capable of collecting any form of data.
|
In fact, it does not have any servers capable of collecting any form of data.
|
||||||
|
|
||||||
Playlet does not show advertising, whether personalized or non personalized.
|
Playlet does not show advertising, whether personalized or non personalized.
|
||||||
|
|
||||||
## Invidious
|
## Invidious
|
||||||
|
|
||||||
Playlet may request information from one or more [Invidious](https://invidious.io/)
|
Playlet may request information from one or more [Invidious](https://invidious.io/)
|
||||||
servers, depending on user configuration. With these requests, absolutely no
|
servers, depending on user configuration. With these requests, absolutely no
|
||||||
user data is collected, and only the bare minimum and necessary information
|
user data is collected, and only the bare minimum and necessary information
|
||||||
@@ -23,6 +25,7 @@ keywords. In case the user has privacy concerns, they can host their own
|
|||||||
Invidious instance and use it from Playlet.
|
Invidious instance and use it from Playlet.
|
||||||
|
|
||||||
## SponsorBlock
|
## SponsorBlock
|
||||||
|
|
||||||
Playlet may request information from a [SponsorBlock](https://github.com/ajayyy/SponsorBlock)
|
Playlet may request information from a [SponsorBlock](https://github.com/ajayyy/SponsorBlock)
|
||||||
server, in order to get sponsor sections for requested videos to watch.
|
server, in order to get sponsor sections for requested videos to watch.
|
||||||
With these requests, absolutely no
|
With these requests, absolutely no
|
||||||
@@ -36,4 +39,14 @@ user privacy.
|
|||||||
Additionally, Playlet may send a "skipped" event to SponsorBlock, to indicate
|
Additionally, Playlet may send a "skipped" event to SponsorBlock, to indicate
|
||||||
that a section of a video has been skipped. This event does not have any
|
that a section of a video has been skipped. This event does not have any
|
||||||
tracking information attached to it, and it is anonymous. It is merely to
|
tracking information attached to it, and it is anonymous. It is merely to
|
||||||
indicate to contributers how much their contributions are being used in the wild.
|
indicate to contributers how much their contributions are being used in the wild.
|
||||||
|
|
||||||
|
## LeanBack
|
||||||
|
|
||||||
|
LeanBack, also known as Lounge API, also known as "cast from phone". Is a feature that Playlet implmements as a convenience to allow users to use a separate device to browse and cast videos.
|
||||||
|
When this feature is used, all traffic related to the videos being watched, added to the queue, and the video player state is routed through YouTube servers.
|
||||||
|
|
||||||
|
Playlet tries to preserve user privacy, to the best of its ability, by implementing several techniques, such as randomizing device id, using a fresh session on each start, and only providing necessary fields for the feature to function.
|
||||||
|
Additionally, Playlet does not join a session/lounge, until a device is attempting to connect using DIAL (**DI**scovery **A**nd **L**aunch spec), or when a `Link with TV code` is generated, by visiting the appropriate settings page.
|
||||||
|
|
||||||
|
If you have privacy concerns and do not wish to use this functionality, simply do not connect from a local network using the YouTube app or the browser, and do not visit the `Link with TV code` tab.
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
# Playlet
|
# Playlet
|
||||||
|
|
||||||
Playlet is an unofficial Youtube client for Roku 📺
|
Playlet is an unofficial YouTube client for Roku 📺
|
||||||
|
|
||||||
## Screenshots
|
## Screenshots
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ More under [Screenshots](./docs/screenshots/README.md)
|
|||||||
- ⚔️ SponsorBlock integration (skips undesirable sections in videos)
|
- ⚔️ SponsorBlock integration (skips undesirable sections in videos)
|
||||||
- 📱 Browse, search, and cast from phone using the web app
|
- 📱 Browse, search, and cast from phone using the web app
|
||||||
- 🔮 Picture-in-picture mode
|
- 🔮 Picture-in-picture mode
|
||||||
- ⚡ Fast! [Check out how we compare with the official Youtube app](https://youtu.be/qmSvA-QQW20)
|
- ⚡ Fast! [Check out how we compare with the official YouTube app](https://youtu.be/qmSvA-QQW20)
|
||||||
|
|
||||||
### Cast from phone
|
### Cast from phone
|
||||||
|
|
||||||
@@ -89,10 +89,10 @@ play•let /ˈplālət/
|
|||||||
: a short play
|
: a short play
|
||||||
```
|
```
|
||||||
|
|
||||||
**Playlet** is about keeping the time you spend on Youtube short and useful. It values your time, so it does not show you ads, and allows you to skip sponsored sections and other irrelevant information that's designed to monitize you and/or waste your time.
|
**Playlet** is about keeping the time you spend on YouTube short and useful. It values your time, so it does not show you ads, and allows you to skip sponsored sections and other irrelevant information that's designed to monitize you and/or waste your time.
|
||||||
|
|
||||||
There's a cliché about how a lot of open source software is **`"Made with ♡"`**. This project in particular is **not**.<br/>
|
There's a cliché about how a lot of open source software is **`"Made with ♡"`**. This project in particular is **not**.<br/>
|
||||||
**Playlet** was created out of **spite**, because I believe I have watched enough back-to-back, unskippable Youtube ads for a lifetime.
|
**Playlet** was created out of **spite**, because I believe I have watched enough back-to-back, unskippable YouTube ads for a lifetime.
|
||||||
|
|
||||||
By removing all the bloat, the ads, the tracking, we could end up with an even faster app than the official one.
|
By removing all the bloat, the ads, the tracking, we could end up with an even faster app than the official one.
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
"createPackage": false,
|
"createPackage": false,
|
||||||
"diagnosticFilters": [
|
"diagnosticFilters": [
|
||||||
{
|
{
|
||||||
"src": "**/*.part.xml",
|
"src": "components/**/*.part.xml",
|
||||||
"codes": [
|
"codes": [
|
||||||
// 1067 - Cannot find function with name '${name}' in component scope
|
// 1067 - Cannot find function with name '${name}' in component scope
|
||||||
// This is to prevent errors where the onChange function is not found in the component scope
|
// This is to prevent errors where the onChange function is not found in the component scope
|
||||||
@@ -45,10 +45,11 @@
|
|||||||
"files": [
|
"files": [
|
||||||
"source/**",
|
"source/**",
|
||||||
"components/**",
|
"components/**",
|
||||||
|
"!components/**/*.part.xml",
|
||||||
"images/**",
|
"images/**",
|
||||||
|
"!**/*.psd",
|
||||||
"!**/*.svg",
|
"!**/*.svg",
|
||||||
"!**/*.svg.meta.json5",
|
"!**/*.svg.meta.json5",
|
||||||
"fonts/**",
|
|
||||||
"config/**",
|
"config/**",
|
||||||
"lib/**",
|
"lib/**",
|
||||||
"www/**",
|
"www/**",
|
||||||
@@ -71,7 +72,8 @@
|
|||||||
"../tools/bs-plugins/validation-plugin.ts",
|
"../tools/bs-plugins/validation-plugin.ts",
|
||||||
"../tools/bs-plugins/logger-plugin.ts",
|
"../tools/bs-plugins/logger-plugin.ts",
|
||||||
"../tools/bs-plugins/image-gen-plugin.ts",
|
"../tools/bs-plugins/image-gen-plugin.ts",
|
||||||
"../tools/bs-plugins/type-gen-plugin.ts"
|
"../tools/bs-plugins/type-gen-plugin.ts",
|
||||||
|
"../tools/bs-plugins/web-server-plugin.ts"
|
||||||
],
|
],
|
||||||
"retainStagingDir": true,
|
"retainStagingDir": true,
|
||||||
"require": [
|
"require": [
|
||||||
|
|||||||
@@ -3,10 +3,11 @@
|
|||||||
"files": [
|
"files": [
|
||||||
"source/**",
|
"source/**",
|
||||||
"components/**",
|
"components/**",
|
||||||
|
"!components/**/*.part.xml",
|
||||||
"images/**",
|
"images/**",
|
||||||
|
"!**/*.psd",
|
||||||
"!**/*.svg",
|
"!**/*.svg",
|
||||||
"!**/*.svg.meta.json5",
|
"!**/*.svg.meta.json5",
|
||||||
"fonts/**",
|
|
||||||
"config/**",
|
"config/**",
|
||||||
"lib/**",
|
"lib/**",
|
||||||
"www/**",
|
"www/**",
|
||||||
@@ -27,7 +28,8 @@
|
|||||||
"../tools/bs-plugins/validation-plugin.ts",
|
"../tools/bs-plugins/validation-plugin.ts",
|
||||||
"../tools/bs-plugins/logger-plugin.ts",
|
"../tools/bs-plugins/logger-plugin.ts",
|
||||||
"../tools/bs-plugins/image-gen-plugin.ts",
|
"../tools/bs-plugins/image-gen-plugin.ts",
|
||||||
"../tools/bs-plugins/type-gen-plugin.ts"
|
"../tools/bs-plugins/type-gen-plugin.ts",
|
||||||
|
"../tools/bs-plugins/web-server-plugin.ts"
|
||||||
],
|
],
|
||||||
"rooibos": {
|
"rooibos": {
|
||||||
"logLevel": 2,
|
"logLevel": 2,
|
||||||
|
|||||||
+1
-1
@@ -142,7 +142,7 @@ That's pretty much it.
|
|||||||
|
|
||||||
There are a few reasons we made this separation:
|
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.
|
- 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. For example, it's possible to choose a different verrsion from the developer settings in the web app.
|
- 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.
|
- 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.
|
- 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.
|
||||||
|
|||||||
+21
-34
@@ -2,7 +2,7 @@ openapi: 3.0.0
|
|||||||
|
|
||||||
info:
|
info:
|
||||||
title: Playlet Web API
|
title: Playlet Web API
|
||||||
version: 0.19.1
|
version: 0.20.0
|
||||||
description:
|
description:
|
||||||
Playlet Web API is a RESTful API for controlling the Playlet app on
|
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
|
Roku devices. The API is intended to be used by the Playlet web app, but can
|
||||||
@@ -106,7 +106,7 @@ paths:
|
|||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
type: string
|
type: string
|
||||||
put:
|
post:
|
||||||
summary: Add to search history
|
summary: Add to search history
|
||||||
description: |
|
description: |
|
||||||
Add a query to the search history.
|
Add a query to the search history.
|
||||||
@@ -140,9 +140,9 @@ paths:
|
|||||||
description: No Content
|
description: No Content
|
||||||
/api/queue:
|
/api/queue:
|
||||||
get:
|
get:
|
||||||
summary: Get play queue
|
summary: Get video queue
|
||||||
description: Get the current videos in the queue.
|
description: Get the current videos in the queue.
|
||||||
operationId: getPlayQueue
|
operationId: getVideoQueue
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: OK
|
description: OK
|
||||||
@@ -151,56 +151,43 @@ paths:
|
|||||||
schema:
|
schema:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
index:
|
|
||||||
type: integer
|
|
||||||
playlistIndex:
|
|
||||||
type: integer
|
|
||||||
items:
|
items:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
$ref: "#/components/schemas/PlayQueueObject"
|
$ref: "#/components/schemas/VideoQueueObject"
|
||||||
|
index:
|
||||||
|
type: integer
|
||||||
|
nowPlaying:
|
||||||
|
$ref: "#/components/schemas/VideoQueueObject"
|
||||||
post:
|
post:
|
||||||
summary: Add to play queue
|
summary: Add to video queue
|
||||||
description: Add a video or a playlist to the queue.
|
description: Add a video or a playlist to the queue.
|
||||||
operationId: addToPlayQueue
|
operationId: addToVideoQueue
|
||||||
requestBody:
|
requestBody:
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/PlayQueueObject"
|
$ref: "#/components/schemas/VideoQueueObject"
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"204":
|
||||||
description: OK
|
description: No Content
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
index:
|
|
||||||
type: integer
|
|
||||||
playlistIndex:
|
|
||||||
type: integer
|
|
||||||
items:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
$ref: "#/components/schemas/PlayQueueObject"
|
|
||||||
delete:
|
delete:
|
||||||
summary: Clear play queue
|
summary: Clear video queue
|
||||||
description: Clear the play queue.
|
description: Clear the video queue.
|
||||||
operationId: clearPlayQueue
|
operationId: clearVideoQueue
|
||||||
responses:
|
responses:
|
||||||
"204":
|
"204":
|
||||||
description: No Content
|
description: No Content
|
||||||
/api/queue/play:
|
/api/queue/play:
|
||||||
post:
|
post:
|
||||||
summary: Play video or playlist
|
summary: Play video
|
||||||
description: Play a video or playlist. This adds the video or playlist to the current position in the queue and plays it.
|
description: Play a video or playlist. This adds the video or playlist to the current position in the queue and plays it.
|
||||||
operationId: playPlayQueue
|
operationId: playVideoQueue
|
||||||
requestBody:
|
requestBody:
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/PlayQueueObject"
|
$ref: "#/components/schemas/VideoQueueObject"
|
||||||
responses:
|
responses:
|
||||||
"204":
|
"204":
|
||||||
description: No Content
|
description: No Content
|
||||||
@@ -574,7 +561,7 @@ components:
|
|||||||
sponsorblock.show_notifications:
|
sponsorblock.show_notifications:
|
||||||
type: boolean
|
type: boolean
|
||||||
# TODO:P1 add the rest of properties
|
# TODO:P1 add the rest of properties
|
||||||
PlayQueueObject:
|
VideoQueueObject:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
videoId:
|
videoId:
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
- [Tracking transpilied files](#tracking-transpilied-files)
|
- [Tracking transpilied files](#tracking-transpilied-files)
|
||||||
- [Logger](#logger)
|
- [Logger](#logger)
|
||||||
- [Type Gen](#type-gen)
|
- [Type Gen](#type-gen)
|
||||||
|
- [Web Server](#web-server)
|
||||||
|
|
||||||
Playlet implements a few [Brighterscript Plugins](https://github.com/rokucommunity/brighterscript/blob/master/docs/plugins.md). The plugins inject themselves in the compilation process, allowing the modification of bs scripts, xml components, and even assets or the app manifest. Let's start with a simple one:
|
Playlet implements a few [Brighterscript Plugins](https://github.com/rokucommunity/brighterscript/blob/master/docs/plugins.md). The plugins inject themselves in the compilation process, allowing the modification of bs scripts, xml components, and even assets or the app manifest. Let's start with a simple one:
|
||||||
|
|
||||||
@@ -571,3 +572,33 @@ function ValidBool(obj as dynamic) as boolean
|
|||||||
end if
|
end if
|
||||||
end function
|
end function
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Web Server
|
||||||
|
|
||||||
|
**[Source](/tools/bs-plugins/web-server-plugin.ts)**
|
||||||
|
|
||||||
|
### Why
|
||||||
|
|
||||||
|
Handles routing annotations (e.g. `@get("/api/something")) so that they are handled by the routers/middlewares. It's nicer than having to register things by hand.
|
||||||
|
|
||||||
|
### How
|
||||||
|
|
||||||
|
Routers need to inherit from `Http.HttpRouter`. Then, once a request handled is annotated, e.g.
|
||||||
|
|
||||||
|
```bs
|
||||||
|
@get("/")
|
||||||
|
function GoHome(context as object) as boolean
|
||||||
|
response = context.response
|
||||||
|
response.Redirect("/index.html")
|
||||||
|
return true
|
||||||
|
end function
|
||||||
|
```
|
||||||
|
|
||||||
|
The route and the handler are added to the router. In this example, the `/` route redirects to `index/html`.
|
||||||
|
|
||||||
|
There one special annotation, and one special route:
|
||||||
|
|
||||||
|
- `@all` matches all methods
|
||||||
|
- `*` matches all paths
|
||||||
|
|
||||||
|
So `@all(*)` would be a middleware that will be matched with any request.
|
||||||
Generated
+44
-117
@@ -1,36 +1,36 @@
|
|||||||
{
|
{
|
||||||
"name": "playlet",
|
"name": "playlet",
|
||||||
"version": "0.19.1",
|
"version": "0.20.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "playlet",
|
"name": "playlet",
|
||||||
"version": "0.19.1",
|
"version": "0.20.0",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@rokucommunity/bslint": "^0.8.14",
|
"@rokucommunity/bslint": "^0.8.17",
|
||||||
"@types/crypto-js": "^4.2.1",
|
"@types/crypto-js": "^4.2.2",
|
||||||
"@types/fs-extra": "^11.0.4",
|
"@types/fs-extra": "^11.0.4",
|
||||||
"@types/node": "^20.11.0",
|
"@types/node": "^20.11.19",
|
||||||
"@types/xml2js": "^0.4.14",
|
"@types/xml2js": "^0.4.14",
|
||||||
"argparse": "^2.0.1",
|
"argparse": "^2.0.1",
|
||||||
"brighterscript": "0.65.16",
|
"brighterscript": "0.65.22",
|
||||||
"brighterscript-formatter": "^1.6.37",
|
"brighterscript-formatter": "^1.6.40",
|
||||||
"convert-svg-to-png": "^0.6.4",
|
"convert-svg-to-png": "^0.6.4",
|
||||||
"cross-fetch": "^4.0.0",
|
"cross-fetch": "^4.0.0",
|
||||||
"crypto-js": "^4.2.0",
|
"crypto-js": "^4.2.0",
|
||||||
"dotenv": "^16.3.1",
|
"dotenv": "^16.4.4",
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
"fs-extra": "^11.2.0",
|
"fs-extra": "^11.2.0",
|
||||||
"glob": "^10.3.10",
|
"glob": "^10.3.10",
|
||||||
"imap": "^0.8.19",
|
"imap": "^0.8.19",
|
||||||
"ip": "^1.1.8",
|
"ip": "^1.1.8",
|
||||||
"json5": "^2.2.3",
|
"json5": "^2.2.3",
|
||||||
"mailparser": "^3.6.6",
|
"mailparser": "^3.6.7",
|
||||||
"roku-deploy": "^3.11.2",
|
"roku-deploy": "^3.11.2",
|
||||||
"rooibos-roku": "^5.10.0",
|
"rooibos-roku": "^5.11.0",
|
||||||
"semver": "^7.5.4",
|
"semver": "^7.6.0",
|
||||||
"shelljs": "^0.8.5",
|
"shelljs": "^0.8.5",
|
||||||
"ts-node": "^10.9.2",
|
"ts-node": "^10.9.2",
|
||||||
"typescript": "^5.3.3",
|
"typescript": "^5.3.3",
|
||||||
@@ -276,9 +276,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/@rokucommunity/bslint": {
|
"node_modules/@rokucommunity/bslint": {
|
||||||
"version": "0.8.14",
|
"version": "0.8.17",
|
||||||
"resolved": "https://registry.npmjs.org/@rokucommunity/bslint/-/bslint-0.8.14.tgz",
|
"resolved": "https://registry.npmjs.org/@rokucommunity/bslint/-/bslint-0.8.17.tgz",
|
||||||
"integrity": "sha512-vKD2weW5I8jOXe+2xHN9FZ9GUCkbE/FOTbWcziLXrObraXJZcNRqk+fWDvi7go79ourQ/9DmYfmFH0bocjOMqg==",
|
"integrity": "sha512-e0ksPVYnN+QkhzuV97yPTf1NxSkBQZNMJRhlCFnMJf6gfps+VdY1HwYn3IlqDz3XJxfYcRSDa3v3fQ5dQynVEA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"fs-extra": "^10.0.0",
|
"fs-extra": "^10.0.0",
|
||||||
@@ -345,9 +345,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/@types/crypto-js": {
|
"node_modules/@types/crypto-js": {
|
||||||
"version": "4.2.1",
|
"version": "4.2.2",
|
||||||
"resolved": "https://registry.npmjs.org/@types/crypto-js/-/crypto-js-4.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/@types/crypto-js/-/crypto-js-4.2.2.tgz",
|
||||||
"integrity": "sha512-FSPGd9+OcSok3RsM0UZ/9fcvMOXJ1ENE/ZbLfOPlBWj7BgXtEAM8VYfTtT760GiLbQIMoVozwVuisjvsVwqYWw==",
|
"integrity": "sha512-sDOLlVbHhXpAUAL0YHDUUwDZf3iN4Bwi4W6a0W0b+QcAezUbRtH4FVb+9J4h+XFPW7l/gQ9F8qC7P+Ec4k8QVQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/@types/fs-extra": {
|
"node_modules/@types/fs-extra": {
|
||||||
@@ -370,9 +370,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@types/node": {
|
"node_modules/@types/node": {
|
||||||
"version": "20.11.0",
|
"version": "20.11.19",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.0.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.19.tgz",
|
||||||
"integrity": "sha512-o9bjXmDNcF7GbM4CNQpmi+TutCgap/K3w1JyKgxAjqx41zp9qlIAVFi0IhCNsJcXolEqLWhbFbEeL0PvYm4pcQ==",
|
"integrity": "sha512-7xMnVEcZFu0DikYjWOlRq7NTPETrm7teqUT2WkQjrTIkEgUyyGdWsj/Zg8bEJt5TNklzbPD1X3fqfsHw3SpapQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"undici-types": "~5.26.4"
|
"undici-types": "~5.26.4"
|
||||||
@@ -728,9 +728,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/brighterscript": {
|
"node_modules/brighterscript": {
|
||||||
"version": "0.65.16",
|
"version": "0.65.22",
|
||||||
"resolved": "https://registry.npmjs.org/brighterscript/-/brighterscript-0.65.16.tgz",
|
"resolved": "https://registry.npmjs.org/brighterscript/-/brighterscript-0.65.22.tgz",
|
||||||
"integrity": "sha512-2RJMF8itkrPXtZ92JkJf3emvzcCl5ETXGVyPsdO/hMKbUGinEGMRFG07FR0bzjRotbALzsozGE/Hjzw412Sjww==",
|
"integrity": "sha512-rDSdO33xRnFGB9nr54awTUucpd4oZpZmDMvVUSAb6jmFU1jz+SYhwV9ezc8U5m3Kswap7uV+BmS1O69QZ9MuSw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@rokucommunity/bslib": "^0.1.1",
|
"@rokucommunity/bslib": "^0.1.1",
|
||||||
@@ -740,7 +740,6 @@
|
|||||||
"chevrotain": "^7.0.1",
|
"chevrotain": "^7.0.1",
|
||||||
"chokidar": "^3.5.1",
|
"chokidar": "^3.5.1",
|
||||||
"clear": "^0.1.0",
|
"clear": "^0.1.0",
|
||||||
"coveralls-next": "^4.2.0",
|
|
||||||
"cross-platform-clear-console": "^2.3.0",
|
"cross-platform-clear-console": "^2.3.0",
|
||||||
"debounce-promise": "^3.1.0",
|
"debounce-promise": "^3.1.0",
|
||||||
"eventemitter3": "^4.0.0",
|
"eventemitter3": "^4.0.0",
|
||||||
@@ -771,12 +770,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/brighterscript-formatter": {
|
"node_modules/brighterscript-formatter": {
|
||||||
"version": "1.6.37",
|
"version": "1.6.40",
|
||||||
"resolved": "https://registry.npmjs.org/brighterscript-formatter/-/brighterscript-formatter-1.6.37.tgz",
|
"resolved": "https://registry.npmjs.org/brighterscript-formatter/-/brighterscript-formatter-1.6.40.tgz",
|
||||||
"integrity": "sha512-jIlqRjPVIp2WwB9Pe0YwK4KU4G3WqhRsqRluuOFY1sTDVW0R/AKXMvCfTsu99L2W7CbpeWA4UjOPzl9JOqN5hw==",
|
"integrity": "sha512-cxvGGluNfxy6p3khtcMt/3AschwqEnERjLRIEt3XVU0R0l2QgwXelDp8ViqgnQ2hQYa8LnfnOiV1u7OCqbiZPA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"brighterscript": "^0.65.16",
|
"brighterscript": "^0.65.19",
|
||||||
"glob-all": "^3.3.0",
|
"glob-all": "^3.3.0",
|
||||||
"jsonc-parser": "^3.0.0",
|
"jsonc-parser": "^3.0.0",
|
||||||
"source-map": "^0.7.3",
|
"source-map": "^0.7.3",
|
||||||
@@ -1479,25 +1478,6 @@
|
|||||||
"integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==",
|
"integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/coveralls-next": {
|
|
||||||
"version": "4.2.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/coveralls-next/-/coveralls-next-4.2.0.tgz",
|
|
||||||
"integrity": "sha512-zg41a/4QDSASPtlV6gp+6owoU43U5CguxuPZR3nPZ26M5ZYdEK3MdUe7HwE+AnCZPkucudfhqqJZehCNkz2rYg==",
|
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
|
||||||
"form-data": "4.0.0",
|
|
||||||
"js-yaml": "4.1.0",
|
|
||||||
"lcov-parse": "1.0.0",
|
|
||||||
"log-driver": "1.2.7",
|
|
||||||
"minimist": "1.2.7"
|
|
||||||
},
|
|
||||||
"bin": {
|
|
||||||
"coveralls": "bin/coveralls.js"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=14"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/create-require": {
|
"node_modules/create-require": {
|
||||||
"version": "1.1.1",
|
"version": "1.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz",
|
||||||
@@ -1726,15 +1706,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/dotenv": {
|
"node_modules/dotenv": {
|
||||||
"version": "16.3.1",
|
"version": "16.4.4",
|
||||||
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.4.tgz",
|
||||||
"integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==",
|
"integrity": "sha512-XvPXc8XAQThSjAbY6cQ/9PcBXmFoWuw1sQ3b8HqUCR6ziGXjkTi//kB9SWa2UwqlgdAIuRqAa/9hVljzPehbYg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=12"
|
"node": ">=12"
|
||||||
},
|
},
|
||||||
"funding": {
|
"funding": {
|
||||||
"url": "https://github.com/motdotla/dotenv?sponsor=1"
|
"url": "https://dotenvx.com"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/eastasianwidth": {
|
"node_modules/eastasianwidth": {
|
||||||
@@ -2103,20 +2083,6 @@
|
|||||||
"node": "*"
|
"node": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/form-data": {
|
|
||||||
"version": "4.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
|
|
||||||
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
|
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
|
||||||
"asynckit": "^0.4.0",
|
|
||||||
"combined-stream": "^1.0.8",
|
|
||||||
"mime-types": "^2.1.12"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 6"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/forwarded": {
|
"node_modules/forwarded": {
|
||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
|
||||||
@@ -2745,18 +2711,6 @@
|
|||||||
"@pkgjs/parseargs": "^0.11.0"
|
"@pkgjs/parseargs": "^0.11.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/js-yaml": {
|
|
||||||
"version": "4.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
|
|
||||||
"integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==",
|
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
|
||||||
"argparse": "^2.0.1"
|
|
||||||
},
|
|
||||||
"bin": {
|
|
||||||
"js-yaml": "bin/js-yaml.js"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/jsbn": {
|
"node_modules/jsbn": {
|
||||||
"version": "0.1.1",
|
"version": "0.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz",
|
||||||
@@ -2838,15 +2792,6 @@
|
|||||||
"setimmediate": "^1.0.5"
|
"setimmediate": "^1.0.5"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/lcov-parse": {
|
|
||||||
"version": "1.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/lcov-parse/-/lcov-parse-1.0.0.tgz",
|
|
||||||
"integrity": "sha512-aprLII/vPzuQvYZnDRU78Fns9I2Ag3gi4Ipga/hxnVMCZC8DnR2nI7XBqrPoywGfxqIx/DgarGvDJZAD3YBTgQ==",
|
|
||||||
"dev": true,
|
|
||||||
"bin": {
|
|
||||||
"lcov-parse": "bin/cli.js"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/leac": {
|
"node_modules/leac": {
|
||||||
"version": "0.6.0",
|
"version": "0.6.0",
|
||||||
"resolved": "https://registry.npmjs.org/leac/-/leac-0.6.0.tgz",
|
"resolved": "https://registry.npmjs.org/leac/-/leac-0.6.0.tgz",
|
||||||
@@ -2940,15 +2885,6 @@
|
|||||||
"integrity": "sha512-hXt6Ul/5yWjfklSGvLQl8vM//l3FtyHZeuelpzK6mm99pNvN9yTDruNZPEJZD1oWrqo+izBmB7oUfWgcCX7s4Q==",
|
"integrity": "sha512-hXt6Ul/5yWjfklSGvLQl8vM//l3FtyHZeuelpzK6mm99pNvN9yTDruNZPEJZD1oWrqo+izBmB7oUfWgcCX7s4Q==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/log-driver": {
|
|
||||||
"version": "1.2.7",
|
|
||||||
"resolved": "https://registry.npmjs.org/log-driver/-/log-driver-1.2.7.tgz",
|
|
||||||
"integrity": "sha512-U7KCmLdqsGHBLeWqYlFA0V0Sl6P08EE1ZrmA9cxjUE0WVqT9qnyVDPz1kzpFEP0jdJuFnasWIfSd7fsaNXkpbg==",
|
|
||||||
"dev": true,
|
|
||||||
"engines": {
|
|
||||||
"node": ">=0.8.6"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/long": {
|
"node_modules/long": {
|
||||||
"version": "3.2.0",
|
"version": "3.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/long/-/long-3.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/long/-/long-3.2.0.tgz",
|
||||||
@@ -2980,9 +2916,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/mailparser": {
|
"node_modules/mailparser": {
|
||||||
"version": "3.6.6",
|
"version": "3.6.7",
|
||||||
"resolved": "https://registry.npmjs.org/mailparser/-/mailparser-3.6.6.tgz",
|
"resolved": "https://registry.npmjs.org/mailparser/-/mailparser-3.6.7.tgz",
|
||||||
"integrity": "sha512-noCjBl3FToxmqTP2fp7z17hQsiCroWNntfTd8O+UejOAF59xeN5WGZK27ilexXV2e2X/cbUhG3L8sfEKaz0/sw==",
|
"integrity": "sha512-/3x8HW70DNehw+3vdOPKdlLuxOHoWcGB5jfx5vJ5XUbY9/2jUJbrrhda5Si8Dj/3w08U0y5uGAkqs5+SPTPKoA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"encoding-japanese": "2.0.0",
|
"encoding-japanese": "2.0.0",
|
||||||
@@ -2992,7 +2928,7 @@
|
|||||||
"libmime": "5.2.1",
|
"libmime": "5.2.1",
|
||||||
"linkify-it": "5.0.0",
|
"linkify-it": "5.0.0",
|
||||||
"mailsplit": "5.4.0",
|
"mailsplit": "5.4.0",
|
||||||
"nodemailer": "6.9.8",
|
"nodemailer": "6.9.9",
|
||||||
"tlds": "1.248.0"
|
"tlds": "1.248.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -3140,15 +3076,6 @@
|
|||||||
"node": "*"
|
"node": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/minimist": {
|
|
||||||
"version": "1.2.7",
|
|
||||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.7.tgz",
|
|
||||||
"integrity": "sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g==",
|
|
||||||
"dev": true,
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ljharb"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/mkdirp-classic": {
|
"node_modules/mkdirp-classic": {
|
||||||
"version": "0.5.3",
|
"version": "0.5.3",
|
||||||
"resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz",
|
"resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz",
|
||||||
@@ -3200,9 +3127,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/nodemailer": {
|
"node_modules/nodemailer": {
|
||||||
"version": "6.9.8",
|
"version": "6.9.9",
|
||||||
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.9.8.tgz",
|
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.9.9.tgz",
|
||||||
"integrity": "sha512-cfrYUk16e67Ks051i4CntM9kshRYei1/o/Gi8K1d+R34OIs21xdFnW7Pt7EucmVKA0LKtqUGNcjMZ7ehjl49mQ==",
|
"integrity": "sha512-dexTll8zqQoVJEZPwQAKzxxtFn0qTnjdQTchoU6Re9BUUGBJiOy3YMn/0ShTW6J5M0dfQ1NeDeRTTl4oIWgQMA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6.0.0"
|
"node": ">=6.0.0"
|
||||||
@@ -3994,9 +3921,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/rooibos-roku": {
|
"node_modules/rooibos-roku": {
|
||||||
"version": "5.10.0",
|
"version": "5.11.0",
|
||||||
"resolved": "https://registry.npmjs.org/rooibos-roku/-/rooibos-roku-5.10.0.tgz",
|
"resolved": "https://registry.npmjs.org/rooibos-roku/-/rooibos-roku-5.11.0.tgz",
|
||||||
"integrity": "sha512-Idiv3nWQOEr5V8z8oHcIovjcoBffgqRtTQ5B6K+x/cGAouKxyVJp0fsZ80xQvUul9IwHQ0XIPUYbNWCR3RQ3sA==",
|
"integrity": "sha512-qxTYwsyp6Ihb6B8tmFm+24DE/s2gMCxagvdABElGWgqL834M+kZtmwrQXvSrMkM+0gkmQfIDuw1M4v484gycYQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"source-map": "^0.7.3",
|
"source-map": "^0.7.3",
|
||||||
@@ -4110,9 +4037,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/semver": {
|
"node_modules/semver": {
|
||||||
"version": "7.5.4",
|
"version": "7.6.0",
|
||||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz",
|
"resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz",
|
||||||
"integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==",
|
"integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"lru-cache": "^6.0.0"
|
"lru-cache": "^6.0.0"
|
||||||
|
|||||||
+15
-12
@@ -1,30 +1,30 @@
|
|||||||
{
|
{
|
||||||
"name": "playlet",
|
"name": "playlet",
|
||||||
"version": "0.19.1",
|
"version": "0.20.0",
|
||||||
"description": "Unofficial Youtube client for Roku",
|
"description": "Unofficial YouTube client for Roku",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@rokucommunity/bslint": "^0.8.14",
|
"@rokucommunity/bslint": "^0.8.17",
|
||||||
"@types/crypto-js": "^4.2.1",
|
"@types/crypto-js": "^4.2.2",
|
||||||
"@types/fs-extra": "^11.0.4",
|
"@types/fs-extra": "^11.0.4",
|
||||||
"@types/node": "^20.11.0",
|
"@types/node": "^20.11.19",
|
||||||
"@types/xml2js": "^0.4.14",
|
"@types/xml2js": "^0.4.14",
|
||||||
"argparse": "^2.0.1",
|
"argparse": "^2.0.1",
|
||||||
"brighterscript": "0.65.16",
|
"brighterscript": "0.65.22",
|
||||||
"brighterscript-formatter": "^1.6.37",
|
"brighterscript-formatter": "^1.6.40",
|
||||||
"convert-svg-to-png": "^0.6.4",
|
"convert-svg-to-png": "^0.6.4",
|
||||||
"cross-fetch": "^4.0.0",
|
"cross-fetch": "^4.0.0",
|
||||||
"crypto-js": "^4.2.0",
|
"crypto-js": "^4.2.0",
|
||||||
"dotenv": "^16.3.1",
|
"dotenv": "^16.4.4",
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
"fs-extra": "^11.2.0",
|
"fs-extra": "^11.2.0",
|
||||||
"glob": "^10.3.10",
|
"glob": "^10.3.10",
|
||||||
"imap": "^0.8.19",
|
"imap": "^0.8.19",
|
||||||
"ip": "^1.1.8",
|
"ip": "^1.1.8",
|
||||||
"json5": "^2.2.3",
|
"json5": "^2.2.3",
|
||||||
"mailparser": "^3.6.6",
|
"mailparser": "^3.6.7",
|
||||||
"roku-deploy": "^3.11.2",
|
"roku-deploy": "^3.11.2",
|
||||||
"rooibos-roku": "^5.10.0",
|
"rooibos-roku": "^5.11.0",
|
||||||
"semver": "^7.5.4",
|
"semver": "^7.6.0",
|
||||||
"shelljs": "^0.8.5",
|
"shelljs": "^0.8.5",
|
||||||
"ts-node": "^10.9.2",
|
"ts-node": "^10.9.2",
|
||||||
"typescript": "^5.3.3",
|
"typescript": "^5.3.3",
|
||||||
@@ -65,6 +65,9 @@
|
|||||||
"generate-sponsorblock-config": "node tools/generate-sponsorblock-config.js",
|
"generate-sponsorblock-config": "node tools/generate-sponsorblock-config.js",
|
||||||
"update-rale-component": "cd tools/RALE && rm TrackerTask.xml && curl -o TrackerTask.zip https://devtools.web.roku.com/roku-advanced-layout-editor/app/TrackerTask.zip && unzip TrackerTask.zip && rm TrackerTask.zip",
|
"update-rale-component": "cd tools/RALE && rm TrackerTask.xml && curl -o TrackerTask.zip https://devtools.web.roku.com/roku-advanced-layout-editor/app/TrackerTask.zip && unzip TrackerTask.zip && rm TrackerTask.zip",
|
||||||
"postinstall": "cd playlet-lib && npm install && cd ../playlet-app && npm install && cd ../playlet-web && npm install",
|
"postinstall": "cd playlet-lib && npm install && cd ../playlet-app && npm install && cd ../playlet-web && npm install",
|
||||||
"update-deps": "npx npm-check-updates -u && cd playlet-app && npx npm-check-updates -u && cd ../playlet-lib && npx npm-check-updates -u && cd ../playlet-web && npx npm-check-updates -u"
|
"update-deps": "npx npm-check-updates -u && cd playlet-app && npx npm-check-updates -u && cd ../playlet-lib && npx npm-check-updates -u && cd ../playlet-web && npx npm-check-updates -u",
|
||||||
|
"registry:write": "node tools/registry.js --input registry.json",
|
||||||
|
"registry:read": "node tools/registry.js --output registry.json",
|
||||||
|
"registry:clear": "node tools/registry.js --clear"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "playlet-app",
|
"name": "playlet-app",
|
||||||
"version": "0.19.1",
|
"version": "0.20.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "playlet-app",
|
"name": "playlet-app",
|
||||||
"version": "0.19.1"
|
"version": "0.20.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "playlet-app",
|
"name": "playlet-app",
|
||||||
"version": "0.19.1",
|
"version": "0.20.0",
|
||||||
"description": "Unofficial Youtube client for Roku",
|
"description": "Unofficial YouTube client for Roku",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prebuild": "rm -rf build/playlet-app",
|
"prebuild": "rm -rf build/playlet-app",
|
||||||
"prebuild:dev": "npm run prebuild",
|
"prebuild:dev": "npm run prebuild",
|
||||||
|
|||||||
@@ -23,7 +23,12 @@ end function
|
|||||||
function GetPlayletLibUrls() as object
|
function GetPlayletLibUrls() as object
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
debug = { type: "debug", link: Manifest.ReadValue("playlet_lib_debug_url") }
|
debug = { type: "debug", link: Manifest.ReadValue("playlet_lib_debug_url") }
|
||||||
return [debug]
|
embedded = { type: "embedded", link: Manifest.ReadValue("playlet_lib_embedded_url") }
|
||||||
|
#if DEBUG_FALLBACK_TO_EMBEDDED
|
||||||
|
return [debug, embedded]
|
||||||
|
#else
|
||||||
|
return [debug]
|
||||||
|
#end if
|
||||||
#else
|
#else
|
||||||
savedUrls = Registry.GetPlayletLibUrlsFromRegistry()
|
savedUrls = Registry.GetPlayletLibUrlsFromRegistry()
|
||||||
if savedUrls <> invalid
|
if savedUrls <> invalid
|
||||||
@@ -109,5 +114,5 @@ function ShowPlayletLibLoadErrorDialog()
|
|||||||
"If the problem persist, contact Playlet authors."
|
"If the problem persist, contact Playlet authors."
|
||||||
]
|
]
|
||||||
|
|
||||||
Dialog.ShowError(message, bulletText, bottomText)
|
DialogShowError(message, bulletText, bottomText)
|
||||||
end function
|
end function
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 76 KiB |
Binary file not shown.
@@ -2,8 +2,8 @@ title=Playlet
|
|||||||
|
|
||||||
# Do not update version manually, it is auto updated from package.json
|
# Do not update version manually, it is auto updated from package.json
|
||||||
major_version=0
|
major_version=0
|
||||||
minor_version=19
|
minor_version=20
|
||||||
build_version=00001
|
build_version=00000
|
||||||
|
|
||||||
ui_resolutions=hd
|
ui_resolutions=hd
|
||||||
|
|
||||||
@@ -33,4 +33,4 @@ playlet_lib_debug_url=http://DEBUG_HOST_IP_ADDRESS:8086/playlet-lib.zip
|
|||||||
|
|
||||||
git_commit_sha=unknown
|
git_commit_sha=unknown
|
||||||
|
|
||||||
bs_const=DEBUG=false
|
bs_const=DEBUG=false;DEBUG_FALLBACK_TO_EMBEDDED=true
|
||||||
@@ -1,45 +1,38 @@
|
|||||||
namespace Dialog
|
function DialogShowError(message as object, bulletText as object, bottomMessage as object)
|
||||||
|
' Note: dialog can be null since StandardMessageDialog is only available on 10.0 and later
|
||||||
|
msgDialog = CreateObject("roSGNode", "StandardMessageDialog")
|
||||||
|
DialogSetPalette(msgDialog)
|
||||||
|
msgDialog.message = message
|
||||||
|
msgDialog.bulletText = bulletText
|
||||||
|
msgDialog.bottomMessage = bottomMessage
|
||||||
|
msgDialog.title = "Error loading Playlet"
|
||||||
|
msgDialog.buttons = ["Exit"]
|
||||||
|
|
||||||
function ShowError(message as object, bulletText as object, bottomMessage as object)
|
' bs:disable-next-line NO_OBSERVE_STRING_CALLBACK
|
||||||
' Note: dialog can be null since StandardMessageDialog is only available on 10.0 and later
|
msgDialog.observeField("buttonSelected", "DialogOnButtonSelected")
|
||||||
msgDialog = CreateObject("roSGNode", "StandardMessageDialog")
|
' bs:disable-next-line NO_OBSERVE_STRING_CALLBACK
|
||||||
SetPalette(msgDialog)
|
msgDialog.observeField("wasClosed", "DialogOnClosed")
|
||||||
msgDialog.message = message
|
|
||||||
msgDialog.bulletText = bulletText
|
|
||||||
msgDialog.bottomMessage = bottomMessage
|
|
||||||
msgDialog.title = "Error loading Playlet"
|
|
||||||
msgDialog.buttons = ["Exit"]
|
|
||||||
|
|
||||||
' bs:disable-next-line NO_OBSERVE_STRING_CALLBACK
|
m.top.getScene().dialog = msgDialog
|
||||||
msgDialog.observeField("buttonSelected", "OnButtonSelected")
|
end function
|
||||||
' bs:disable-next-line NO_OBSERVE_STRING_CALLBACK
|
|
||||||
msgDialog.observeField("wasClosed", "OnDialogClosed")
|
|
||||||
|
|
||||||
m.top.getScene().dialog = msgDialog
|
function DialogSetPalette(msgDialog as object)
|
||||||
end function
|
palette = createObject("roSGNode", "RSGPalette")
|
||||||
|
palette.colors = {
|
||||||
|
DialogBackgroundColor: "#242424FF"
|
||||||
|
DialogFocusColor: "#CECECEFF"
|
||||||
|
DialogFocusItemColor: "#202020FF"
|
||||||
|
DialogSecondaryTextColor: "#DBDBDBFF"
|
||||||
|
DialogSecondaryItemColor: "#FF1C30FF"
|
||||||
|
DialogTextColor: "#DBDBDBFF"
|
||||||
|
}
|
||||||
|
msgDialog.palette = palette
|
||||||
|
end function
|
||||||
|
|
||||||
function SetPalette(msgDialog as object)
|
function DialogOnButtonSelected()
|
||||||
palette = createObject("roSGNode", "RSGPalette")
|
m.top.getScene().dialog.close = true
|
||||||
palette.colors = {
|
end function
|
||||||
DialogBackgroundColor: "#242424FF"
|
|
||||||
DialogFocusColor: "#CECECEFF"
|
|
||||||
DialogFocusItemColor: "#202020FF"
|
|
||||||
DialogSecondaryTextColor: "#DBDBDBFF"
|
|
||||||
DialogSecondaryItemColor: "#FF1C30FF"
|
|
||||||
DialogTextColor: "#DBDBDBFF"
|
|
||||||
}
|
|
||||||
msgDialog.palette = palette
|
|
||||||
end function
|
|
||||||
|
|
||||||
function OnButtonSelected()
|
|
||||||
m.top.getScene().dialog.close = true
|
|
||||||
end function
|
|
||||||
|
|
||||||
function OnDialogClosed()
|
|
||||||
' TODO:P1 throw an exception to cause a crash report to be generated
|
|
||||||
' Should include which playlet lib failed to load
|
|
||||||
m.top.getScene().exitChannel = true
|
|
||||||
end function
|
|
||||||
|
|
||||||
end namespace
|
|
||||||
|
|
||||||
|
function DialogOnClosed()
|
||||||
|
m.top.getScene().exitChannel = true
|
||||||
|
end function
|
||||||
@@ -33,9 +33,9 @@ function Main(args as object) as void
|
|||||||
' These vars are needed to pass certification.
|
' These vars are needed to pass certification.
|
||||||
' The actual work is done in Playlet Lib
|
' The actual work is done in Playlet Lib
|
||||||
' bs:disable-next-line LINT1005
|
' bs:disable-next-line LINT1005
|
||||||
contentId = args.contentId
|
_contentId = args.contentId
|
||||||
' bs:disable-next-line LINT1005
|
' bs:disable-next-line LINT1005
|
||||||
mediaType = args.mediaType
|
_mediaType = args.mediaType
|
||||||
|
|
||||||
' Do not signal app launch complete here, we're doing it over at Playlet Lib
|
' Do not signal app launch complete here, we're doing it over at Playlet Lib
|
||||||
' This is needed to pass cetification
|
' This is needed to pass cetification
|
||||||
@@ -45,7 +45,7 @@ function Main(args as object) as void
|
|||||||
input = CreateObject("roInput")
|
input = CreateObject("roInput")
|
||||||
input.setMessagePort(port)
|
input.setMessagePort(port)
|
||||||
|
|
||||||
' TODO:P1 follow up on bug where roSystemLog does not fire for a video player in ComponentLibrary
|
' TODO:P2 follow up on bug where roSystemLog does not fire for a video player in ComponentLibrary
|
||||||
' https://community.roku.com/t5/Roku-Developer-Program/BUG-roSystemLog-not-firing-with-ComponentLibrary/td-p/906075
|
' https://community.roku.com/t5/Roku-Developer-Program/BUG-roSystemLog-not-firing-with-ComponentLibrary/td-p/906075
|
||||||
systemLog = CreateObject("roSystemLog")
|
systemLog = CreateObject("roSystemLog")
|
||||||
systemLog.SetMessagePort(port)
|
systemLog.SetMessagePort(port)
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "playlet-lib",
|
"name": "playlet-lib",
|
||||||
"version": "0.19.1",
|
"version": "0.20.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "playlet-lib",
|
"name": "playlet-lib",
|
||||||
"version": "0.19.1"
|
"version": "0.20.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "playlet-lib",
|
"name": "playlet-lib",
|
||||||
"version": "0.19.1",
|
"version": "0.20.0",
|
||||||
"description": "Unofficial Youtube client for Roku",
|
"description": "Unofficial YouTube client for Roku",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prebuild": "rm -rf build/playlet-lib",
|
"prebuild": "rm -rf build/playlet-lib",
|
||||||
"prebuild:dev": "npm run prebuild",
|
"prebuild:dev": "npm run prebuild",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import "pkg:/components/Dialog/DialogUtils.bs"
|
import "pkg:/components/Dialog/DialogUtils.bs"
|
||||||
import "pkg:/components/Navigation/LongPress.bs"
|
import "pkg:/components/Navigation/LongPress.bs"
|
||||||
import "pkg:/components/PlayQueue/PlayQueueViewUtils.bs"
|
import "pkg:/components/VideoQueue/VideoQueueUtils.bs"
|
||||||
import "pkg:/components/VideoPlayer/VideoUtils.bs"
|
import "pkg:/components/VideoQueue/VideoQueueViewUtils.bs"
|
||||||
import "pkg:/source/utils/FocusManagement.bs"
|
import "pkg:/source/utils/FocusManagement.bs"
|
||||||
import "pkg:/source/utils/Logging.bs"
|
import "pkg:/source/utils/Logging.bs"
|
||||||
import "pkg:/source/utils/StringUtils.bs"
|
import "pkg:/source/utils/StringUtils.bs"
|
||||||
@@ -86,13 +86,13 @@ function onKeyEvent(key as string, press as boolean) as boolean
|
|||||||
end if
|
end if
|
||||||
|
|
||||||
if key = OPTIONS_LONG_PRESS_KEY and press
|
if key = OPTIONS_LONG_PRESS_KEY and press
|
||||||
LogInfo("Opening PlayQueueView")
|
LogInfo("Opening VideoQueueView")
|
||||||
PlayQueueViewUtils.Open(m.top.playQueue, m.top)
|
VideoQueueViewUtils.Open(m.top.videoQueue, m.top)
|
||||||
return true
|
return true
|
||||||
end if
|
end if
|
||||||
|
|
||||||
if key = "options" and not press
|
if key = "options" and not press
|
||||||
if VideoUtils.ToggleVideoPictureInPicture()
|
if VideoQueueUtils.ToggleVideoPictureInPicture(m.top.videoQueue)
|
||||||
return true
|
return true
|
||||||
end if
|
end if
|
||||||
end if
|
end if
|
||||||
@@ -102,26 +102,26 @@ function onKeyEvent(key as string, press as boolean) as boolean
|
|||||||
end if
|
end if
|
||||||
|
|
||||||
if key = "play"
|
if key = "play"
|
||||||
if VideoUtils.TogglePause()
|
if VideoQueueUtils.TogglePause(m.top.videoQueue)
|
||||||
return true
|
return true
|
||||||
end if
|
end if
|
||||||
end if
|
end if
|
||||||
|
|
||||||
if key = "pause"
|
if key = "pause"
|
||||||
if VideoUtils.PauseVideo()
|
if VideoQueueUtils.Pause(m.top.videoQueue)
|
||||||
return true
|
return true
|
||||||
end if
|
end if
|
||||||
end if
|
end if
|
||||||
|
|
||||||
if key = "playonly"
|
if key = "playonly"
|
||||||
if VideoUtils.ResumeVideo()
|
if VideoQueueUtils.Play(m.top.videoQueue)
|
||||||
return true
|
return true
|
||||||
end if
|
end if
|
||||||
end if
|
end if
|
||||||
|
|
||||||
if key = "back"
|
if key = "back"
|
||||||
if VideoUtils.IsVideoPlayerOpen() and not VideoUtils.IsVideoPlayerFullScreen()
|
if VideoQueueUtils.IsVideoPlayerOpen(m.top.videoQueue) and not VideoQueueUtils.IsVideoPlayerFullScreen(m.top.videoQueue)
|
||||||
if VideoUtils.ToggleVideoPictureInPicture()
|
if VideoQueueUtils.ToggleVideoPictureInPicture(m.top.videoQueue)
|
||||||
return true
|
return true
|
||||||
end if
|
end if
|
||||||
end if
|
end if
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<interface>
|
<interface>
|
||||||
<field id="root" type="node" />
|
<field id="root" type="node" />
|
||||||
<field id="stack" type="node" />
|
<field id="stack" type="node" />
|
||||||
<field id="playQueue" type="node" />
|
<field id="videoQueue" type="node" />
|
||||||
<function name="PushScreen" />
|
<function name="PushScreen" />
|
||||||
<function name="PopScreen" />
|
<function name="PopScreen" />
|
||||||
<function name="FocusTopScreen" />
|
<function name="FocusTopScreen" />
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
translation="[115,20]"
|
translation="[115,20]"
|
||||||
width="104"
|
width="104"
|
||||||
height="104"
|
height="104"
|
||||||
uri="pkg:/images/circle-mask-500.png">
|
uri="pkg:/images/white-circle.png">
|
||||||
|
|
||||||
<CirclePoster
|
<CirclePoster
|
||||||
id="thumbnail"
|
id="thumbnail"
|
||||||
|
|||||||
@@ -10,13 +10,13 @@
|
|||||||
<field id="failedBitmapUri" type="uri" alias="Poster.failedBitmapUri" />
|
<field id="failedBitmapUri" type="uri" alias="Poster.failedBitmapUri" />
|
||||||
<field id="loadStatus" type="string" alias="Poster.loadStatus" />
|
<field id="loadStatus" type="string" alias="Poster.loadStatus" />
|
||||||
|
|
||||||
<field id="maskUri" type="uri" value="pkg:/images/circle-mask-500.png" alias="MaskGroup.maskuri" />
|
<field id="maskUri" type="uri" value="pkg:/images/white-circle.png" alias="MaskGroup.maskuri" />
|
||||||
<field id="maskSize" type="vector2d" alias="MaskGroup.maskSize" />
|
<field id="maskSize" type="vector2d" alias="MaskGroup.maskSize" />
|
||||||
</interface>
|
</interface>
|
||||||
<children>
|
<children>
|
||||||
<MaskGroup
|
<MaskGroup
|
||||||
id="MaskGroup"
|
id="MaskGroup"
|
||||||
maskuri="pkg:/images/circle-mask-500.png">
|
maskuri="pkg:/images/white-circle.png">
|
||||||
<Poster
|
<Poster
|
||||||
id="Poster" />
|
id="Poster" />
|
||||||
</MaskGroup>
|
</MaskGroup>
|
||||||
|
|||||||
@@ -5,9 +5,6 @@ import "pkg:/source/AsyncTask/Tasks.bs"
|
|||||||
import "pkg:/source/utils/ErrorUtils.bs"
|
import "pkg:/source/utils/ErrorUtils.bs"
|
||||||
import "pkg:/source/utils/Logging.bs"
|
import "pkg:/source/utils/Logging.bs"
|
||||||
|
|
||||||
function Init()
|
|
||||||
end function
|
|
||||||
|
|
||||||
function LoadChannel(invidiousNode as object) as void
|
function LoadChannel(invidiousNode as object) as void
|
||||||
if m.contentTask <> invalid
|
if m.contentTask <> invalid
|
||||||
m.contentTask.cancel = true
|
m.contentTask.cancel = true
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
import "pkg:/components/Dialog/DialogUtils.bs"
|
||||||
|
import "pkg:/components/VideoFeed/FeedLoadState.bs"
|
||||||
|
import "pkg:/source/AsyncTask/AsyncTask.bs"
|
||||||
|
import "pkg:/source/AsyncTask/Tasks.bs"
|
||||||
|
import "pkg:/source/utils/ErrorUtils.bs"
|
||||||
|
import "pkg:/source/utils/Logging.bs"
|
||||||
|
|
||||||
|
function LoadPlaylistPage(invidiousNode as object) as void
|
||||||
|
LoadPlaylist(invidiousNode, true)
|
||||||
|
end function
|
||||||
|
|
||||||
|
function LoadPlaylistAll(invidiousNode as object) as void
|
||||||
|
LoadPlaylist(invidiousNode, false)
|
||||||
|
end function
|
||||||
|
|
||||||
|
function LoadPlaylist(invidiousNode as object, singlePage as boolean) as void
|
||||||
|
if m.contentTask <> invalid
|
||||||
|
m.contentTask.cancel = true
|
||||||
|
end if
|
||||||
|
|
||||||
|
loadState = m.top.loadState
|
||||||
|
if loadState = FeedLoadState.Loading or loadState = FeedLoadState.Loaded
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
m.top.loadState = FeedLoadState.Loading
|
||||||
|
m.contentTask = AsyncTask.Start(Tasks.PlaylistContentTask, {
|
||||||
|
content: m.top
|
||||||
|
invidious: invidiousNode
|
||||||
|
singlePage: singlePage
|
||||||
|
}, OnPlaylistContentTaskResult)
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnPlaylistContentTaskResult(output as object) as void
|
||||||
|
m.contentTask = invalid
|
||||||
|
|
||||||
|
if output.cancelled
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
if not output.success or not output.result.success
|
||||||
|
' output.error for unhandled exception
|
||||||
|
error = output.error
|
||||||
|
if error = invalid
|
||||||
|
' output.result.error for network errors
|
||||||
|
error = output.result.error
|
||||||
|
end if
|
||||||
|
error = ErrorUtils.Format(error)
|
||||||
|
LogError(error)
|
||||||
|
playlistId = output.task.input.content.playlistId
|
||||||
|
message = `Failed to load playlist ${playlistId}\n${error}`
|
||||||
|
DialogUtils.ShowDialog(message, "Playlist load fail", true)
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
end function
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
<component name="PlaylistContentNode" extends="ContentNode">
|
<component name="PlaylistContentNode" extends="ContentNode">
|
||||||
<interface>
|
<interface>
|
||||||
|
<function name="LoadPlaylistPage" />
|
||||||
|
<function name="LoadPlaylistAll" />
|
||||||
|
|
||||||
<field id="type" type="string" value="playlist" />
|
<field id="type" type="string" value="playlist" />
|
||||||
<field id="loadState" type="string" />
|
<field id="loadState" type="string" />
|
||||||
<!-- index in a feed -->
|
<!-- index in a feed -->
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
import "pkg:/components/Services/Invidious/InvidiousService.bs"
|
||||||
|
import "pkg:/components/Services/Invidious/InvidiousToContentNode.bs"
|
||||||
|
import "pkg:/components/VideoFeed/FeedLoadState.bs"
|
||||||
|
|
||||||
|
@asynctask
|
||||||
|
function PlaylistContentTask(input as object) as object
|
||||||
|
contentNode = input.content
|
||||||
|
invidiousNode = input.invidious
|
||||||
|
singlePage = input.singlePage
|
||||||
|
|
||||||
|
if m.top.cancel
|
||||||
|
contentNode.loadState = FeedLoadState.None
|
||||||
|
return invalid
|
||||||
|
end if
|
||||||
|
|
||||||
|
service = new Invidious.InvidiousService(invidiousNode)
|
||||||
|
instance = service.GetInstance()
|
||||||
|
|
||||||
|
while true
|
||||||
|
index = contentNode.getChildCount()
|
||||||
|
response = service.GetPlaylist(contentNode.playlistId, index, m.top.cancellation)
|
||||||
|
|
||||||
|
if m.top.cancel
|
||||||
|
contentNode.loadState = FeedLoadState.None
|
||||||
|
return invalid
|
||||||
|
end if
|
||||||
|
|
||||||
|
metadata = response.Json()
|
||||||
|
|
||||||
|
if not response.IsSuccess() or metadata = invalid
|
||||||
|
contentNode.loadState = FeedLoadState.Error
|
||||||
|
return {
|
||||||
|
success: false
|
||||||
|
error: response.ErrorMessage()
|
||||||
|
}
|
||||||
|
end if
|
||||||
|
|
||||||
|
InvidiousContent.ToPlaylistContentNode(contentNode, metadata, instance)
|
||||||
|
childCount = contentNode.getChildCount()
|
||||||
|
|
||||||
|
if metadata.videos.Count() = 0 or childCount >= metadata.videoCount
|
||||||
|
contentNode.loadState = FeedLoadState.Loaded
|
||||||
|
return {
|
||||||
|
success: true
|
||||||
|
}
|
||||||
|
else
|
||||||
|
contentNode.loadState = FeedLoadState.LoadedPage
|
||||||
|
if singlePage
|
||||||
|
return {
|
||||||
|
success: true
|
||||||
|
}
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
end while
|
||||||
|
|
||||||
|
return invalid
|
||||||
|
end function
|
||||||
@@ -5,8 +5,11 @@
|
|||||||
<field id="index" type="integer" value="-1" />
|
<field id="index" type="integer" value="-1" />
|
||||||
<!-- index in a feed -->
|
<!-- index in a feed -->
|
||||||
<field id="feedSourcesIndex" type="integer" value="-1" />
|
<field id="feedSourcesIndex" type="integer" value="-1" />
|
||||||
|
<!-- index in the queue -->
|
||||||
|
<field id="queueIndex" type="integer" value="-1" />
|
||||||
|
|
||||||
<field id="author" type="string" />
|
<!-- NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation -->
|
||||||
|
<field id="_author" type="string" />
|
||||||
<field id="authorId" type="string" />
|
<field id="authorId" type="string" />
|
||||||
<field id="isUpcoming" type="boolean" />
|
<field id="isUpcoming" type="boolean" />
|
||||||
<field id="lengthSeconds" type="integer" />
|
<field id="lengthSeconds" type="integer" />
|
||||||
|
|||||||
@@ -163,6 +163,17 @@ function OnkeyEvent(key as string, press as boolean) as boolean
|
|||||||
Close()
|
Close()
|
||||||
return true
|
return true
|
||||||
end if
|
end if
|
||||||
|
|
||||||
|
if key = "up"
|
||||||
|
m.optionsList.jumpToItem = m.optionsList.content.getChildCount() - 1
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
|
||||||
|
if key = "down"
|
||||||
|
m.optionsList.jumpToItem = 0
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
|
||||||
return false
|
return false
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace ContextMenuUtils
|
|||||||
if item.type = "video"
|
if item.type = "video"
|
||||||
LogInfo("Opening context menu for video:", item.videoId)
|
LogInfo("Opening context menu for video:", item.videoId)
|
||||||
title = item.title
|
title = item.title
|
||||||
subtitle = item.author
|
subtitle = item._author
|
||||||
thumbnail = item.thumbnail
|
thumbnail = item.thumbnail
|
||||||
else if item.type = "playlist"
|
else if item.type = "playlist"
|
||||||
LogInfo("Opening context menu for playlist:", item.playlistId)
|
LogInfo("Opening context menu for playlist:", item.playlistId)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<StdDlgTitleArea primaryTitle="Login to Invidious" />
|
<StdDlgTitleArea primaryTitle="Login to Invidious" />
|
||||||
<StdDlgContentArea>
|
<StdDlgContentArea>
|
||||||
<StdDlgTextItem
|
<StdDlgTextItem
|
||||||
text="Login to Invidious in order to view Subscriptions, Playlists, and use the Watch history." />
|
text="Login to Invidious in order to view Subscriptions, Playlists, and use the Watch history.

Please note that an Invidious account is different from a YouTube account." />
|
||||||
</StdDlgContentArea>
|
</StdDlgContentArea>
|
||||||
<StdDlgButtonArea id="buttonArea">
|
<StdDlgButtonArea id="buttonArea">
|
||||||
<StdDlgButton text="OK" />
|
<StdDlgButton text="OK" />
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
import "pkg:/components/VideoPlayer/VideoUtils.bs"
|
|
||||||
import "pkg:/source/utils/Logging.bs"
|
import "pkg:/source/utils/Logging.bs"
|
||||||
import "pkg:/source/utils/StringUtils.bs"
|
import "pkg:/source/utils/StringUtils.bs"
|
||||||
import "pkg:/source/utils/Types.bs"
|
import "pkg:/source/utils/Types.bs"
|
||||||
|
|
||||||
function InitEcpArgs()
|
function InitEcpArgs()
|
||||||
m.playQueue = m.top.findNode("PlayQueue")
|
m.videoQueue = m.top.findNode("VideoQueue")
|
||||||
LaunchArgumentsReceived()
|
LaunchArgumentsReceived()
|
||||||
|
|
||||||
m.scene.ObserveField("inputArgs", FuncName(InputArgumentsReceived))
|
m.scene.ObserveField("inputArgs", FuncName(InputArgumentsReceived))
|
||||||
@@ -46,6 +45,6 @@ function ProcessArguments(args as object) as void
|
|||||||
if args.timestamp <> invalid
|
if args.timestamp <> invalid
|
||||||
node.timestamp = args.timestamp
|
node.timestamp = args.timestamp
|
||||||
end if
|
end if
|
||||||
m.playQueue@.Play(node, -1)
|
m.videoQueue.playVideo = node
|
||||||
end if
|
end if
|
||||||
end function
|
end function
|
||||||
@@ -15,7 +15,11 @@ function Init()
|
|||||||
|
|
||||||
m.port = port
|
m.port = port
|
||||||
|
|
||||||
StartLogger(m.top)
|
#if DEBUG
|
||||||
|
StartLogger(m.top, LogLevel.Debug)
|
||||||
|
#else
|
||||||
|
StartLogger(m.top, LogLevel.Info)
|
||||||
|
#end if
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function StartLogger(logger as object, logLevel = LogLevel.Info as LogLevel) as void
|
function StartLogger(logger as object, logLevel = LogLevel.Info as LogLevel) as void
|
||||||
|
|||||||
@@ -21,6 +21,12 @@ function MainSceneContainerChanged()
|
|||||||
end function
|
end function
|
||||||
|
|
||||||
function StartWebServer()
|
function StartWebServer()
|
||||||
|
m.loungeService = m.top.findNode("LoungeService")
|
||||||
|
m.loungeService@.StartService()
|
||||||
|
|
||||||
m.webServer = m.top.findNode("WebServer")
|
m.webServer = m.top.findNode("WebServer")
|
||||||
m.webServer@.StartServer()
|
m.webServer@.StartServer()
|
||||||
|
|
||||||
|
m.dialServer = m.top.findNode("DialServer")
|
||||||
|
m.dialServer@.StartServer()
|
||||||
end function
|
end function
|
||||||
@@ -22,6 +22,11 @@ function MainSceneContainerChanged()
|
|||||||
end function
|
end function
|
||||||
|
|
||||||
function StartWebServer()
|
function StartWebServer()
|
||||||
|
m.loungeService = m.top.findNode("LoungeService")
|
||||||
|
m.loungeService.callfunc("StartService", invalid)
|
||||||
m.webServer = m.top.findNode("WebServer")
|
m.webServer = m.top.findNode("WebServer")
|
||||||
m.webServer.callfunc("StartServer", invalid)
|
m.webServer.callfunc("StartServer", invalid)
|
||||||
end function'//# sourceMappingURL=./MainScene.bs.map
|
m.dialServer = m.top.findNode("DialServer")
|
||||||
|
m.dialServer.callfunc("StartServer", invalid)
|
||||||
|
end function
|
||||||
|
'//# sourceMappingURL=./MainScene.brs.map
|
||||||
@@ -8,6 +8,7 @@
|
|||||||
</interface>
|
</interface>
|
||||||
<script type="text/brightscript" uri="pkg:/components/parts/AutoBind/AutoBind.part.brs" />
|
<script type="text/brightscript" uri="pkg:/components/parts/AutoBind/AutoBind.part.brs" />
|
||||||
<script type="text/brightscript" uri="pkg:/components/MainScene_bindings.brs" />
|
<script type="text/brightscript" uri="pkg:/components/MainScene_bindings.brs" />
|
||||||
|
<script type="text/brightscript" uri="pkg:/source/utils/NodePathUtils.brs" />
|
||||||
<script type="text/brightscript" uri="pkg:/components/MainScene.brs" />
|
<script type="text/brightscript" uri="pkg:/components/MainScene.brs" />
|
||||||
<script type="text/brightscript" uri="pkg:/source/utils/LoadingScreen.brs" />
|
<script type="text/brightscript" uri="pkg:/source/utils/LoadingScreen.brs" />
|
||||||
<script type="text/brightscript" uri="pkg:/components/parts/AutoBind/OnNodeReadyNoOp.brs" />
|
<script type="text/brightscript" uri="pkg:/components/parts/AutoBind/OnNodeReadyNoOp.brs" />
|
||||||
@@ -15,9 +16,6 @@
|
|||||||
<script type="text/brightscript" uri="pkg:/source/utils/Types.brs" />
|
<script type="text/brightscript" uri="pkg:/source/utils/Types.brs" />
|
||||||
<script type="text/brightscript" uri="pkg:/source/utils/StringUtils.brs" />
|
<script type="text/brightscript" uri="pkg:/source/utils/StringUtils.brs" />
|
||||||
<script type="text/brightscript" uri="pkg:/source/utils/Logging.brs" />
|
<script type="text/brightscript" uri="pkg:/source/utils/Logging.brs" />
|
||||||
<script type="text/brightscript" uri="pkg:/components/VideoPlayer/VideoUtils.brs" />
|
|
||||||
<script type="text/brightscript" uri="pkg:/source/utils/FocusManagement.brs" />
|
|
||||||
<script type="text/brightscript" uri="pkg:/components/Dialog/DialogUtils.brs" />
|
|
||||||
<script type="text/brightscript" uri="pkg:/source/bslib.brs" />
|
<script type="text/brightscript" uri="pkg:/source/bslib.brs" />
|
||||||
<children>
|
<children>
|
||||||
<Logger id="Logger" />
|
<Logger id="Logger" />
|
||||||
@@ -30,7 +28,7 @@
|
|||||||
<NavBarItem screen="HomeScreen" text="Home" icon="pkg:/images/icons/home.png" />
|
<NavBarItem screen="HomeScreen" text="Home" icon="pkg:/images/icons/home.png" />
|
||||||
<NavBarItem screen="BookmarksScreen" text="Bookmarks" icon="pkg:/images/icons/star.png" />
|
<NavBarItem screen="BookmarksScreen" text="Bookmarks" icon="pkg:/images/icons/star.png" />
|
||||||
<NavBarItem screen="SettingsScreen" text="Settings" icon="pkg:/images/icons/settings.png" />
|
<NavBarItem screen="SettingsScreen" text="Settings" icon="pkg:/images/icons/settings.png" />
|
||||||
<NavBarItem screen="WebAppScreen" text="Web App" icon="pkg:/images/icons/phone.png" />
|
<NavBarItem screen="RemoteScreen" text="Remote" icon="pkg:/images/icons/phone.png" />
|
||||||
<NavBarItem screen="AppInfoScreen" text="Info" icon="pkg:/images/icons/info.png" />
|
<NavBarItem screen="AppInfoScreen" text="Info" icon="pkg:/images/icons/info.png" />
|
||||||
</ContentNode>
|
</ContentNode>
|
||||||
</NavBar>
|
</NavBar>
|
||||||
@@ -38,13 +36,15 @@
|
|||||||
</Group>
|
</Group>
|
||||||
<VideoContainer id="VideoContainer" />
|
<VideoContainer id="VideoContainer" />
|
||||||
<Group id="Notifications" />
|
<Group id="Notifications" />
|
||||||
<PlayQueue id="PlayQueue" />
|
<VideoQueue id="VideoQueue" />
|
||||||
<ApplicationInfo id="ApplicationInfo" />
|
<ApplicationInfo id="ApplicationInfo" />
|
||||||
<Preferences id="Preferences" />
|
<Preferences id="Preferences" />
|
||||||
<Bookmarks id="Bookmarks" />
|
<Bookmarks id="Bookmarks" />
|
||||||
<SearchHistory id="SearchHistory" />
|
<SearchHistory id="SearchHistory" />
|
||||||
<Invidious id="Invidious" />
|
<Invidious id="Invidious" />
|
||||||
<PlayletWebServer id="WebServer" port="8888" />
|
<PlayletWebServer id="WebServer" port="8888" />
|
||||||
|
<DialServer id="DialServer" />
|
||||||
|
<LoungeService id="LoungeService" />
|
||||||
</AppController>
|
</AppController>
|
||||||
</children>
|
</children>
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<AppController id="AppController"
|
<AppController id="AppController"
|
||||||
root="bind:./AppRoot"
|
root="bind:./AppRoot"
|
||||||
stack="bind:./Stack"
|
stack="bind:./Stack"
|
||||||
playQueue="bind:./PlayQueue">
|
videoQueue="bind:./VideoQueue">
|
||||||
<Group id="Stack">
|
<Group id="Stack">
|
||||||
<AppRoot id="AppRoot">
|
<AppRoot id="AppRoot">
|
||||||
<NavBar id="NavBar" focusIndex="1" appController="bind:/AppController">
|
<NavBar id="NavBar" focusIndex="1" appController="bind:/AppController">
|
||||||
@@ -31,8 +31,8 @@
|
|||||||
icon="pkg:/images/icons/settings.png">
|
icon="pkg:/images/icons/settings.png">
|
||||||
</NavBarItem>
|
</NavBarItem>
|
||||||
<NavBarItem
|
<NavBarItem
|
||||||
screen="WebAppScreen"
|
screen="RemoteScreen"
|
||||||
text="Web App"
|
text="Remote"
|
||||||
icon="pkg:/images/icons/phone.png">
|
icon="pkg:/images/icons/phone.png">
|
||||||
</NavBarItem>
|
</NavBarItem>
|
||||||
<NavBarItem
|
<NavBarItem
|
||||||
@@ -49,10 +49,14 @@
|
|||||||
<Group id="Notifications" />
|
<Group id="Notifications" />
|
||||||
|
|
||||||
<!-- No render nodes -->
|
<!-- No render nodes -->
|
||||||
<PlayQueue id="PlayQueue"
|
<VideoQueue id="VideoQueue"
|
||||||
|
appController="bind:/AppController"
|
||||||
|
videoContainer="bind:../VideoContainer"
|
||||||
invidious="bind:../Invidious"
|
invidious="bind:../Invidious"
|
||||||
notifications="bind:../Notifications"
|
notifications="bind:../Notifications"
|
||||||
preferences="bind:../Preferences" />
|
preferences="bind:../Preferences"
|
||||||
|
loungeService="bind:../LoungeService" />
|
||||||
|
|
||||||
<ApplicationInfo id="ApplicationInfo" />
|
<ApplicationInfo id="ApplicationInfo" />
|
||||||
<Preferences id="Preferences" />
|
<Preferences id="Preferences" />
|
||||||
<Bookmarks id="Bookmarks" />
|
<Bookmarks id="Bookmarks" />
|
||||||
@@ -64,15 +68,23 @@
|
|||||||
applicationInfo="bind:../ApplicationInfo"
|
applicationInfo="bind:../ApplicationInfo"
|
||||||
preferences="bind:../Preferences" />
|
preferences="bind:../Preferences" />
|
||||||
|
|
||||||
<PlayletWebServer
|
<!-- Tasks -->
|
||||||
id="WebServer"
|
<PlayletWebServer id="WebServer"
|
||||||
port="8888"
|
port="8888"
|
||||||
appController="bind:/AppController"
|
appController="bind:/AppController"
|
||||||
applicationInfo="bind:../ApplicationInfo"
|
applicationInfo="bind:../ApplicationInfo"
|
||||||
invidious="bind:../Invidious"
|
invidious="bind:../Invidious"
|
||||||
preferences="bind:../Preferences"
|
preferences="bind:../Preferences"
|
||||||
playQueue="bind:../PlayQueue"
|
videoQueue="bind:../VideoQueue"
|
||||||
bookmarks="bind:../Bookmarks" />
|
bookmarks="bind:../Bookmarks"
|
||||||
|
loungeService="bind:../LoungeService" />
|
||||||
|
<DialServer id="DialServer"
|
||||||
|
webServer="bind:../WebServer"
|
||||||
|
loungeService="bind:../LoungeService" />
|
||||||
|
<LoungeService id="LoungeService"
|
||||||
|
videoQueue="bind:../VideoQueue"
|
||||||
|
notifications="bind:../Notifications"
|
||||||
|
invidious="bind:../Invidious" />
|
||||||
</AppController>
|
</AppController>
|
||||||
</children>
|
</children>
|
||||||
</component>
|
</component>
|
||||||
@@ -8,15 +8,18 @@ function InitializeBindings()
|
|||||||
"AppController": {
|
"AppController": {
|
||||||
"root": "./AppRoot",
|
"root": "./AppRoot",
|
||||||
"stack": "./Stack",
|
"stack": "./Stack",
|
||||||
"playQueue": "./PlayQueue"
|
"videoQueue": "./VideoQueue"
|
||||||
},
|
},
|
||||||
"NavBar": {
|
"NavBar": {
|
||||||
"appController": "/AppController"
|
"appController": "/AppController"
|
||||||
},
|
},
|
||||||
"PlayQueue": {
|
"VideoQueue": {
|
||||||
|
"appController": "/AppController",
|
||||||
|
"videoContainer": "../VideoContainer",
|
||||||
"invidious": "../Invidious",
|
"invidious": "../Invidious",
|
||||||
"notifications": "../Notifications",
|
"notifications": "../Notifications",
|
||||||
"preferences": "../Preferences"
|
"preferences": "../Preferences",
|
||||||
|
"loungeService": "../LoungeService"
|
||||||
},
|
},
|
||||||
"SearchHistory": {
|
"SearchHistory": {
|
||||||
"preferences": "../Preferences"
|
"preferences": "../Preferences"
|
||||||
@@ -31,9 +34,20 @@ function InitializeBindings()
|
|||||||
"applicationInfo": "../ApplicationInfo",
|
"applicationInfo": "../ApplicationInfo",
|
||||||
"invidious": "../Invidious",
|
"invidious": "../Invidious",
|
||||||
"preferences": "../Preferences",
|
"preferences": "../Preferences",
|
||||||
"playQueue": "../PlayQueue",
|
"videoQueue": "../VideoQueue",
|
||||||
"bookmarks": "../Bookmarks"
|
"bookmarks": "../Bookmarks",
|
||||||
|
"loungeService": "../LoungeService"
|
||||||
|
},
|
||||||
|
"DialServer": {
|
||||||
|
"webServer": "../WebServer",
|
||||||
|
"loungeService": "../LoungeService"
|
||||||
|
},
|
||||||
|
"LoungeService": {
|
||||||
|
"videoQueue": "../VideoQueue",
|
||||||
|
"notifications": "../Notifications",
|
||||||
|
"invidious": "../Invidious"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end function'//# sourceMappingURL=./MainScene_bindings.bs.map
|
end function
|
||||||
|
'//# sourceMappingURL=./MainScene_bindings.brs.map
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
<component name="ContentNodeReference" extends="ContentNode">
|
|
||||||
<interface>
|
|
||||||
<field id="refNode" type="node" />
|
|
||||||
</interface>
|
|
||||||
</component>
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
' 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,240 +0,0 @@
|
|||||||
import "pkg:/components/Dialog/DialogUtils.bs"
|
|
||||||
import "pkg:/components/NodeByRef/NodeByRef.bs"
|
|
||||||
import "pkg:/components/PlayQueue/Notifications/PlayQueueNotificationUtils.bs"
|
|
||||||
import "pkg:/components/VideoFeed/FeedLoadState.bs"
|
|
||||||
import "pkg:/components/VideoPlayer/VideoUtils.bs"
|
|
||||||
import "pkg:/source/AsyncTask/AsyncTask.bs"
|
|
||||||
import "pkg:/source/AsyncTask/Tasks.bs"
|
|
||||||
import "pkg:/source/utils/ArrayUtils.bs"
|
|
||||||
import "pkg:/source/utils/ErrorUtils.bs"
|
|
||||||
import "pkg:/source/utils/Logging.bs"
|
|
||||||
import "pkg:/source/utils/RingBuffer.bs"
|
|
||||||
import "pkg:/source/utils/Types.bs"
|
|
||||||
|
|
||||||
' TODO:P1 prevent adding duplicates of the same video/playlist
|
|
||||||
function Init()
|
|
||||||
m.pendingLoadTasks = {}
|
|
||||||
m.content = m.top.findNode("Content")
|
|
||||||
m.top.content = m.content
|
|
||||||
m.content.addField("index", "integer", false)
|
|
||||||
m.content.index = m.top.index
|
|
||||||
' TODO:P2 use actual queue nodes instead of internal buffer
|
|
||||||
m.watchedVideos = new RingBuffer(100)
|
|
||||||
end function
|
|
||||||
|
|
||||||
function Play(node as object, playlistIndex as integer)
|
|
||||||
m.top.index += 1
|
|
||||||
m.top.playlistIndex = playlistIndex
|
|
||||||
|
|
||||||
node = WrapWithIndexField(node)
|
|
||||||
if m.top.index >= m.content.getChildCount()
|
|
||||||
m.content.appendChild(node)
|
|
||||||
m.top.index = m.content.getChildCount() - 1
|
|
||||||
else
|
|
||||||
m.content.insertChild(node, m.top.index)
|
|
||||||
end if
|
|
||||||
|
|
||||||
PlayItemAtCurrentIndex()
|
|
||||||
end function
|
|
||||||
|
|
||||||
function AddToQueue(node as object)
|
|
||||||
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
|
|
||||||
|
|
||||||
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 node in queueNodes
|
|
||||||
node = NodeByRef.Unwrap(node)
|
|
||||||
if node = invalid
|
|
||||||
continue for
|
|
||||||
end if
|
|
||||||
|
|
||||||
nodeType = node.type
|
|
||||||
if nodeType = "video"
|
|
||||||
items.push({
|
|
||||||
type: nodeType
|
|
||||||
videoId: node.videoId
|
|
||||||
title: node.title
|
|
||||||
author: node.author
|
|
||||||
thumbnail: node.thumbnail
|
|
||||||
})
|
|
||||||
else if node.type = "playlist"
|
|
||||||
items.push({
|
|
||||||
type: nodeType
|
|
||||||
playlistId: node.playlistId
|
|
||||||
title: node.title
|
|
||||||
thumbnail: node.thumbnail
|
|
||||||
videoCountText: node.videoCountText
|
|
||||||
})
|
|
||||||
end if
|
|
||||||
end for
|
|
||||||
|
|
||||||
return {
|
|
||||||
index: m.top.index
|
|
||||||
playlistIndex: m.top.playlistIndex
|
|
||||||
items: items
|
|
||||||
}
|
|
||||||
end function
|
|
||||||
|
|
||||||
function Clear(_unused as dynamic)
|
|
||||||
m.content.removeChildrenIndex(m.content.getChildCount(), 0)
|
|
||||||
m.top.index = -1
|
|
||||||
m.top.playlistIndex = -1
|
|
||||||
end function
|
|
||||||
|
|
||||||
function PlayNextItem(_unused as dynamic) as boolean
|
|
||||||
childCount = m.content.getChildCount()
|
|
||||||
if childCount = 0
|
|
||||||
return false
|
|
||||||
end if
|
|
||||||
|
|
||||||
index = m.top.index
|
|
||||||
if index <> -1
|
|
||||||
if index >= childCount
|
|
||||||
return false
|
|
||||||
end if
|
|
||||||
node = m.content.getChild(index)
|
|
||||||
node = NodeByRef.Unwrap(node)
|
|
||||||
if node.type = "playlist"
|
|
||||||
m.top.playlistIndex += 1
|
|
||||||
if PlayPlaylistAtCurrentIndex(node)
|
|
||||||
return true
|
|
||||||
end if
|
|
||||||
end if
|
|
||||||
end if
|
|
||||||
|
|
||||||
m.top.index += 1
|
|
||||||
m.top.playlistIndex = -1
|
|
||||||
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.content.getChild(m.top.index)
|
|
||||||
node = NodeByRef.Unwrap(node)
|
|
||||||
if node = invalid
|
|
||||||
return false
|
|
||||||
end if
|
|
||||||
if node.type = "video"
|
|
||||||
PlayVideo(node)
|
|
||||||
return true
|
|
||||||
else if node.type = "playlist"
|
|
||||||
if m.top.playlistIndex = -1
|
|
||||||
m.top.playlistIndex = 0
|
|
||||||
end if
|
|
||||||
return PlayPlaylistAtCurrentIndex(node)
|
|
||||||
end if
|
|
||||||
return false
|
|
||||||
end function
|
|
||||||
|
|
||||||
function PlayPlaylistAtCurrentIndex(playlist as object) as boolean
|
|
||||||
playlist = NodeByRef.Unwrap(playlist)
|
|
||||||
if playlist.videoCount < 0
|
|
||||||
LoadPlaylist(playlist)
|
|
||||||
return true
|
|
||||||
end if
|
|
||||||
playlistIndex = m.top.playlistIndex
|
|
||||||
if playlistIndex < 0 or playlistIndex >= playlist.videoCount
|
|
||||||
return false
|
|
||||||
end if
|
|
||||||
|
|
||||||
if playlistIndex < playlist.getChildCount()
|
|
||||||
child = playlist.getChild(playlistIndex)
|
|
||||||
PlayVideo(child)
|
|
||||||
return true
|
|
||||||
end if
|
|
||||||
|
|
||||||
LoadPlaylist(playlist)
|
|
||||||
return true
|
|
||||||
end function
|
|
||||||
|
|
||||||
function PlayVideo(node as object)
|
|
||||||
videoId = node.videoId
|
|
||||||
if not m.watchedVideos.Contains(videoId)
|
|
||||||
m.watchedVideos.Push(videoId)
|
|
||||||
end if
|
|
||||||
VideoUtils.PlayVideo(node)
|
|
||||||
end function
|
|
||||||
|
|
||||||
function LoadPlaylist(playlist as object) as void
|
|
||||||
if playlist.loadState = FeedLoadState.Loading
|
|
||||||
return
|
|
||||||
end if
|
|
||||||
|
|
||||||
playlist.loadState = FeedLoadState.Loading
|
|
||||||
|
|
||||||
task = AsyncTask.Start(Tasks.PlaylistContentTask, {
|
|
||||||
content: playlist
|
|
||||||
invidious: m.top.invidious
|
|
||||||
}, OnPlaylistContentTaskResult)
|
|
||||||
m.pendingLoadTasks[task.id] = task
|
|
||||||
end function
|
|
||||||
|
|
||||||
function OnPlaylistContentTaskResult(output as object) as void
|
|
||||||
m.pendingLoadTasks.Delete(output.task.id)
|
|
||||||
|
|
||||||
if output.cancelled
|
|
||||||
return
|
|
||||||
end if
|
|
||||||
|
|
||||||
playlist = output.task.input.content
|
|
||||||
if not output.success or not output.result.success
|
|
||||||
' output.error for unhandled exception
|
|
||||||
error = output.error
|
|
||||||
if error = invalid
|
|
||||||
' output.result.error for network errors
|
|
||||||
error = output.result.error
|
|
||||||
end if
|
|
||||||
error = ErrorUtils.Format(error)
|
|
||||||
LogError(error)
|
|
||||||
playlistId = playlist.playlistId
|
|
||||||
message = `Failed to load playlist ${playlistId}\n${error}`
|
|
||||||
' TODO:P1 play next upon closing the dialog
|
|
||||||
DialogUtils.ShowDialog(message, "Playlist load fail", true)
|
|
||||||
return
|
|
||||||
end if
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
function watchedVideosContain(videoId as string) as boolean
|
|
||||||
return m.watchedVideos.Contains(videoId)
|
|
||||||
end function
|
|
||||||
|
|
||||||
function watchedVideosClear(_unused as dynamic)
|
|
||||||
m.watchedVideos = new RingBuffer(100)
|
|
||||||
end function
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
<component name="PlayQueue" extends="Node">
|
|
||||||
<interface>
|
|
||||||
<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" />
|
|
||||||
<field id="preferences" type="node" />
|
|
||||||
<function name="Play" />
|
|
||||||
<function name="AddToQueue" />
|
|
||||||
<function name="GetQueue" />
|
|
||||||
<function name="Clear" />
|
|
||||||
<function name="PlayNextItem" />
|
|
||||||
<function name="PlayItemAtIndex" />
|
|
||||||
<function name="watchedVideosContain" />
|
|
||||||
<function name="watchedVideosClear" />
|
|
||||||
</interface>
|
|
||||||
<children>
|
|
||||||
<ContentNode id="Content" />
|
|
||||||
</children>
|
|
||||||
</component>
|
|
||||||
@@ -1,83 +0,0 @@
|
|||||||
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()
|
|
||||||
end function
|
|
||||||
|
|
||||||
function OnClearButtonSelected()
|
|
||||||
m.top.playQueue@.Clear()
|
|
||||||
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
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
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()
|
|
||||||
return playQueueView
|
|
||||||
end function
|
|
||||||
|
|
||||||
end namespace
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
import "pkg:/components/Services/Invidious/InvidiousService.bs"
|
|
||||||
import "pkg:/components/Services/Invidious/InvidiousToContentNode.bs"
|
|
||||||
|
|
||||||
' TODO:P1 this should only be called from PlaylistContentNode.bs
|
|
||||||
@asynctask
|
|
||||||
function PlaylistContentTask(input as object) as object
|
|
||||||
contentNode = input.content
|
|
||||||
invidiousNode = input.invidious
|
|
||||||
|
|
||||||
if m.top.cancel
|
|
||||||
contentNode.loadState = FeedLoadState.None
|
|
||||||
return invalid
|
|
||||||
end if
|
|
||||||
|
|
||||||
service = new Invidious.InvidiousService(invidiousNode)
|
|
||||||
|
|
||||||
index = contentNode.getChildCount()
|
|
||||||
response = service.GetPlaylist(contentNode.playlistId, index, m.top.cancellation)
|
|
||||||
|
|
||||||
if m.top.cancel
|
|
||||||
contentNode.loadState = FeedLoadState.None
|
|
||||||
return invalid
|
|
||||||
end if
|
|
||||||
|
|
||||||
metadata = response.Json()
|
|
||||||
|
|
||||||
if not response.IsSuccess() or metadata = invalid
|
|
||||||
contentNode.loadState = FeedLoadState.Error
|
|
||||||
return {
|
|
||||||
success: false
|
|
||||||
error: response.ErrorMessage()
|
|
||||||
}
|
|
||||||
end if
|
|
||||||
|
|
||||||
instance = service.GetInstance()
|
|
||||||
InvidiousContent.ToPlaylistContentNode(contentNode, metadata, instance)
|
|
||||||
|
|
||||||
childCount = contentNode.getChildCount()
|
|
||||||
if metadata.videos.Count() > 0 or childCount < metadata.videoCount
|
|
||||||
contentNode.loadState = FeedLoadState.LoadedPage
|
|
||||||
else
|
|
||||||
contentNode.loadState = FeedLoadState.Loaded
|
|
||||||
end if
|
|
||||||
|
|
||||||
return {
|
|
||||||
success: true
|
|
||||||
}
|
|
||||||
end function
|
|
||||||
@@ -4,7 +4,6 @@ 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"
|
||||||
import "pkg:/components/VideoPlayer/VideoUtils.bs"
|
|
||||||
import "pkg:/source/AsyncTask/AsyncTask.bs"
|
import "pkg:/source/AsyncTask/AsyncTask.bs"
|
||||||
import "pkg:/source/AsyncTask/Tasks.bs"
|
import "pkg:/source/AsyncTask/Tasks.bs"
|
||||||
import "pkg:/source/utils/ErrorUtils.bs"
|
import "pkg:/source/utils/ErrorUtils.bs"
|
||||||
@@ -117,7 +116,10 @@ function OnItemSelected(index as integer) as void
|
|||||||
videoId = video.videoId
|
videoId = video.videoId
|
||||||
if not StringUtils.IsNullOrEmpty(videoId)
|
if not StringUtils.IsNullOrEmpty(videoId)
|
||||||
LogInfo("Play playlist:", playlistId, "video:", videoId)
|
LogInfo("Play playlist:", playlistId, "video:", videoId)
|
||||||
m.playQueue@.Play(playlist, index)
|
m.videoQueue.playPlaylist = {
|
||||||
|
playlistNode: playlist
|
||||||
|
playlistIndex: index
|
||||||
|
}
|
||||||
end if
|
end if
|
||||||
end function
|
end function
|
||||||
|
|
||||||
@@ -165,10 +167,10 @@ function GetContextMenuOptionsForItem(video as object) as object
|
|||||||
end if
|
end if
|
||||||
|
|
||||||
options = [
|
options = [
|
||||||
ContextMenuUtils.CreateOption("Play", m.playQueue, "Play", [playlist, index]),
|
ContextMenuUtils.CreateOption("Play", m.videoQueue, "FuncPlayPlaylist", [playlist, index]),
|
||||||
ContextMenuUtils.CreateOption("Queue", m.playQueue, "AddToQueue", [playlist])
|
ContextMenuUtils.CreateOption("Queue", m.videoQueue, "FuncAddToQueuePlaylist", [playlist])
|
||||||
ContextMenuUtils.CreateOption("Play video", m.playQueue, "Play", [video, -1]),
|
ContextMenuUtils.CreateOption("Play video", m.videoQueue, "FuncPlayVideo", [video]),
|
||||||
ContextMenuUtils.CreateOption("Queue video", m.playQueue, "AddToQueue", [video]),
|
ContextMenuUtils.CreateOption("Queue video", m.videoQueue, "FuncAddToQueueVideo", [video]),
|
||||||
]
|
]
|
||||||
|
|
||||||
if not StringUtils.IsNullOrEmpty(playlist.authorId)
|
if not StringUtils.IsNullOrEmpty(playlist.authorId)
|
||||||
@@ -214,42 +216,5 @@ function LoadPlaylistIfNeeded() as void
|
|||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
|
|
||||||
LoadPlaylist()
|
m.top.content@.LoadPlaylistPage(m.top.invidious)
|
||||||
end function
|
|
||||||
|
|
||||||
function LoadPlaylist() as void
|
|
||||||
if m.playlistLoadTask <> invalid
|
|
||||||
m.playlistLoadTask.cancel = true
|
|
||||||
end if
|
|
||||||
|
|
||||||
m.top.content.loadState = FeedLoadState.Loading
|
|
||||||
m.playlistLoadTask = AsyncTask.Start(Tasks.PlaylistContentTask, {
|
|
||||||
content: m.top.content
|
|
||||||
invidious: m.top.invidious
|
|
||||||
}, OnPlaylistContentTaskResult)
|
|
||||||
end function
|
|
||||||
|
|
||||||
function OnPlaylistContentTaskResult(output as object) as void
|
|
||||||
m.playlistLoadTask = invalid
|
|
||||||
|
|
||||||
if output.cancelled
|
|
||||||
return
|
|
||||||
end if
|
|
||||||
|
|
||||||
if not output.success or not output.result.success
|
|
||||||
' output.error for unhandled exception
|
|
||||||
error = output.error
|
|
||||||
if error = invalid
|
|
||||||
' output.result.error for network errors
|
|
||||||
error = output.result.error
|
|
||||||
end if
|
|
||||||
error = ErrorUtils.Format(error)
|
|
||||||
LogError(error)
|
|
||||||
playlistId = output.task.input.content.playlistId
|
|
||||||
message = `Failed to load playlist ${playlistId}\n${error}`
|
|
||||||
DialogUtils.ShowDialog(message, "Playlist load fail", true)
|
|
||||||
return
|
|
||||||
end if
|
|
||||||
|
|
||||||
LoadPlaylistIfNeeded()
|
|
||||||
end function
|
end function
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
<field id="content" type="node" onChange="OnContentSet" />
|
<field id="content" type="node" onChange="OnContentSet" />
|
||||||
<field id="appController" type="node" bind="/AppController" />
|
<field id="appController" type="node" bind="/AppController" />
|
||||||
<field id="invidious" type="node" bind="/Invidious" />
|
<field id="invidious" type="node" bind="/Invidious" />
|
||||||
<field id="playQueue" type="node" bind="/PlayQueue" />
|
<field id="videoQueue" type="node" bind="/VideoQueue" />
|
||||||
<field id="bookmarks" type="node" bind="/Bookmarks" />
|
<field id="bookmarks" type="node" bind="/Bookmarks" />
|
||||||
<function name="OpenPlaylistChannel" />
|
<function name="OpenPlaylistChannel" />
|
||||||
</interface>
|
</interface>
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ function OnContentSet() as void
|
|||||||
end if
|
end if
|
||||||
|
|
||||||
m.top.title = content.title
|
m.top.title = content.title
|
||||||
m.top.author = content.author
|
' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
|
||||||
|
m.top.author = content._author
|
||||||
m.top.thumbnailUri = content.thumbnail
|
m.top.thumbnailUri = content.thumbnail
|
||||||
|
|
||||||
if ValidInt(content.lengthSeconds) <> 0
|
if ValidInt(content.lengthSeconds) <> 0
|
||||||
|
|||||||
File renamed without changes.
@@ -0,0 +1,196 @@
|
|||||||
|
import "pkg:/components/Dialog/DialogUtils.bs"
|
||||||
|
import "pkg:/components/Navigation/Navigation.bs"
|
||||||
|
import "pkg:/source/AsyncTask/AsyncTask.bs"
|
||||||
|
import "pkg:/source/AsyncTask/AsyncTask.bs"
|
||||||
|
import "pkg:/source/AsyncTask/Tasks.bs"
|
||||||
|
import "pkg:/source/AsyncTask/Tasks.bs"
|
||||||
|
import "pkg:/source/utils/ErrorUtils.bs"
|
||||||
|
import "pkg:/source/utils/FocusManagement.bs"
|
||||||
|
import "pkg:/source/utils/Logging.bs"
|
||||||
|
import "pkg:/source/utils/StringUtils.bs"
|
||||||
|
|
||||||
|
function Init()
|
||||||
|
m.webAppButton = m.top.findNode("WebAppButton")
|
||||||
|
m.linkWithWifiButton = m.top.findNode("LinkWithWiFiButton")
|
||||||
|
m.linkWithTvButton = m.top.findNode("LinkWithTvButton")
|
||||||
|
|
||||||
|
m.webAppPanel = m.top.findNode("WebAppPanel")
|
||||||
|
m.linkWithWifiPanel = m.top.findNode("LinkWithWiFiPanel")
|
||||||
|
m.linkWithTvPanel = m.top.findNode("LinkWithTvPanel")
|
||||||
|
|
||||||
|
m.wifiNameLabel = m.top.findNode("WifiNameLabel")
|
||||||
|
m.linkCodeLabel = m.top.findNode("LinkCodeLabel")
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnNodeReady()
|
||||||
|
SetNavigation(m.webAppButton, "down", m.linkWithWifiButton)
|
||||||
|
SetNavigation(m.linkWithWifiButton, "down", m.linkWithTvButton)
|
||||||
|
SetNavigation(m.linkWithTvButton, "up", m.linkWithWifiButton)
|
||||||
|
SetNavigation(m.linkWithWifiButton, "up", m.webAppButton)
|
||||||
|
|
||||||
|
SetNavigation(invalid, "back", m.navBar)
|
||||||
|
SetNavigation(invalid, "left", m.navBar)
|
||||||
|
|
||||||
|
address = m.webserver@.GetServerAddress()
|
||||||
|
isValidAddress = not StringUtils.IsNullOrEmpty(address)
|
||||||
|
if isValidAddress
|
||||||
|
m.top.url = address
|
||||||
|
end if
|
||||||
|
m.top.findNode("noInternet").visible = not isValidAddress
|
||||||
|
m.top.findNode("yesInternet").visible = isValidAddress
|
||||||
|
m.top.focusable = isValidAddress
|
||||||
|
|
||||||
|
m.top.observeField("visible", FuncName(OnVisibleChanged))
|
||||||
|
|
||||||
|
m.linkWithWifiPanel.observeField("visible", FuncName(OnLinkWithWifiPanelVisibleChanged))
|
||||||
|
m.linkWithWifiPanel.visible = false
|
||||||
|
m.linkWithTvPanel.observeField("visible", FuncName(OnLinkWithTvPanelVisibleChanged))
|
||||||
|
m.linkWithTvPanel.visible = false
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnFocusChange() as void
|
||||||
|
if not m.top.focus
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
if m.currentNavigtionNode = invalid
|
||||||
|
m.currentNavigtionNode = m.webAppButton
|
||||||
|
end if
|
||||||
|
|
||||||
|
NodeSetFocus(m.currentNavigtionNode, true)
|
||||||
|
ShowTab(m.currentNavigtionNode)
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnUrlSet()
|
||||||
|
url = m.top.url
|
||||||
|
|
||||||
|
urlLabel = m.top.findNode("urlLabel")
|
||||||
|
urlLabel.text = url
|
||||||
|
|
||||||
|
qrCodePoster = m.top.findNode("QrCodePoster")
|
||||||
|
AsyncTask.Start(Tasks.GenerateQrCodeTask, {
|
||||||
|
poster: qrCodePoster
|
||||||
|
text: url
|
||||||
|
size: qrCodePoster.loadWidth
|
||||||
|
padding: 20
|
||||||
|
})
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnkeyEvent(key as string, press as boolean) as boolean
|
||||||
|
navigation = NavigationKeyHandler(key, press)
|
||||||
|
if navigation.handled
|
||||||
|
ShowTab(navigation.node)
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
return false
|
||||||
|
end function
|
||||||
|
|
||||||
|
function ShowTab(button as object)
|
||||||
|
if button.isSameNode(m.webAppButton)
|
||||||
|
m.webAppPanel.visible = true
|
||||||
|
m.linkWithWifiPanel.visible = false
|
||||||
|
m.linkWithTvPanel.visible = false
|
||||||
|
m.currentNavigtionNode = button
|
||||||
|
else if button.isSameNode(m.linkWithWifiButton)
|
||||||
|
m.linkWithWifiPanel.visible = true
|
||||||
|
m.webAppPanel.visible = false
|
||||||
|
m.linkWithTvPanel.visible = false
|
||||||
|
m.currentNavigtionNode = button
|
||||||
|
else if button.isSameNode(m.linkWithTvButton)
|
||||||
|
m.linkWithTvPanel.visible = true
|
||||||
|
m.webAppPanel.visible = false
|
||||||
|
m.linkWithWifiPanel.visible = false
|
||||||
|
m.currentNavigtionNode = button
|
||||||
|
end if
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnVisibleChanged()
|
||||||
|
if not m.top.visible
|
||||||
|
m.currentNavigtionNode = invalid
|
||||||
|
m.webAppPanel.visible = true
|
||||||
|
m.linkWithWifiPanel.visible = false
|
||||||
|
m.linkWithTvPanel.visible = false
|
||||||
|
end if
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnLinkWithWifiPanelVisibleChanged() as void
|
||||||
|
if not m.linkWithWifiPanel.visible
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
deviceInfo = CreateObject("roDeviceInfo")
|
||||||
|
connectionInfo = deviceInfo.GetConnectionInfo()
|
||||||
|
|
||||||
|
if connectionInfo.type = "WiFiConnection"
|
||||||
|
m.wifiNameLabel.text = connectionInfo.ssid
|
||||||
|
else if connectionInfo.type = "WiredConnection"
|
||||||
|
m.wifiNameLabel.text = "Wired connection"
|
||||||
|
else
|
||||||
|
m.wifiNameLabel.text = "N/A"
|
||||||
|
end if
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnLinkWithTvPanelVisibleChanged()
|
||||||
|
if m.linkWithTvPanel.visible
|
||||||
|
GeneratePairingCode()
|
||||||
|
else
|
||||||
|
if m.linkCodeTask <> invalid
|
||||||
|
m.linkCodeTask.cancel = true
|
||||||
|
m.linkCodeTask = invalid
|
||||||
|
end if
|
||||||
|
m.linkCodeLabel.text = ""
|
||||||
|
end if
|
||||||
|
end function
|
||||||
|
|
||||||
|
function GeneratePairingCode()
|
||||||
|
if m.linkCodeTask <> invalid
|
||||||
|
m.linkCodeTask.cancel = true
|
||||||
|
end if
|
||||||
|
|
||||||
|
m.linkCodeTask = AsyncTask.Start(Tasks.LoungeGenerateManualPairingCodeTask, {
|
||||||
|
loungeService: m.loungeService
|
||||||
|
loungeToken: m.loungeService.loungeToken
|
||||||
|
screenId: m.loungeService.screenId
|
||||||
|
' Use deviceName as screenName
|
||||||
|
screenName: m.loungeService.deviceName
|
||||||
|
deviceId: m.loungeService.deviceId
|
||||||
|
}, OnLoungeGenerateManualPairingCodeTaskResult)
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnLoungeGenerateManualPairingCodeTaskResult(output as object) as void
|
||||||
|
m.linkCodeTask = invalid
|
||||||
|
|
||||||
|
if output.cancelled
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
if not output.success or not output.result.success
|
||||||
|
' output.error for unhandled exception
|
||||||
|
error = output.error
|
||||||
|
if error = invalid
|
||||||
|
' output.result.error for network errors
|
||||||
|
error = output.result.error
|
||||||
|
end if
|
||||||
|
error = ErrorUtils.Format(error)
|
||||||
|
LogError(error)
|
||||||
|
|
||||||
|
message = `Failed to generate manual pairing code\n${error}`
|
||||||
|
DialogUtils.ShowDialog(message, "Get TV code fail", true)
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
manualLinkCode = output.result.code
|
||||||
|
if StringUtils.IsNullOrEmpty(manualLinkCode)
|
||||||
|
m.linkCodeLabel.text = ""
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
' insert a space every 3 characters.
|
||||||
|
parts = []
|
||||||
|
for i = 0 to manualLinkCode.Len() - 1 step 3
|
||||||
|
parts.Push(manualLinkCode.Mid(i, 3))
|
||||||
|
end for
|
||||||
|
linkCode = parts.Join(" ")
|
||||||
|
|
||||||
|
m.linkCodeLabel.text = linkCode
|
||||||
|
end function
|
||||||
@@ -0,0 +1,159 @@
|
|||||||
|
<component name="RemoteScreen" extends="Group" includes="AutoBind,Focus">
|
||||||
|
<interface>
|
||||||
|
<field id="navBar" type="node" bind="/NavBar" />
|
||||||
|
<field id="webServer" type="node" bind="/WebServer" />
|
||||||
|
<field id="loungeService" type="node" bind="/LoungeService" />
|
||||||
|
<field id="url" type="string" onChange="OnUrlSet" />
|
||||||
|
<field id="qrCodeUrl" type="string" onChange="OnUrlSet" />
|
||||||
|
</interface>
|
||||||
|
<children>
|
||||||
|
<Group id="noInternet" visible="false">
|
||||||
|
<Label
|
||||||
|
height="720"
|
||||||
|
width="1280"
|
||||||
|
font="font:MediumBoldSystemFont"
|
||||||
|
horizAlign="center"
|
||||||
|
vertAlign="center"
|
||||||
|
text="Could not get IP address: are we connected to the internet?"
|
||||||
|
/>
|
||||||
|
</Group>
|
||||||
|
<Group id="yesInternet" visible="false">
|
||||||
|
<SettingCategory
|
||||||
|
id="WebAppButton"
|
||||||
|
displayText="Playlet Web App"
|
||||||
|
description="Use Playlet Remote in the browser"
|
||||||
|
minimumWidth="350"
|
||||||
|
translation="[150,178]" />
|
||||||
|
|
||||||
|
<SettingCategory
|
||||||
|
id="LinkWithWiFiButton"
|
||||||
|
displayText="Link with Wi-Fi"
|
||||||
|
description="Cast from the YouTube app to Playlet"
|
||||||
|
minimumWidth="350"
|
||||||
|
translation="[150,314]" />
|
||||||
|
|
||||||
|
<SettingCategory
|
||||||
|
id="LinkWithTvButton"
|
||||||
|
displayText="Link with TV code"
|
||||||
|
description="Cast from the YouTube app to Playlet"
|
||||||
|
minimumWidth="350"
|
||||||
|
translation="[150,450]" />
|
||||||
|
|
||||||
|
<Group id="WebAppPanel"
|
||||||
|
translation="[700,115]">
|
||||||
|
<Label
|
||||||
|
height="30"
|
||||||
|
width="400"
|
||||||
|
font="font:SmallBoldSystemFont"
|
||||||
|
horizAlign="center"
|
||||||
|
text="Scan the QR code" />
|
||||||
|
<Poster
|
||||||
|
id="QrCodePoster"
|
||||||
|
height="400"
|
||||||
|
width="400"
|
||||||
|
loadHeight="400"
|
||||||
|
loadWidth="400"
|
||||||
|
translation="[0,40]" />
|
||||||
|
<Label
|
||||||
|
id="UrlLabel"
|
||||||
|
height="30"
|
||||||
|
width="400"
|
||||||
|
font="font:SmallBoldSystemFont"
|
||||||
|
horizAlign="center"
|
||||||
|
translation="[0,460]" />
|
||||||
|
</Group>
|
||||||
|
|
||||||
|
<Group id="LinkWithWiFiPanel"
|
||||||
|
translation="[700,220]">
|
||||||
|
<LayoutGroup itemSpacings="[12]">
|
||||||
|
<LayoutGroup layoutDirection="horiz" itemSpacings="[15]">
|
||||||
|
<Label
|
||||||
|
font="font:SmallSystemFont"
|
||||||
|
text="1." />
|
||||||
|
<Label
|
||||||
|
font="font:SmallSystemFont"
|
||||||
|
width="380"
|
||||||
|
wrap="true"
|
||||||
|
text="On your phone, connect to the same Wi-Fi network as this device." />
|
||||||
|
</LayoutGroup>
|
||||||
|
<LayoutGroup layoutDirection="horiz" itemSpacings="[15]">
|
||||||
|
<Label
|
||||||
|
font="font:SmallSystemFont"
|
||||||
|
text="2." />
|
||||||
|
<Label
|
||||||
|
font="font:SmallSystemFont"
|
||||||
|
width="380"
|
||||||
|
wrap="true"
|
||||||
|
text="Open the YouTube app on your phone." />
|
||||||
|
</LayoutGroup>
|
||||||
|
<LayoutGroup layoutDirection="horiz" itemSpacings="[15]">
|
||||||
|
<Label
|
||||||
|
font="font:SmallSystemFont"
|
||||||
|
text="3." />
|
||||||
|
<Label
|
||||||
|
font="font:SmallSystemFont"
|
||||||
|
width="380"
|
||||||
|
wrap="true"
|
||||||
|
text="Tap the cast icon and select this device." />
|
||||||
|
</LayoutGroup>
|
||||||
|
</LayoutGroup>
|
||||||
|
<Label
|
||||||
|
text="Roku connected to:"
|
||||||
|
translation="[0,220]">
|
||||||
|
<Font role="font" uri="font:SystemFontFile" size="20" />
|
||||||
|
</Label>
|
||||||
|
<Label
|
||||||
|
id="WifiNameLabel"
|
||||||
|
color="#4287f5"
|
||||||
|
translation="[0,250]">
|
||||||
|
<Font role="font" uri="font:BoldSystemFontFile" size="28" />
|
||||||
|
</Label>
|
||||||
|
</Group>
|
||||||
|
|
||||||
|
<Group id="LinkWithTvPanel"
|
||||||
|
translation="[700,220]">
|
||||||
|
<LayoutGroup itemSpacings="[12]">
|
||||||
|
<LayoutGroup layoutDirection="horiz" itemSpacings="[15]">
|
||||||
|
<Label
|
||||||
|
font="font:SmallSystemFont"
|
||||||
|
text="1." />
|
||||||
|
<Label
|
||||||
|
font="font:SmallSystemFont"
|
||||||
|
width="380"
|
||||||
|
wrap="true"
|
||||||
|
text="On your phone, open the YouTube app." />
|
||||||
|
</LayoutGroup>
|
||||||
|
<LayoutGroup layoutDirection="horiz" itemSpacings="[15]">
|
||||||
|
<Label
|
||||||
|
font="font:SmallSystemFont"
|
||||||
|
text="2." />
|
||||||
|
<Label
|
||||||
|
font="font:SmallSystemFont"
|
||||||
|
width="380"
|
||||||
|
wrap="true"
|
||||||
|
text="Tap the Chromecast icon." />
|
||||||
|
</LayoutGroup>
|
||||||
|
<LayoutGroup layoutDirection="horiz" itemSpacings="[15]">
|
||||||
|
<Label
|
||||||
|
font="font:SmallSystemFont"
|
||||||
|
text="3." />
|
||||||
|
<Label
|
||||||
|
font="font:SmallSystemFont"
|
||||||
|
width="380"
|
||||||
|
wrap="true"
|
||||||
|
text="Tap "Link with TV code" and enter the code below." />
|
||||||
|
</LayoutGroup>
|
||||||
|
</LayoutGroup>
|
||||||
|
<Label
|
||||||
|
id="LinkCodeLabel"
|
||||||
|
font="font:LargeBoldSystemFont"
|
||||||
|
color="#4287f5"
|
||||||
|
translation="[-30,180]"
|
||||||
|
width="460"
|
||||||
|
horizAlign="center">
|
||||||
|
<Font role="font" uri="font:BoldSystemFontFile" size="48" />
|
||||||
|
</Label>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
</children>
|
||||||
|
</component>
|
||||||
@@ -252,7 +252,7 @@ function OnkeyEvent(key as string, press as boolean) as boolean
|
|||||||
return true
|
return true
|
||||||
end if
|
end if
|
||||||
|
|
||||||
if key = "options" and press
|
if key = "options"
|
||||||
' A pass-through to the app controller, so it can toggle picture-in-picture
|
' A pass-through to the app controller, so it can toggle picture-in-picture
|
||||||
return false
|
return false
|
||||||
end if
|
end if
|
||||||
|
|||||||
@@ -10,9 +10,9 @@
|
|||||||
<Group id="container">
|
<Group id="container">
|
||||||
<Button
|
<Button
|
||||||
id="filtersButton"
|
id="filtersButton"
|
||||||
translation="[160,40]"
|
translation="[160,35]"
|
||||||
minWidth="240"
|
minWidth="0"
|
||||||
height="48"
|
height="58"
|
||||||
showFocusFootprint="true"
|
showFocusFootprint="true"
|
||||||
iconUri="pkg:/images/icons/filters-white.png"
|
iconUri="pkg:/images/icons/filters-white.png"
|
||||||
focusedIconUri="pkg:/images/icons/filters-black.png"
|
focusedIconUri="pkg:/images/icons/filters-black.png"
|
||||||
|
|||||||
+10
-5
@@ -1,5 +1,6 @@
|
|||||||
import "pkg:/components/Navigation/Navigation.bs"
|
import "pkg:/components/Navigation/Navigation.bs"
|
||||||
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
|
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
|
||||||
|
import "pkg:/source/utils/Logging.bs"
|
||||||
import "pkg:/source/utils/MathUtils.bs"
|
import "pkg:/source/utils/MathUtils.bs"
|
||||||
import "pkg:/source/utils/Types.bs"
|
import "pkg:/source/utils/Types.bs"
|
||||||
|
|
||||||
@@ -49,7 +50,7 @@ function OnkeyEvent(key as string, press as boolean) as boolean
|
|||||||
return true
|
return true
|
||||||
end if
|
end if
|
||||||
|
|
||||||
if key = "options" and press
|
if key = "options"
|
||||||
' A pass-through to the app controller, so it can toggle picture-in-picture
|
' A pass-through to the app controller, so it can toggle picture-in-picture
|
||||||
return false
|
return false
|
||||||
end if
|
end if
|
||||||
@@ -69,9 +70,14 @@ function OnValueChange()
|
|||||||
nodes = []
|
nodes = []
|
||||||
checkedState = []
|
checkedState = []
|
||||||
for each item in value
|
for each item in value
|
||||||
|
feed = m.homeLayout[item.id]
|
||||||
|
if feed = invalid
|
||||||
|
LogWarn("unknown feed id:", item.id)
|
||||||
|
continue for
|
||||||
|
end if
|
||||||
node = CreateObject("roSGNode", "ContentNode")
|
node = CreateObject("roSGNode", "ContentNode")
|
||||||
node.id = item.id
|
node.id = feed.id
|
||||||
node.title = m.homeLayout[item.id].title
|
node.title = feed.title
|
||||||
nodes.push(node)
|
nodes.push(node)
|
||||||
checkedState.push(item.enabled)
|
checkedState.push(item.enabled)
|
||||||
end for
|
end for
|
||||||
@@ -125,8 +131,7 @@ function MoveItem(offset as integer) as void
|
|||||||
|
|
||||||
itemCount = content.getChildCount()
|
itemCount = content.getChildCount()
|
||||||
index = m.checkList.itemFocused
|
index = m.checkList.itemFocused
|
||||||
newIndex = MathUtils.Max(0, MathUtils.Min(index + offset, itemCount - 1))
|
newIndex = MathUtils.Clamp(index + offset, 0, itemCount - 1)
|
||||||
|
|
||||||
if index = newIndex
|
if index = newIndex
|
||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
|
|||||||
+1
-1
@@ -50,7 +50,7 @@ function OnkeyEvent(key as string, press as boolean) as boolean
|
|||||||
return true
|
return true
|
||||||
end if
|
end if
|
||||||
|
|
||||||
if key = "options" and press
|
if key = "options"
|
||||||
' A pass-through to the app controller, so it can toggle picture-in-picture
|
' A pass-through to the app controller, so it can toggle picture-in-picture
|
||||||
return false
|
return false
|
||||||
end if
|
end if
|
||||||
|
|||||||
+1
-1
@@ -31,7 +31,7 @@ function OnkeyEvent(key as string, press as boolean) as boolean
|
|||||||
return true
|
return true
|
||||||
end if
|
end if
|
||||||
|
|
||||||
if key = "options" and press
|
if key = "options"
|
||||||
' A pass-through to the app controller, so it can toggle picture-in-picture
|
' A pass-through to the app controller, so it can toggle picture-in-picture
|
||||||
return false
|
return false
|
||||||
end if
|
end if
|
||||||
|
|||||||
+7
-18
@@ -1,22 +1,11 @@
|
|||||||
function Init()
|
|
||||||
m.nameLabel = m.top.findNode("nameLabel")
|
|
||||||
m.versionLabel = m.top.findNode("versionLabel")
|
|
||||||
m.usersLabel = m.top.findNode("usersLabel")
|
|
||||||
m.signupLabel = m.top.findNode("signupLabel")
|
|
||||||
m.locationLabel = m.top.findNode("locationLabel")
|
|
||||||
m.flagEmoji = m.top.findNode("flagEmoji")
|
|
||||||
m.healthLabel = m.top.findNode("healthLabel")
|
|
||||||
|
|
||||||
end function
|
|
||||||
|
|
||||||
function OnContentSet() as void
|
function OnContentSet() as void
|
||||||
content = m.top.itemContent
|
content = m.top.itemContent
|
||||||
|
|
||||||
m.nameLabel.text = content.name
|
m.top.name = content.name
|
||||||
m.versionLabel.text = content.version
|
m.top.version = content.version
|
||||||
m.usersLabel.text = content.users
|
m.top.users = content.users
|
||||||
m.signupLabel.text = content.signup
|
m.top.signup = content.signup
|
||||||
m.locationLabel.text = content.location
|
m.top.location = content.location
|
||||||
m.flagEmoji.uri = content.flag
|
m.top.flag = content.flag
|
||||||
m.healthLabel.text = content.health
|
m.top.health = content.health
|
||||||
end function
|
end function
|
||||||
+7
@@ -1,6 +1,13 @@
|
|||||||
<component name="InvidiousPublicInstancesListItem" extends="Group">
|
<component name="InvidiousPublicInstancesListItem" extends="Group">
|
||||||
<interface>
|
<interface>
|
||||||
<field id="itemContent" type="node" onChange="OnContentSet" />
|
<field id="itemContent" type="node" onChange="OnContentSet" />
|
||||||
|
<field id="name" type="string" alias="nameLabel.text" />
|
||||||
|
<field id="version" type="string" alias="versionLabel.text" />
|
||||||
|
<field id="users" type="string" alias="usersLabel.text" />
|
||||||
|
<field id="signup" type="string" alias="signupLabel.text" />
|
||||||
|
<field id="location" type="string" alias="locationLabel.text" />
|
||||||
|
<field id="flag" type="string" alias="flagEmoji.uri" />
|
||||||
|
<field id="health" type="string" alias="healthLabel.text" />
|
||||||
</interface>
|
</interface>
|
||||||
<children>
|
<children>
|
||||||
<Label
|
<Label
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
import "pkg:/components/Navigation/Navigation.bs"
|
||||||
|
import "pkg:/source/utils/FocusManagement.bs"
|
||||||
|
import "pkg:/source/utils/MathUtils.bs"
|
||||||
|
import "pkg:/source/utils/Types.bs"
|
||||||
|
|
||||||
|
function Init()
|
||||||
|
m.top.focusable = true
|
||||||
|
m.top.itemSpacings = [10]
|
||||||
|
|
||||||
|
m.minusButton = m.top.findNode("MinusButton")
|
||||||
|
m.numberButton = m.top.findNode("NumberButton")
|
||||||
|
m.plusButton = m.top.findNode("PlusButton")
|
||||||
|
|
||||||
|
m.minusButton.observeFieldScoped("buttonSelected", FuncName(OnMinusSelected))
|
||||||
|
m.plusButton.observeFieldScoped("buttonSelected", FuncName(OnPlusSelected))
|
||||||
|
|
||||||
|
SetNavigation(m.minusButton, "right", m.numberButton)
|
||||||
|
SetNavigation(m.numberButton, "left", m.minusButton)
|
||||||
|
SetNavigation(m.numberButton, "right", m.plusButton)
|
||||||
|
SetNavigation(m.plusButton, "left", m.numberButton)
|
||||||
|
end function
|
||||||
|
|
||||||
|
function BindPreference(preferences as object, key as string)
|
||||||
|
if m.preferences <> invalid and m.key <> invalid
|
||||||
|
m.preferences.unobserveFieldScoped(m.key)
|
||||||
|
end if
|
||||||
|
|
||||||
|
m.preferences = preferences
|
||||||
|
m.key = key
|
||||||
|
|
||||||
|
if preferences <> invalid and key <> invalid
|
||||||
|
preferences.observeFieldScoped(key, FuncName(OnPreferenceChange))
|
||||||
|
OnPreferenceChange()
|
||||||
|
end if
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnPreferenceChange()
|
||||||
|
m.top.value = MathUtils.Clamp(m.preferences[m.key], m.top.min, m.top.max)
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnValueChange() as void
|
||||||
|
m.numberButton.text = `${m.top.value}`
|
||||||
|
if m.preferences = invalid or m.key = invalid
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
m.preferences[m.key] = m.top.value
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnFocusChange() as void
|
||||||
|
if not m.top.focus
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
NodeSetFocus(m.numberButton, true)
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnkeyEvent(key as string, press as boolean) as boolean
|
||||||
|
if NavigationKeyHandler(key, press).handled
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
return false
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnMinusSelected()
|
||||||
|
m.top.value = MathUtils.Max(m.top.value - 1, m.top.min)
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnPlusSelected()
|
||||||
|
m.top.value = MathUtils.Min(m.top.value + 1, m.top.max)
|
||||||
|
end function
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
<component name="NumberControl" extends="LayoutGroup" includes="Focus">
|
||||||
|
<interface>
|
||||||
|
<field id="displayText" type="string" alias="DisplayTextLabel.text" />
|
||||||
|
<field id="description" type="string" alias="DescriptionLabel.text" />
|
||||||
|
<field id="min" type="integer" value="-999999" />
|
||||||
|
<field id="max" type="integer" value="999999" />
|
||||||
|
<field id="value" type="integer" onChange="OnValueChange" />
|
||||||
|
<function name="BindPreference" />
|
||||||
|
</interface>
|
||||||
|
<children>
|
||||||
|
<Label id="DisplayTextLabel" width="450" />
|
||||||
|
<Label id="DescriptionLabel"
|
||||||
|
width="450"
|
||||||
|
color="0xb4b4b4ff"
|
||||||
|
wrap="true">
|
||||||
|
<Font role="font" uri="font:SystemFontFile" size="18" />
|
||||||
|
</Label>
|
||||||
|
<LayoutGroup layoutDirection="horiz">
|
||||||
|
<Button
|
||||||
|
id="MinusButton"
|
||||||
|
iconUri=""
|
||||||
|
focusedIconUri=""
|
||||||
|
minWidth="64"
|
||||||
|
maxWidth="64"
|
||||||
|
showFocusFootprint="true"
|
||||||
|
text="-" />
|
||||||
|
<Button
|
||||||
|
id="NumberButton"
|
||||||
|
iconUri=""
|
||||||
|
focusedIconUri=""
|
||||||
|
minWidth="150"
|
||||||
|
showFocusFootprint="true"
|
||||||
|
text="0" />
|
||||||
|
<Button
|
||||||
|
id="PlusButton"
|
||||||
|
iconUri=""
|
||||||
|
focusedIconUri=""
|
||||||
|
minWidth="64"
|
||||||
|
maxWidth="64"
|
||||||
|
showFocusFootprint="true"
|
||||||
|
text="+" />
|
||||||
|
</LayoutGroup>
|
||||||
|
</children>
|
||||||
|
</component>
|
||||||
@@ -10,7 +10,9 @@ function Init()
|
|||||||
|
|
||||||
m.top.iconUri = ""
|
m.top.iconUri = ""
|
||||||
m.top.focusedIconUri = ""
|
m.top.focusedIconUri = ""
|
||||||
m.top.focusFootprintBitmapUri = "pkg:/images/white.9.png"
|
m.top.focusBitmapUri = "pkg:/images/white.9.png"
|
||||||
|
m.top.focusFootprintBitmapUri = "pkg:/images/white_border.9.png"
|
||||||
|
m.top.showFocusFootprint = true
|
||||||
m.top.observeField("focusedChild", FuncName(OnFocusedChildChange))
|
m.top.observeField("focusedChild", FuncName(OnFocusedChildChange))
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<component name="SettingCategory" extends="Button">
|
<component name="SettingCategory" extends="Button">
|
||||||
<interface>
|
<interface>
|
||||||
<field id="padding" type="integer" value="10" onChange="Resize" />
|
<field id="padding" type="integer" value="15" onChange="Resize" />
|
||||||
<field id="minimumWidth" type="integer" value="280" onChange="Resize" />
|
<field id="minimumWidth" type="integer" value="280" onChange="Resize" />
|
||||||
<field id="displayText" type="string" alias="DisplayTextLabel.text" onChange="Resize" />
|
<field id="displayText" type="string" alias="DisplayTextLabel.text" onChange="Resize" />
|
||||||
<field id="description" type="string" alias="DescriptionLabel.text" onChange="Resize" />
|
<field id="description" type="string" alias="DescriptionLabel.text" onChange="Resize" />
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import "pkg:/components/Navigation/Navigation.bs"
|
import "pkg:/components/Navigation/Navigation.bs"
|
||||||
import "pkg:/components/Navigation/ScrollTo.bs"
|
import "pkg:/components/Navigation/ScrollTo.bs"
|
||||||
import "pkg:/source/utils/FocusManagement.bs"
|
import "pkg:/source/utils/FocusManagement.bs"
|
||||||
|
import "pkg:/source/utils/Types.bs"
|
||||||
|
|
||||||
function Init()
|
function Init()
|
||||||
m.top.focusable = true
|
m.top.focusable = true
|
||||||
@@ -9,9 +10,9 @@ function Init()
|
|||||||
m.scrollAnimationInterpolator = m.scrollAnimation.findNode("scrollAnimationInterpolator")
|
m.scrollAnimationInterpolator = m.scrollAnimation.findNode("scrollAnimationInterpolator")
|
||||||
m.viewport = {
|
m.viewport = {
|
||||||
x: 150
|
x: 150
|
||||||
y: 96
|
y: 50
|
||||||
width: 1920
|
width: 1920
|
||||||
height: 550
|
height: 620
|
||||||
}
|
}
|
||||||
end function
|
end function
|
||||||
|
|
||||||
@@ -126,6 +127,8 @@ function CreateControl(item as object, container as object, startX as integer, s
|
|||||||
control = CreateRadioControl(item, container)
|
control = CreateRadioControl(item, container)
|
||||||
else if item.type = "string"
|
else if item.type = "string"
|
||||||
control = CreateStringControl(item, container)
|
control = CreateStringControl(item, container)
|
||||||
|
else if item.type = "number"
|
||||||
|
control = CreateNumberComponent(item, container)
|
||||||
else if item.rokuComponent <> invalid
|
else if item.rokuComponent <> invalid
|
||||||
control = CreateRokuComponent(item, container)
|
control = CreateRokuComponent(item, container)
|
||||||
end if
|
end if
|
||||||
@@ -169,6 +172,19 @@ function CreateStringControl(item as object, container as object) as object
|
|||||||
return node
|
return node
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
function CreateNumberComponent(item as object, container as object) as object
|
||||||
|
node = container.createChild("NumberControl")
|
||||||
|
node.displayText = item.displayText
|
||||||
|
node.description = item.description
|
||||||
|
if IsInt(item.min)
|
||||||
|
node.min = item.min
|
||||||
|
end if
|
||||||
|
if IsInt(item.max)
|
||||||
|
node.max = item.max
|
||||||
|
end if
|
||||||
|
return node
|
||||||
|
end function
|
||||||
|
|
||||||
function CreateRokuComponent(item as object, container as object) as object
|
function CreateRokuComponent(item as object, container as object) as object
|
||||||
node = container.createChild(item.rokuComponent)
|
node = container.createChild(item.rokuComponent)
|
||||||
if node.hasField("displayText")
|
if node.hasField("displayText")
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
import "pkg:/source/AsyncTask/AsyncTask.bs"
|
|
||||||
import "pkg:/source/AsyncTask/Tasks.bs"
|
|
||||||
import "pkg:/source/utils/StringUtils.bs"
|
|
||||||
|
|
||||||
function Init()
|
|
||||||
end function
|
|
||||||
|
|
||||||
function OnNodeReady()
|
|
||||||
address = m.webserver@.GetServerAddress()
|
|
||||||
isValidAddress = not StringUtils.IsNullOrEmpty(address)
|
|
||||||
if isValidAddress
|
|
||||||
m.top.url = address
|
|
||||||
end if
|
|
||||||
m.top.findNode("noInternet").visible = not isValidAddress
|
|
||||||
m.top.findNode("yesInternet").visible = isValidAddress
|
|
||||||
end function
|
|
||||||
|
|
||||||
function OnUrlSet()
|
|
||||||
url = m.top.url
|
|
||||||
|
|
||||||
urlLabel = m.top.findNode("urlLabel")
|
|
||||||
urlLabel.text = url
|
|
||||||
|
|
||||||
qrCodePoster = m.top.findNode("QrCodePoster")
|
|
||||||
AsyncTask.Start(Tasks.GenerateQrCodeTask, {
|
|
||||||
poster: qrCodePoster
|
|
||||||
text: url
|
|
||||||
size: qrCodePoster.loadWidth
|
|
||||||
padding: 20
|
|
||||||
})
|
|
||||||
end function
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
<component name="WebAppScreen" extends="Group" includes="AutoBind">
|
|
||||||
<interface>
|
|
||||||
<field id="webServer" type="node" bind="/WebServer" />
|
|
||||||
<field id="url" type="string" onChange="OnUrlSet" />
|
|
||||||
<field id="qrCodeUrl" type="string" onChange="OnUrlSet" />
|
|
||||||
</interface>
|
|
||||||
<children>
|
|
||||||
<Group id="noInternet" visible="false">
|
|
||||||
<Label
|
|
||||||
height="720"
|
|
||||||
width="1280"
|
|
||||||
font="font:MediumBoldSystemFont"
|
|
||||||
horizAlign="center"
|
|
||||||
vertAlign="center"
|
|
||||||
text="Could not get IP address: are we connected to the internet?"
|
|
||||||
/>
|
|
||||||
</Group>
|
|
||||||
<Group id="yesInternet" visible="false">
|
|
||||||
<Label
|
|
||||||
height="60"
|
|
||||||
width="1280"
|
|
||||||
font="font:MediumBoldSystemFont"
|
|
||||||
horizAlign="center"
|
|
||||||
translation="[0,92]"
|
|
||||||
text="Scan the QR code with your phone camera, or open the URL in a web browser:"
|
|
||||||
/>
|
|
||||||
<Poster
|
|
||||||
id="QrCodePoster"
|
|
||||||
height="400"
|
|
||||||
width="400"
|
|
||||||
loadHeight="400"
|
|
||||||
loadWidth="400"
|
|
||||||
translation="[440, 160]" />
|
|
||||||
|
|
||||||
<Label
|
|
||||||
id="UrlLabel"
|
|
||||||
height="50"
|
|
||||||
width="1280"
|
|
||||||
font="font:MediumBoldSystemFont"
|
|
||||||
horizAlign="center"
|
|
||||||
translation="[0,600]"
|
|
||||||
/>
|
|
||||||
</Group>
|
|
||||||
</children>
|
|
||||||
</component>
|
|
||||||
@@ -14,7 +14,7 @@ function GetLatestPlayletLibVersionFromGithubReleases() as string
|
|||||||
if response.StatusCode() = 200
|
if response.StatusCode() = 200
|
||||||
headers = response.Headers()
|
headers = response.Headers()
|
||||||
if headers.location <> invalid
|
if headers.location <> invalid
|
||||||
regex = CreateObject("roRegex", "/v?(\d+\.\d+\.\d+)", "")
|
regex = /\/v?(\d+\.\d+\.\d+)/
|
||||||
match = regex.match(headers.location)
|
match = regex.match(headers.location)
|
||||||
if match.Count() = 2
|
if match.Count() = 2
|
||||||
return match[1]
|
return match[1]
|
||||||
|
|||||||
@@ -8,8 +8,28 @@ class DashManifest
|
|||||||
public invidiousInstance as dynamic
|
public invidiousInstance as dynamic
|
||||||
|
|
||||||
function new(invidiousInstance as string)
|
function new(invidiousInstance as string)
|
||||||
m.utils = new Http.Utils()
|
|
||||||
m.invidiousInstance = invidiousInstance
|
m.invidiousInstance = invidiousInstance
|
||||||
|
|
||||||
|
m.utils = new Http.Utils()
|
||||||
|
m.urlRegex = /https?:\/\/\S+(\/\S+)/i
|
||||||
|
|
||||||
|
' https://github.com/LuanRT/YouTube.js/blob/6082b4a52ee07a622735e6e9128a0531a5ae3bfb/src/utils/StreamingInfo.ts#L332-L349
|
||||||
|
m.colorInfo = {
|
||||||
|
primaries: {
|
||||||
|
"COLOR_PRIMARIES_BT709": "1"
|
||||||
|
"COLOR_PRIMARIES_BT2020": "9"
|
||||||
|
}
|
||||||
|
transferCharacteristics: {
|
||||||
|
"COLOR_TRANSFER_CHARACTERISTICS_BT709": "1"
|
||||||
|
"COLOR_TRANSFER_CHARACTERISTICS_BT2020_10": "14"
|
||||||
|
"COLOR_TRANSFER_CHARACTERISTICS_SMPTEST2084": "16"
|
||||||
|
"COLOR_TRANSFER_CHARACTERISTICS_ARIB_STD_B67": "18"
|
||||||
|
}
|
||||||
|
matrixCoefficients: {
|
||||||
|
"COLOR_MATRIX_COEFFICIENTS_BT709": "1"
|
||||||
|
"COLOR_MATRIX_COEFFICIENTS_BT2020_NCL": "14"
|
||||||
|
}
|
||||||
|
}
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function fromVideoMetadata(metadata as object, local as boolean) as string
|
function fromVideoMetadata(metadata as object, local as boolean) as string
|
||||||
@@ -17,10 +37,8 @@ class DashManifest
|
|||||||
adaptiveFormats.Append (metadata.adaptiveFormats)
|
adaptiveFormats.Append (metadata.adaptiveFormats)
|
||||||
|
|
||||||
if local
|
if local
|
||||||
urlRegex = CreateObject("roRegex", "https?:\/\/\S+(\/\S+)", "i")
|
|
||||||
|
|
||||||
for i = 0 to adaptiveFormats.Count() - 1
|
for i = 0 to adaptiveFormats.Count() - 1
|
||||||
adaptiveFormats[i].url = urlRegex.replace(adaptiveFormats[i].url, m.invidiousInstance + "\1")
|
adaptiveFormats[i].url = m.urlRegex.replace(adaptiveFormats[i].url, m.invidiousInstance + "\1")
|
||||||
end for
|
end for
|
||||||
end if
|
end if
|
||||||
|
|
||||||
@@ -55,11 +73,10 @@ class DashManifest
|
|||||||
end if
|
end if
|
||||||
|
|
||||||
if xml.Node("AdaptationSet", adaptationSetAttributes)
|
if xml.Node("AdaptationSet", adaptationSetAttributes)
|
||||||
xml.Node("Role", {
|
xml.EmptyNode("Role", {
|
||||||
"schemeIdUri": "urn:mpeg:dash:role:2011"
|
"schemeIdUri": "urn:mpeg:dash:role:2011"
|
||||||
"value": audioSet.acont = "original" ? "main" : "alternate"
|
"value": audioSet.acont = "original" ? "main" : "alternate"
|
||||||
})
|
})
|
||||||
xml.End()
|
|
||||||
|
|
||||||
for i = 0 to audioStreams.Count() - 1
|
for i = 0 to audioStreams.Count() - 1
|
||||||
stream = audioStreams[i]
|
stream = audioStreams[i]
|
||||||
@@ -82,31 +99,23 @@ class DashManifest
|
|||||||
"bandwidth": stream.bitrate
|
"bandwidth": stream.bitrate
|
||||||
})
|
})
|
||||||
|
|
||||||
xml.Node("AudioChannelConfiguration", {
|
xml.EmptyNode("AudioChannelConfiguration", {
|
||||||
"schemeIdUri": "urn:mpeg:dash:23003:3:audio_channel_configuration:2011"
|
"schemeIdUri": "urn:mpeg:dash:23003:3:audio_channel_configuration:2011"
|
||||||
"value": `${stream.audioChannels}`
|
"value": `${stream.audioChannels}`
|
||||||
})
|
})
|
||||||
xml.End()
|
|
||||||
|
|
||||||
if xml.Node("BaseURL")
|
xml.TextNode("BaseURL", stream.url)
|
||||||
xml.Text(stream.url)
|
|
||||||
xml.End()
|
if xml.Node("SegmentBase", { "indexRange": stream.index })
|
||||||
end if
|
xml.EmptyNode("Initialization", { "range": stream.init })
|
||||||
|
|
||||||
if xml.Node("SegmentBase", {
|
|
||||||
"indexRange": stream.index
|
|
||||||
})
|
|
||||||
if xml.Node("Initialization", {
|
|
||||||
"range": stream.init
|
|
||||||
})
|
|
||||||
xml.End()
|
|
||||||
end if
|
|
||||||
xml.End()
|
xml.End()
|
||||||
end if
|
end if
|
||||||
|
|
||||||
xml.End()
|
xml.End()
|
||||||
end if
|
end if
|
||||||
end for
|
end for
|
||||||
|
|
||||||
xml.End()
|
xml.End()
|
||||||
end if
|
end if
|
||||||
|
|
||||||
@@ -154,19 +163,15 @@ class DashManifest
|
|||||||
end if
|
end if
|
||||||
|
|
||||||
if xml.Node("Representation", representationAttributes)
|
if xml.Node("Representation", representationAttributes)
|
||||||
|
m.AddColorInfo(stream, xml)
|
||||||
if xml.Node("BaseURL")
|
if xml.Node("BaseURL")
|
||||||
xml.Text(stream.url)
|
xml.Text(stream.url)
|
||||||
xml.End()
|
xml.End()
|
||||||
end if
|
end if
|
||||||
|
|
||||||
if xml.Node("SegmentBase", {
|
if xml.Node("SegmentBase", { "indexRange": stream.index })
|
||||||
"indexRange": stream.index
|
xml.EmptyNode("Initialization", { "range": stream.init })
|
||||||
})
|
|
||||||
if xml.Node("Initialization", {
|
|
||||||
"range": stream.init
|
|
||||||
})
|
|
||||||
xml.End()
|
|
||||||
end if
|
|
||||||
xml.End()
|
xml.End()
|
||||||
end if
|
end if
|
||||||
|
|
||||||
@@ -184,7 +189,7 @@ class DashManifest
|
|||||||
for each storyboard in storyboards
|
for each storyboard in storyboards
|
||||||
interval = ValidInt(storyboard.interval)
|
interval = ValidInt(storyboard.interval)
|
||||||
if interval = 0
|
if interval = 0
|
||||||
LogWarn("Invalid storyboard interval=0")
|
LogWarn("Invalid storyboard interval:", storyboard.interval)
|
||||||
continue for
|
continue for
|
||||||
end if
|
end if
|
||||||
|
|
||||||
@@ -211,7 +216,7 @@ class DashManifest
|
|||||||
|
|
||||||
intervalInSeconds = interval \ 1000
|
intervalInSeconds = interval \ 1000
|
||||||
|
|
||||||
' Youtube template uses the var $M for tile pages
|
' YouTube template uses the var $M for tile pages
|
||||||
' DASH-IF uses $Number$ in the SegmentTemplate
|
' DASH-IF uses $Number$ in the SegmentTemplate
|
||||||
' https://dashif.org/docs/DASH-IF-IOP-v4.3.pdf
|
' https://dashif.org/docs/DASH-IF-IOP-v4.3.pdf
|
||||||
url = templateUrl.replace("$M", "$Number$")
|
url = templateUrl.replace("$M", "$Number$")
|
||||||
@@ -230,12 +235,11 @@ class DashManifest
|
|||||||
"mimeType": "image/jpeg"
|
"mimeType": "image/jpeg"
|
||||||
"contentType": "image"
|
"contentType": "image"
|
||||||
})
|
})
|
||||||
xml.Node("SegmentTemplate", {
|
xml.EmptyNode("SegmentTemplate", {
|
||||||
"media": url
|
"media": url
|
||||||
"duration": duration
|
"duration": duration
|
||||||
"startNumber": 0
|
"startNumber": 0
|
||||||
})
|
})
|
||||||
xml.End()
|
|
||||||
|
|
||||||
if xml.Node("Representation", {
|
if xml.Node("Representation", {
|
||||||
"id": `thumbnails_${id}`
|
"id": `thumbnails_${id}`
|
||||||
@@ -244,11 +248,10 @@ class DashManifest
|
|||||||
"height": storyboardHeightInPixels
|
"height": storyboardHeightInPixels
|
||||||
})
|
})
|
||||||
|
|
||||||
xml.Node("EssentialProperty", {
|
xml.EmptyNode("EssentialProperty", {
|
||||||
"schemeIdUri": "http://dashif.org/guidelines/thumbnail_tile"
|
"schemeIdUri": "http://dashif.org/guidelines/thumbnail_tile"
|
||||||
"value": `${storyboardWidth}x${storyboardHeight}`
|
"value": `${storyboardWidth}x${storyboardHeight}`
|
||||||
})
|
})
|
||||||
xml.End()
|
|
||||||
|
|
||||||
xml.End()
|
xml.End()
|
||||||
end if
|
end if
|
||||||
@@ -371,4 +374,47 @@ class DashManifest
|
|||||||
end for
|
end for
|
||||||
return result
|
return result
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
function AddColorInfo(videoStream as object, xml as object) as void
|
||||||
|
if videoStream.colorInfo = invalid
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
if videoStream.colorInfo.primaries <> invalid
|
||||||
|
primaries = m.colorInfo.primaries[videoStream.colorInfo.primaries]
|
||||||
|
if primaries <> invalid
|
||||||
|
xml.EmptyNode("EssentialProperty", {
|
||||||
|
"schemeIdUri": "urn:mpeg:mpegB:cicp:ColourPrimaries"
|
||||||
|
"value": primaries
|
||||||
|
})
|
||||||
|
else
|
||||||
|
LogWarn("Unknown colorInfo.primaries:", videoStream.colorInfo.primaries)
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
|
||||||
|
if videoStream.colorInfo.transferCharacteristics <> invalid
|
||||||
|
transferCharacteristics = m.colorInfo.transferCharacteristics[videoStream.colorInfo.transferCharacteristics]
|
||||||
|
if transferCharacteristics <> invalid
|
||||||
|
xml.EmptyNode("EssentialProperty", {
|
||||||
|
"schemeIdUri": "urn:mpeg:mpegB:cicp:TransferCharacteristics"
|
||||||
|
"value": transferCharacteristics
|
||||||
|
})
|
||||||
|
else
|
||||||
|
LogWarn("Unknown colorInfo.transferCharacteristics:", videoStream.colorInfo.transferCharacteristics)
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
|
||||||
|
if videoStream.colorInfo.matrixCoefficients <> invalid
|
||||||
|
matrixCoefficients = m.colorInfo.matrixCoefficients[videoStream.colorInfo.matrixCoefficients]
|
||||||
|
if matrixCoefficients <> invalid
|
||||||
|
xml.EmptyNode("EssentialProperty", {
|
||||||
|
"schemeIdUri": "urn:mpeg:mpegB:cicp:MatrixCoefficients"
|
||||||
|
"value": matrixCoefficients
|
||||||
|
})
|
||||||
|
else
|
||||||
|
LogWarn("Unknown colorInfo.matrixCoefficients:", videoStream.colorInfo.matrixCoefficients)
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
end function
|
||||||
|
|
||||||
end class
|
end class
|
||||||
@@ -41,26 +41,13 @@ namespace Invidious
|
|||||||
|
|
||||||
function new(node as object)
|
function new(node as object)
|
||||||
m.node = node
|
m.node = node
|
||||||
|
|
||||||
m.endpoints = node.apiDefinitions
|
|
||||||
|
|
||||||
m.responseHandlers = {
|
|
||||||
DefaultHandler: m.DefaultHandler
|
|
||||||
AuthFeedHandler: m.AuthFeedHandler
|
|
||||||
PlaylistHandler: m.PlaylistHandler
|
|
||||||
VideoInfoHandler: m.VideoInfoHandler
|
|
||||||
PlaylistInfoHandler: m.PlaylistInfoHandler
|
|
||||||
ChannelInfoHandler: m.ChannelInfoHandler
|
|
||||||
ChannelVideosHandler: m.ChannelVideosHandler
|
|
||||||
ChannelPlaylistsHandler: m.ChannelPlaylistsHandler
|
|
||||||
WatchHistoryHandler: m.WatchHistoryHandler
|
|
||||||
}
|
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function DefaultQueryParams() as object
|
function GetUserRegion() as string
|
||||||
return {
|
if m._userRegion = invalid
|
||||||
region: m.node.applicationInfo@.GetUserCountryCode()
|
m._userRegion = m.node.applicationInfo@.GetUserCountryCode()
|
||||||
}
|
end if
|
||||||
|
return m._userRegion
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function GetAuthenticationHeaders(token as string) as object
|
function GetAuthenticationHeaders(token as string) as object
|
||||||
@@ -99,7 +86,7 @@ namespace Invidious
|
|||||||
url = `${instance}${Invidious.SEARCH_SUGGEST_ENDPOINT}`
|
url = `${instance}${Invidious.SEARCH_SUGGEST_ENDPOINT}`
|
||||||
|
|
||||||
request = HttpClient.Get(url)
|
request = HttpClient.Get(url)
|
||||||
request.QueryParams(m.DefaultQueryParams())
|
request.QueryParam("region", m.GetUserRegion())
|
||||||
request.QueryParam("q", q)
|
request.QueryParam("q", q)
|
||||||
request.CacheSeconds(60 * 60 * 24)
|
request.CacheSeconds(60 * 60 * 24)
|
||||||
|
|
||||||
@@ -109,33 +96,51 @@ namespace Invidious
|
|||||||
return response.Json()
|
return response.Json()
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function GetVideoMetadata(videoId as string, cancellation = invalid as object) as object
|
function GetVideoMetadata(videoId as string, options = invalid as object) as object
|
||||||
instance = m.GetInstance()
|
|
||||||
url = `${instance}${Invidious.VIDEOS_ENDPOINT}/${videoId}`
|
|
||||||
|
|
||||||
request = HttpClient.Get(url)
|
|
||||||
request.QueryParams(m.DefaultQueryParams())
|
|
||||||
' 5 hours cache. Videos should expire in 6 hours, but since we don't
|
' 5 hours cache. Videos should expire in 6 hours, but since we don't
|
||||||
' have the exact expiration time, we'll use 5 hours. Invidious currently
|
' have the exact expiration time, we'll use 5 hours. Invidious currently
|
||||||
' Does a fresh fetch if the cache is older than 10 minutes.
|
' Does a fresh fetch if the cache is older than 10 minutes.
|
||||||
' https://github.com/iv-org/invidious/blob/069e91d2a609b1df94bdfbb693335969b2a281d8/src/invidious/videos.cr#L349
|
' https://github.com/iv-org/invidious/blob/069e91d2a609b1df94bdfbb693335969b2a281d8/src/invidious/videos.cr#L349
|
||||||
request.CacheSeconds(60 * 60 * 5)
|
cacheSeconds = 18000 ' 5 hours
|
||||||
|
cancellation = invalid
|
||||||
|
tryCount = 2
|
||||||
|
|
||||||
|
if options <> invalid
|
||||||
|
if options.DoesExist("cacheSeconds")
|
||||||
|
cacheSeconds = options.cacheSeconds
|
||||||
|
end if
|
||||||
|
if options.DoesExist("cancellation")
|
||||||
|
cancellation = options.cancellation
|
||||||
|
end if
|
||||||
|
if options.DoesExist("tryCount")
|
||||||
|
tryCount = options.tryCount
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
|
||||||
|
instance = m.GetInstance()
|
||||||
|
url = `${instance}${Invidious.VIDEOS_ENDPOINT}/${videoId}`
|
||||||
|
|
||||||
|
request = HttpClient.Get(url)
|
||||||
|
|
||||||
|
request.CacheSeconds(cacheSeconds)
|
||||||
request.Cancellation(cancellation)
|
request.Cancellation(cancellation)
|
||||||
|
|
||||||
request.TryCount(2)
|
if tryCount > 1
|
||||||
request.RetryCallback(function(context as object) as boolean
|
request.TryCount(tryCount)
|
||||||
response = context.response
|
request.RetryCallback(function(context as object) as boolean
|
||||||
' In some cases, video info requests return "HTTP/0.9 when not allowed" errors.
|
response = context.response
|
||||||
' Retrying should usually fix the issue.
|
' In some cases, video info requests return "HTTP/0.9 when not allowed" errors.
|
||||||
if response.StatusCode() = HttpClient.CurlErrors.CURLE_UNSUPPORTED_PROTOCOL
|
' Retrying should usually fix the issue.
|
||||||
errorMessage = response.ErrorMessage()
|
if response.StatusCode() = HttpClient.CurlErrors.CURLE_UNSUPPORTED_PROTOCOL
|
||||||
if errorMessage.InStr("HTTP/0.9") <> -1
|
errorMessage = response.ErrorMessage()
|
||||||
return true
|
if errorMessage.InStr("HTTP/0.9") <> -1
|
||||||
|
return true
|
||||||
|
end if
|
||||||
end if
|
end if
|
||||||
end if
|
|
||||||
|
|
||||||
return false
|
return false
|
||||||
end function)
|
end function)
|
||||||
|
end if
|
||||||
|
|
||||||
return request.Await()
|
return request.Await()
|
||||||
end function
|
end function
|
||||||
@@ -152,7 +157,6 @@ namespace Invidious
|
|||||||
request.Headers(m.GetAuthenticationHeaders(authToken.token))
|
request.Headers(m.GetAuthenticationHeaders(authToken.token))
|
||||||
end if
|
end if
|
||||||
|
|
||||||
request.QueryParams(m.DefaultQueryParams())
|
|
||||||
request.QueryParam("index", index)
|
request.QueryParam("index", index)
|
||||||
request.Cancellation(cancellation)
|
request.Cancellation(cancellation)
|
||||||
|
|
||||||
@@ -164,7 +168,6 @@ namespace Invidious
|
|||||||
url = `${instance}${Invidious.CHANNELS_ENDPOINT}/${authorId}`
|
url = `${instance}${Invidious.CHANNELS_ENDPOINT}/${authorId}`
|
||||||
|
|
||||||
request = HttpClient.Get(url)
|
request = HttpClient.Get(url)
|
||||||
request.QueryParams(m.DefaultQueryParams())
|
|
||||||
request.Cancellation(cancellation)
|
request.Cancellation(cancellation)
|
||||||
request.CacheSeconds(60 * 60 * 24)' 24 hours
|
request.CacheSeconds(60 * 60 * 24)' 24 hours
|
||||||
request.TryCount(3)
|
request.TryCount(3)
|
||||||
@@ -187,6 +190,10 @@ namespace Invidious
|
|||||||
|
|
||||||
feedSource = feedSources[feedSourcesIndex]
|
feedSource = feedSources[feedSourcesIndex]
|
||||||
|
|
||||||
|
if m.endpoints = invalid
|
||||||
|
m.endpoints = m.node.apiDefinitions
|
||||||
|
end if
|
||||||
|
|
||||||
endpoint = m.endpoints[feedSource.endpoint]
|
endpoint = m.endpoints[feedSource.endpoint]
|
||||||
if endpoint = invalid or StringUtils.IsNullOrEmpty(endpoint.paginationType)
|
if endpoint = invalid or StringUtils.IsNullOrEmpty(endpoint.paginationType)
|
||||||
return feedSource
|
return feedSource
|
||||||
@@ -220,6 +227,10 @@ namespace Invidious
|
|||||||
end function
|
end function
|
||||||
|
|
||||||
function MakeRequest(feedSource as object, additionalQueryParams = invalid as object, cancellation = invalid as object) as object
|
function MakeRequest(feedSource as object, additionalQueryParams = invalid as object, cancellation = invalid as object) as object
|
||||||
|
if m.endpoints = invalid
|
||||||
|
m.endpoints = m.node.apiDefinitions
|
||||||
|
end if
|
||||||
|
|
||||||
endpoint = m.endpoints[feedSource.endpoint]
|
endpoint = m.endpoints[feedSource.endpoint]
|
||||||
if endpoint = invalid
|
if endpoint = invalid
|
||||||
return {
|
return {
|
||||||
@@ -291,6 +302,20 @@ namespace Invidious
|
|||||||
|
|
||||||
response = request.Await()
|
response = request.Await()
|
||||||
|
|
||||||
|
if m.responseHandlers = invalid
|
||||||
|
m.responseHandlers = {
|
||||||
|
DefaultHandler: m.DefaultHandler
|
||||||
|
AuthFeedHandler: m.AuthFeedHandler
|
||||||
|
PlaylistHandler: m.PlaylistHandler
|
||||||
|
VideoInfoHandler: m.VideoInfoHandler
|
||||||
|
PlaylistInfoHandler: m.PlaylistInfoHandler
|
||||||
|
ChannelInfoHandler: m.ChannelInfoHandler
|
||||||
|
ChannelVideosHandler: m.ChannelVideosHandler
|
||||||
|
ChannelPlaylistsHandler: m.ChannelPlaylistsHandler
|
||||||
|
WatchHistoryHandler: m.WatchHistoryHandler
|
||||||
|
}
|
||||||
|
end if
|
||||||
|
|
||||||
responseHandler = endpoint.responseHandler <> invalid ? m.responseHandlers[endpoint.responseHandler] : m.responseHandlers["DefaultHandler"]
|
responseHandler = endpoint.responseHandler <> invalid ? m.responseHandlers[endpoint.responseHandler] : m.responseHandlers["DefaultHandler"]
|
||||||
|
|
||||||
result = responseHandler(m, feedSource, response)
|
result = responseHandler(m, feedSource, response)
|
||||||
@@ -505,14 +530,22 @@ We apologize for the inconvenience.`
|
|||||||
function VerifyTokenScope(token as string) as boolean
|
function VerifyTokenScope(token as string) as boolean
|
||||||
tokenObject = ParseJson(token)
|
tokenObject = ParseJson(token)
|
||||||
if tokenObject = invalid
|
if tokenObject = invalid
|
||||||
|
LogWarn("Failed to json parse token:", token)
|
||||||
return false
|
return false
|
||||||
end if
|
end if
|
||||||
if not IsArray(tokenObject.scopes)
|
if not IsArray(tokenObject.scopes)
|
||||||
|
LogWarn("Token scopes are not an array:", tokenObject.scopes)
|
||||||
return false
|
return false
|
||||||
end if
|
end if
|
||||||
|
|
||||||
scopes = tokenObject.scopes.join(",")
|
scopes = tokenObject.scopes.join(",")
|
||||||
return scopes = Invidious.AUTH_SCOPES
|
expectedScopes = Invidious.AUTH_SCOPES
|
||||||
|
validScopes = expectedScopes = scopes
|
||||||
|
|
||||||
|
if not validScopes
|
||||||
|
LogWarn(`Token scopes do not match expected scopes. Expected: "${expectedScopes}", got: "${scopes}"`)
|
||||||
|
end if
|
||||||
|
return validScopes
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function DeleteAuthToken()
|
function DeleteAuthToken()
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import "pkg:/components/VideoFeed/FeedLoadState.bs"
|
import "pkg:/components/VideoFeed/FeedLoadState.bs"
|
||||||
|
import "pkg:/source/utils/StringUtils.bs"
|
||||||
import "pkg:/source/utils/TimeUtils.bs"
|
import "pkg:/source/utils/TimeUtils.bs"
|
||||||
|
|
||||||
namespace InvidiousContent
|
namespace InvidiousContent
|
||||||
@@ -33,7 +34,8 @@ namespace InvidiousContent
|
|||||||
end if
|
end if
|
||||||
node.type = "video"
|
node.type = "video"
|
||||||
|
|
||||||
SetIfExists(node, "author", item, "author")
|
' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
|
||||||
|
SetIfExists(node, "_author", item, "author")
|
||||||
SetIfExists(node, "authorId", item, "authorId")
|
SetIfExists(node, "authorId", item, "authorId")
|
||||||
SetIfExists(node, "lengthSeconds", item, "lengthSeconds")
|
SetIfExists(node, "lengthSeconds", item, "lengthSeconds")
|
||||||
node.lengthText = TimeUtils.GetFormattedTime(item.lengthSeconds)
|
node.lengthText = TimeUtils.GetFormattedTime(item.lengthSeconds)
|
||||||
@@ -43,6 +45,7 @@ namespace InvidiousContent
|
|||||||
VideoSetThumbnail(node, item, instance)
|
VideoSetThumbnail(node, item, instance)
|
||||||
SetIfExists(node, "title", item, "title")
|
SetIfExists(node, "title", item, "title")
|
||||||
SetIfExists(node, "timestamp", item, "timestamp")
|
SetIfExists(node, "timestamp", item, "timestamp")
|
||||||
|
SetIfExists(node, "id", item, "videoId")
|
||||||
SetIfExists(node, "videoId", item, "videoId")
|
SetIfExists(node, "videoId", item, "videoId")
|
||||||
node.viewCountText = VideoGetViewCountText(item)
|
node.viewCountText = VideoGetViewCountText(item)
|
||||||
SetIfExists(node, "index", item, "index")
|
SetIfExists(node, "index", item, "index")
|
||||||
@@ -61,6 +64,7 @@ namespace InvidiousContent
|
|||||||
SetIfExists(node, "_author", item, "author")
|
SetIfExists(node, "_author", item, "author")
|
||||||
SetIfExists(node, "authorId", item, "authorId")
|
SetIfExists(node, "authorId", item, "authorId")
|
||||||
SetIfExists(node, "description", item, "description")
|
SetIfExists(node, "description", item, "description")
|
||||||
|
SetIfExists(node, "id", item, "playlistId")
|
||||||
SetIfExists(node, "playlistId", item, "playlistId")
|
SetIfExists(node, "playlistId", item, "playlistId")
|
||||||
SetIfExists(node, "title", item, "title")
|
SetIfExists(node, "title", item, "title")
|
||||||
SetIfExists(node, "videoCount", item, "videoCount")
|
SetIfExists(node, "videoCount", item, "videoCount")
|
||||||
@@ -105,6 +109,7 @@ namespace InvidiousContent
|
|||||||
|
|
||||||
' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
|
' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
|
||||||
SetIfExists(node, "_author", item, "author")
|
SetIfExists(node, "_author", item, "author")
|
||||||
|
SetIfExists(node, "id", item, "authorId")
|
||||||
SetIfExists(node, "authorId", item, "authorId")
|
SetIfExists(node, "authorId", item, "authorId")
|
||||||
SetIfExists(node, "channelHandle", item, "channelHandle")
|
SetIfExists(node, "channelHandle", item, "channelHandle")
|
||||||
SetIfExists(node, "description", item, "description")
|
SetIfExists(node, "description", item, "description")
|
||||||
|
|||||||
@@ -0,0 +1,298 @@
|
|||||||
|
import "pkg:/source/utils/Logging.bs"
|
||||||
|
import "pkg:/source/utils/UrlUtils.bs"
|
||||||
|
|
||||||
|
const LONG_POLL_BUFSIZE = 65536
|
||||||
|
const LONG_POLL_TIMEOUT_MS = 60000
|
||||||
|
|
||||||
|
enum HttpResponseState
|
||||||
|
INIT = 0
|
||||||
|
READING_STATUS = 1
|
||||||
|
READING_HEADERS = 2
|
||||||
|
READING_BODY_CHUNK_SIZE = 3
|
||||||
|
READING_BODY_CHUNK = 4
|
||||||
|
end enum
|
||||||
|
|
||||||
|
class LongPoller
|
||||||
|
' Socket stuff for long polling
|
||||||
|
private socket
|
||||||
|
private socket_buffer
|
||||||
|
private socket_state = HttpResponseState.INIT
|
||||||
|
private socket_chunk_size = 0
|
||||||
|
private socket_timer
|
||||||
|
|
||||||
|
private status_code = 0
|
||||||
|
private headers
|
||||||
|
|
||||||
|
function new()
|
||||||
|
m.socket_timer = CreateObject("roTimespan")
|
||||||
|
end function
|
||||||
|
|
||||||
|
function SendRequest(url as string, messagePort as object) as boolean
|
||||||
|
m.url = url
|
||||||
|
|
||||||
|
urlObject = UrlUtils.ParseUrl(url)
|
||||||
|
if urlObject.protocol <> "http"
|
||||||
|
throw `Invalid protocol: ${urlObject.protocol}`
|
||||||
|
end if
|
||||||
|
|
||||||
|
sendAddress = CreateObject("roSocketAddress")
|
||||||
|
sendAddress.SetAddress(`${urlObject.host}:${urlObject.port}`)
|
||||||
|
|
||||||
|
socket = CreateObject("roStreamSocket")
|
||||||
|
socket.setSendToAddress(sendAddress)
|
||||||
|
if not socket.Connect()
|
||||||
|
LogError("Failed to connect")
|
||||||
|
return false
|
||||||
|
end if
|
||||||
|
|
||||||
|
LogInfo(`Sending long polling GET ${url}`, "ID:", socket.GetID())
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
? `════════ curl command ════════\n${m.ToCurlCommand()}\n══════════════════════════════`
|
||||||
|
#end if
|
||||||
|
|
||||||
|
message = `GET ${urlObject.path} HTTP/1.1\r\n`
|
||||||
|
message += `Host: ${urlObject.host}\r\n`
|
||||||
|
message += `\r\n`
|
||||||
|
|
||||||
|
socket.SendStr(message)
|
||||||
|
|
||||||
|
socket.notifyReadable(true)
|
||||||
|
socket.setMessagePort(messagePort)
|
||||||
|
|
||||||
|
m.socket = socket
|
||||||
|
m.socket_timer.Mark()
|
||||||
|
|
||||||
|
return true
|
||||||
|
end function
|
||||||
|
|
||||||
|
' Returns:
|
||||||
|
' - false if we're no longer returning data - socket is closed
|
||||||
|
' - true if we're still waiting for data
|
||||||
|
' - array we've received chunk(s) of data
|
||||||
|
function Poll(socketMessages as object) as dynamic
|
||||||
|
if m.socket = invalid
|
||||||
|
return false
|
||||||
|
end if
|
||||||
|
|
||||||
|
socket = m.socket
|
||||||
|
if not socket.IsConnected()
|
||||||
|
LogError("Socket is not connected")
|
||||||
|
m.CloseSocket()
|
||||||
|
return false
|
||||||
|
end if
|
||||||
|
|
||||||
|
' Not receiving data for LONG_POLL_TIMEOUT_MS seconds might be a sign of a dead connection
|
||||||
|
if m.socket_timer.TotalMilliseconds() > LONG_POLL_TIMEOUT_MS
|
||||||
|
LogWarn("Timeout after", LONG_POLL_TIMEOUT_MS, "ms")
|
||||||
|
m.CloseSocket()
|
||||||
|
return false
|
||||||
|
end if
|
||||||
|
|
||||||
|
if socketMessages.Count() = 0
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
|
||||||
|
hasDataToReceive = false
|
||||||
|
for each socketMessage in socketMessages
|
||||||
|
if socketMessage.GetSocketID() = socket.GetID()
|
||||||
|
hasDataToReceive = true
|
||||||
|
exit for
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
|
||||||
|
if not hasDataToReceive
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
|
||||||
|
data = socket.ReceiveStr(LONG_POLL_BUFSIZE)
|
||||||
|
if not socket.eSuccess()
|
||||||
|
LogError("Error receiving data")
|
||||||
|
m.CloseSocket()
|
||||||
|
return false
|
||||||
|
end if
|
||||||
|
|
||||||
|
m.socket_timer.Mark()
|
||||||
|
|
||||||
|
if m.socket_buffer = invalid
|
||||||
|
m.socket_buffer = ""
|
||||||
|
end if
|
||||||
|
|
||||||
|
m.socket_buffer += data
|
||||||
|
|
||||||
|
return m.ParseData()
|
||||||
|
end function
|
||||||
|
|
||||||
|
function IsOpen() as boolean
|
||||||
|
return m.socket <> invalid and m.socket.IsConnected()
|
||||||
|
end function
|
||||||
|
|
||||||
|
function CloseSocket() as void
|
||||||
|
if m.socket = invalid
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
m.socket.notifyReadable(false)
|
||||||
|
m.socket.close()
|
||||||
|
m.socket = invalid
|
||||||
|
m.socket_buffer = invalid
|
||||||
|
m.socket_state = HttpResponseState.INIT
|
||||||
|
end function
|
||||||
|
|
||||||
|
function ParseData() as dynamic
|
||||||
|
if m.socket_state = HttpResponseState.INIT
|
||||||
|
m.socket_state = HttpResponseState.READING_STATUS
|
||||||
|
end if
|
||||||
|
|
||||||
|
if m.socket_state = HttpResponseState.READING_STATUS
|
||||||
|
if not m.ParseOpration()
|
||||||
|
return false
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
|
||||||
|
if m.socket_state = HttpResponseState.READING_HEADERS
|
||||||
|
if not m.ParseHeaders()
|
||||||
|
return false
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
|
||||||
|
chunks = []
|
||||||
|
READING_BODY_CHUNK_SIZE:
|
||||||
|
if m.socket_state = HttpResponseState.READING_BODY_CHUNK_SIZE
|
||||||
|
if not m.ParseChunkSize()
|
||||||
|
return chunks
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
|
||||||
|
if m.socket_state = HttpResponseState.READING_BODY_CHUNK
|
||||||
|
chunk = m.ParseChunk()
|
||||||
|
if IsBool(chunk)
|
||||||
|
if not chunk
|
||||||
|
return chunks
|
||||||
|
end if
|
||||||
|
else
|
||||||
|
chunks.Push(chunk)
|
||||||
|
goto READING_BODY_CHUNK_SIZE
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
|
||||||
|
return chunks
|
||||||
|
end function
|
||||||
|
|
||||||
|
function ParseOpration() as boolean
|
||||||
|
newLineIndex = m.socket_buffer.InStr(`\r\n`)
|
||||||
|
if newLineIndex > 0
|
||||||
|
operationLine = m.socket_buffer.Left(newLineIndex)
|
||||||
|
parts = operationLine.Split(" ")
|
||||||
|
if parts.Count() <> 3 or parts[0] <> "HTTP/1.1"
|
||||||
|
LogError("Invalid operation line:", operationLine)
|
||||||
|
m.CloseSocket()
|
||||||
|
return false
|
||||||
|
end if
|
||||||
|
|
||||||
|
m.status_code = Val(parts[1])
|
||||||
|
if not m.status_code = 200
|
||||||
|
LogError("Http status code:", m.status_code)
|
||||||
|
LogError("Response data:", m.socket_buffer)
|
||||||
|
m.CloseSocket()
|
||||||
|
return false
|
||||||
|
end if
|
||||||
|
|
||||||
|
m.socket_buffer = m.socket_buffer.Mid(newLineIndex + 2)
|
||||||
|
m.socket_state = HttpResponseState.READING_HEADERS
|
||||||
|
end if
|
||||||
|
|
||||||
|
return true
|
||||||
|
end function
|
||||||
|
|
||||||
|
function ParseHeaders() as boolean
|
||||||
|
newLineIndex = m.socket_buffer.InStr(`\r\n\r\n`)
|
||||||
|
if newLineIndex > 0
|
||||||
|
headersStr = m.socket_buffer.Left(newLineIndex)
|
||||||
|
|
||||||
|
headers = {}
|
||||||
|
headerLines = headersStr.Split(`\r\n`)
|
||||||
|
for each headerLine in headerLines
|
||||||
|
colonIndex = headerLine.InStr(":")
|
||||||
|
key = headerLine.Left(colonIndex).Trim()
|
||||||
|
value = headerLine.Mid(colonIndex + 1).Trim()
|
||||||
|
headers[key] = value
|
||||||
|
end for
|
||||||
|
m.headers = headers
|
||||||
|
|
||||||
|
LogDebug("Headers:", headers)
|
||||||
|
|
||||||
|
if headers["Transfer-Encoding"] <> "chunked"
|
||||||
|
LogError("Invalid transfer encoding:", headers["Transfer-Encoding"])
|
||||||
|
m.CloseSocket()
|
||||||
|
return false
|
||||||
|
end if
|
||||||
|
|
||||||
|
m.socket_buffer = m.socket_buffer.Mid(newLineIndex + 4)
|
||||||
|
m.socket_state = HttpResponseState.READING_BODY_CHUNK_SIZE
|
||||||
|
end if
|
||||||
|
return true
|
||||||
|
end function
|
||||||
|
|
||||||
|
function ParseChunkSize() as boolean
|
||||||
|
m.ConsumeNewLines()
|
||||||
|
newLineIndex = m.socket_buffer.InStr(`\r\n`)
|
||||||
|
if newLineIndex > 0
|
||||||
|
chunkSize = m.socket_buffer.Left(newLineIndex)
|
||||||
|
chunkSize = chunkSize.Trim()
|
||||||
|
chunkSize = Val(chunkSize, 16)
|
||||||
|
LogDebug("Chunk size:", chunkSize)
|
||||||
|
m.socket_chunk_size = chunkSize
|
||||||
|
if chunkSize = 0
|
||||||
|
LogDebug("End of chunked data")
|
||||||
|
m.CloseSocket()
|
||||||
|
return false
|
||||||
|
end if
|
||||||
|
m.socket_buffer = m.socket_buffer.Mid(newLineIndex + 2)
|
||||||
|
m.socket_state = HttpResponseState.READING_BODY_CHUNK
|
||||||
|
end if
|
||||||
|
|
||||||
|
return true
|
||||||
|
end function
|
||||||
|
|
||||||
|
function ParseChunk() as dynamic
|
||||||
|
if m.socket_chunk_size > 0
|
||||||
|
if m.socket_buffer.Len() >= m.socket_chunk_size
|
||||||
|
chunk = m.socket_buffer.Left(m.socket_chunk_size)
|
||||||
|
m.socket_buffer = m.socket_buffer.Mid(m.socket_chunk_size)
|
||||||
|
m.socket_chunk_size = 0
|
||||||
|
m.socket_state = HttpResponseState.READING_BODY_CHUNK_SIZE
|
||||||
|
return chunk
|
||||||
|
end if
|
||||||
|
else
|
||||||
|
LogError("Invalid chunk size")
|
||||||
|
m.CloseSocket()
|
||||||
|
return false
|
||||||
|
end if
|
||||||
|
|
||||||
|
return true
|
||||||
|
end function
|
||||||
|
|
||||||
|
function ConsumeNewLines()
|
||||||
|
CR = `\r`
|
||||||
|
LF = `\n`
|
||||||
|
startIndex = 0
|
||||||
|
while true
|
||||||
|
char = m.socket_buffer.Mid(startIndex, 1)
|
||||||
|
if char = CR or char = LF
|
||||||
|
startIndex += 1
|
||||||
|
else
|
||||||
|
exit while
|
||||||
|
end if
|
||||||
|
end while
|
||||||
|
|
||||||
|
if startIndex > 0
|
||||||
|
m.socket_buffer = m.socket_buffer.Mid(startIndex)
|
||||||
|
end if
|
||||||
|
end function
|
||||||
|
|
||||||
|
function ToCurlCommand() as string
|
||||||
|
' It won't work the same since it will disconnect quickly
|
||||||
|
return `curl "${m.url}"`
|
||||||
|
end function
|
||||||
|
|
||||||
|
end class
|
||||||
@@ -0,0 +1,583 @@
|
|||||||
|
import "pkg:/components/Dialog/DialogUtils.bs"
|
||||||
|
import "pkg:/components/Services/Invidious/InvidiousToContentNode.bs"
|
||||||
|
import "pkg:/components/Services/LoungeService/LongPoller.bs"
|
||||||
|
import "pkg:/components/Services/LoungeService/LoungeConstants.bs"
|
||||||
|
import "pkg:/components/Services/LoungeService/LoungeMessages.bs"
|
||||||
|
import "pkg:/components/Services/LoungeService/LoungeVideoQueue.bs"
|
||||||
|
import "pkg:/components/Services/LoungeService/Notifications/DeviceConnectedNotificationUtils.bs"
|
||||||
|
import "pkg:/source/services/HttpClient.bs"
|
||||||
|
import "pkg:/source/utils/Logging.bs"
|
||||||
|
import "pkg:/source/utils/RegistryUtils.bs"
|
||||||
|
import "pkg:/source/utils/StringUtils.bs"
|
||||||
|
import "pkg:/source/utils/UrlUtils.bs"
|
||||||
|
|
||||||
|
const COMMAND_HANDLER_PREFIX = "_Handle_"
|
||||||
|
|
||||||
|
class LoungeApi
|
||||||
|
|
||||||
|
public loungeServiceNode
|
||||||
|
public videoQueueNode
|
||||||
|
public notificationsNode
|
||||||
|
public invService
|
||||||
|
|
||||||
|
public deviceId
|
||||||
|
public deviceName
|
||||||
|
public screenId
|
||||||
|
public screenName
|
||||||
|
public loungeToken
|
||||||
|
public sessionId
|
||||||
|
public gSessionId
|
||||||
|
|
||||||
|
private ofs
|
||||||
|
private lastProcessedCommandIndex = -1
|
||||||
|
private poller
|
||||||
|
private outgoingMessagesRequests
|
||||||
|
|
||||||
|
function new(loungeServiceNode as object, videoQueueNode as object, notificationsNode as object, invidiousNode as object)
|
||||||
|
m.loungeServiceNode = loungeServiceNode
|
||||||
|
m.videoQueueNode = videoQueueNode
|
||||||
|
m.notificationsNode = notificationsNode
|
||||||
|
m.invService = new Invidious.InvidiousService(invidiousNode)
|
||||||
|
m.dateTime = CreateObject("roDateTime")
|
||||||
|
m.deviceId = loungeServiceNode.deviceId
|
||||||
|
deviceName = loungeServiceNode.deviceName
|
||||||
|
m.deviceName = deviceName
|
||||||
|
m.screenName = deviceName
|
||||||
|
m.ofs = 0
|
||||||
|
m.poller = invalid
|
||||||
|
m.outgoingMessagesRequests = {}
|
||||||
|
|
||||||
|
commandHandlers = {}
|
||||||
|
commandHandlers[COMMAND_TYPE_NOOP] = m.HandleIgnoreCommand
|
||||||
|
commandHandlers[COMMAND_TYPE_GET_VOLUME] = m.HandleIgnoreCommand
|
||||||
|
commandHandlers[COMMAND_TYPE_GET_SUBTITLES_TRACK] = m.HandleIgnoreCommand
|
||||||
|
commandHandlers[COMMAND_TYPE_SET_SUBTITLES] = m.HandleIgnoreCommand
|
||||||
|
commandHandlers[COMMAND_TYPE_DPAD_COMMAND] = m.HandleIgnoreCommand
|
||||||
|
commandHandlers[COMMAND_TYPE_VOICE_COMMAND] = m.HandleIgnoreCommand
|
||||||
|
commandHandlers[COMMAND_TYPE_ON_USER_ACTIVITY] = m.HandleIgnoreCommand
|
||||||
|
|
||||||
|
commandHandlers[COMMAND_TYPE_GET_NOW_PLAYING] = m.HandleGetPlayingNow
|
||||||
|
commandHandlers[COMMAND_TYPE_SESSION_ID] = m.HandleSessionId
|
||||||
|
commandHandlers[COMMAND_TYPE_G_SESSION_ID] = m.HandleGSessionId
|
||||||
|
commandHandlers[COMMAND_TYPE_LOUNGE_STATUS] = m.HandleLoungeStatus
|
||||||
|
commandHandlers[COMMAND_TYPE_REMOTE_CONNECTED] = m.HandleRemoteConnected
|
||||||
|
commandHandlers[COMMAND_TYPE_REMOTE_DISCONNECTED] = m.HandleRemoteDisconnected
|
||||||
|
commandHandlers[COMMAND_TYPE_SET_VOLUME] = m.HandleSetVolume
|
||||||
|
commandHandlers[COMMAND_TYPE_SET_PLAYLIST] = m.HandleSetPlaylist
|
||||||
|
commandHandlers[COMMAND_TYPE_UPDATE_PLAYLIST] = m.HandleUpdatePlaylist
|
||||||
|
commandHandlers[COMMAND_TYPE_PAUSE] = m.HandlePause
|
||||||
|
commandHandlers[COMMAND_TYPE_PLAY] = m.HandlePlay
|
||||||
|
commandHandlers[COMMAND_TYPE_STOP_VIDEO] = m.HandleStopVideo
|
||||||
|
commandHandlers[COMMAND_TYPE_SEEK_TO] = m.HandleSeekTo
|
||||||
|
|
||||||
|
for each key in commandHandlers
|
||||||
|
m[COMMAND_HANDLER_PREFIX + key] = commandHandlers[key]
|
||||||
|
end for
|
||||||
|
end function
|
||||||
|
|
||||||
|
function Zx() as string
|
||||||
|
' Math.floor(2147483648 * Math.random()).toString(36) + Math.abs(Math.floor(2147483648 * Math.random()) ^ Date.now()).toString(36)
|
||||||
|
rnd1% = rnd(2147483647)
|
||||||
|
rnd2& = rnd(2147483647)
|
||||||
|
m.dateTime.mark()
|
||||||
|
now& = m.dateTime.AsSeconds()
|
||||||
|
now& = now& * 1000 + m.dateTime.GetMilliseconds()
|
||||||
|
rnd2xor& = (rnd2& or now&) and not (rnd2& and now&)
|
||||||
|
return StrI(rnd1%, 36) + StrI(Abs(rnd2xor&), 36)
|
||||||
|
end function
|
||||||
|
|
||||||
|
function GetScreenId() as dynamic
|
||||||
|
if not StringUtils.IsNullOrEmpty(m.screenId)
|
||||||
|
return m.screenId
|
||||||
|
end if
|
||||||
|
|
||||||
|
request = HttpClient.Get("https://www.youtube.com/api/lounge/pairing/generate_screen_id")
|
||||||
|
response = request.Await()
|
||||||
|
if not response.IsSuccess()
|
||||||
|
error = `Failed to get screen id. Please restart playlet to use the cast function.\n${response.ErrorMessage()}`
|
||||||
|
LogError(error)
|
||||||
|
DialogUtils.ShowDialog(error, "Lounge service setup error")
|
||||||
|
return invalid
|
||||||
|
end if
|
||||||
|
id = response.Text()
|
||||||
|
if not IsString(id)
|
||||||
|
error = `Failed to get screen id. Please restart playlet to use the cast function.\nNot a valid screen id: ${id}`
|
||||||
|
LogError(error)
|
||||||
|
DialogUtils.ShowDialog(error, "Lounge service setup error")
|
||||||
|
return invalid
|
||||||
|
end if
|
||||||
|
m.screenId = id
|
||||||
|
return id
|
||||||
|
end function
|
||||||
|
|
||||||
|
function GetToken() as dynamic
|
||||||
|
if not StringUtils.IsNullOrEmpty(m.loungeToken)
|
||||||
|
return m.loungeToken
|
||||||
|
end if
|
||||||
|
|
||||||
|
form = UrlUtils.GetUrlEncodedForm({ "screen_ids": m.screenId })
|
||||||
|
request = HttpClient.Post("https://www.youtube.com/api/lounge/pairing/get_lounge_token_batch", form)
|
||||||
|
request.Header("Content-Type", "application/x-www-form-urlencoded")
|
||||||
|
response = request.Await()
|
||||||
|
if not response.IsSuccess()
|
||||||
|
error = `Failed to get lounge token. Please restart playlet to use the cast function.\n${response.ErrorMessage()}`
|
||||||
|
LogError(error)
|
||||||
|
DialogUtils.ShowDialog(error, "Lounge service setup error")
|
||||||
|
return invalid
|
||||||
|
end if
|
||||||
|
|
||||||
|
json = response.Json()
|
||||||
|
screens = json.screens
|
||||||
|
if not IsArray(screens) or screens.Count() <> 1
|
||||||
|
error = `Failed to get lounge token. Please restart playlet to use the cast function.\nInvalid response: ${json}`
|
||||||
|
LogError(error)
|
||||||
|
DialogUtils.ShowDialog(error, "Lounge service setup error")
|
||||||
|
return invalid
|
||||||
|
end if
|
||||||
|
|
||||||
|
' payload contains more information, but we only need the token
|
||||||
|
m.loungeToken = screens[0].loungeToken
|
||||||
|
return m.loungeToken
|
||||||
|
end function
|
||||||
|
|
||||||
|
function GetSessionData() as boolean
|
||||||
|
baseUrl = "https://www.youtube.com/api/lounge/bc/bind"
|
||||||
|
queryParams = {
|
||||||
|
"device": "LOUNGE_SCREEN"
|
||||||
|
"theme": "cl"
|
||||||
|
"capabilities": ""
|
||||||
|
"mdxVersion": "2"
|
||||||
|
"VER": "8"
|
||||||
|
"v": "2"
|
||||||
|
"t": "1"
|
||||||
|
"app": "lb-v4"
|
||||||
|
"RID": "1337"
|
||||||
|
}
|
||||||
|
|
||||||
|
queryParams["name"] = m.screenName
|
||||||
|
queryParams["id"] = m.deviceId
|
||||||
|
queryParams["loungeIdToken"] = m.loungeToken
|
||||||
|
queryParams["zx"] = m.Zx()
|
||||||
|
|
||||||
|
url = UrlUtils.BuildUrl(baseUrl, invalid, queryParams)
|
||||||
|
|
||||||
|
request = HttpClient.Post(url, "count=0")
|
||||||
|
request.Header("Content-Type", "application/x-www-form-urlencoded")
|
||||||
|
|
||||||
|
response = request.Await()
|
||||||
|
if not response.IsSuccess()
|
||||||
|
error = `Failed to get session data. Please restart playlet to use the cast function.\n${response.ErrorMessage()}`
|
||||||
|
LogError(error)
|
||||||
|
DialogUtils.ShowDialog(error, "Lounge service setup error")
|
||||||
|
return false
|
||||||
|
end if
|
||||||
|
|
||||||
|
text = response.Text()
|
||||||
|
' First line should be a number, which is the length of the JSON payload
|
||||||
|
text = text.Mid(text.instr(`\n`) + 1)
|
||||||
|
|
||||||
|
messagesToSend = []
|
||||||
|
commands = ParseJson(text)
|
||||||
|
m.ProcessCommands(commands, messagesToSend)
|
||||||
|
m.SendMessages(messagesToSend)
|
||||||
|
return true
|
||||||
|
end function
|
||||||
|
|
||||||
|
function FetchCommandsRpc(messagePort as object) as void
|
||||||
|
' Note we're not using https, not supported by LongPoller
|
||||||
|
baseUrl = "http://www.youtube.com/api/lounge/bc/bind"
|
||||||
|
queryParams = {
|
||||||
|
"device": "LOUNGE_SCREEN"
|
||||||
|
"theme": "cl"
|
||||||
|
"capabilities": ""
|
||||||
|
"mdxVersion": "2"
|
||||||
|
"VER": "8"
|
||||||
|
"v": "2"
|
||||||
|
"t": "1"
|
||||||
|
"app": "lb-v4"
|
||||||
|
"RID": "rpc"
|
||||||
|
"CI": "0"
|
||||||
|
}
|
||||||
|
|
||||||
|
queryParams["name"] = m.screenName
|
||||||
|
queryParams["id"] = m.deviceId
|
||||||
|
queryParams["loungeIdToken"] = m.loungeToken
|
||||||
|
queryParams["SID"] = m.sessionId
|
||||||
|
queryParams["gsessionid"] = m.gSessionId
|
||||||
|
queryParams["zx"] = m.Zx()
|
||||||
|
|
||||||
|
url = UrlUtils.BuildUrl(baseUrl, invalid, queryParams)
|
||||||
|
|
||||||
|
if m.poller = invalid
|
||||||
|
m.poller = new LongPoller()
|
||||||
|
end if
|
||||||
|
|
||||||
|
m.poller.SendRequest(url, messagePort)
|
||||||
|
end function
|
||||||
|
|
||||||
|
function Poll(socketMessages as object, messagesToSend as object) as boolean
|
||||||
|
chunks = m.poller.Poll(socketMessages)
|
||||||
|
if IsArray(chunks)
|
||||||
|
for each chunk in chunks
|
||||||
|
m.ProcessChunk(chunk, messagesToSend)
|
||||||
|
end for
|
||||||
|
end if
|
||||||
|
|
||||||
|
return m.poller.IsOpen()
|
||||||
|
end function
|
||||||
|
|
||||||
|
function ProcessChunk(chunk as string, messagesToSend as object) as void
|
||||||
|
chunk = m.ConsumeNewLines(chunk)
|
||||||
|
newLineIndex = chunk.InStr(`\n`)
|
||||||
|
while newLineIndex > 0
|
||||||
|
payloadSize = chunk.Left(newLineIndex).trim()
|
||||||
|
payloadSize = payloadSize.ToInt()
|
||||||
|
payload = chunk.Mid(newLineIndex + 1, payloadSize)
|
||||||
|
commands = ParseJson(payload)
|
||||||
|
m.ProcessCommands(commands, messagesToSend)
|
||||||
|
chunk = chunk.Mid(newLineIndex + payloadSize + 1)
|
||||||
|
newLineIndex = chunk.InStr(`\n`)
|
||||||
|
end while
|
||||||
|
end function
|
||||||
|
|
||||||
|
function ConsumeNewLines(chunk as string) as string
|
||||||
|
CR = `\r`
|
||||||
|
LF = `\n`
|
||||||
|
startIndex = 0
|
||||||
|
while true
|
||||||
|
char = chunk.Mid(startIndex, 1)
|
||||||
|
if char = CR or char = LF
|
||||||
|
startIndex += 1
|
||||||
|
else
|
||||||
|
exit while
|
||||||
|
end if
|
||||||
|
end while
|
||||||
|
|
||||||
|
if startIndex > 0
|
||||||
|
return chunk.Mid(startIndex)
|
||||||
|
end if
|
||||||
|
|
||||||
|
return chunk
|
||||||
|
end function
|
||||||
|
|
||||||
|
function ProcessCommands(commands as object, messagesToSend as object) as void
|
||||||
|
if not IsArray(commands)
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
for each command in commands
|
||||||
|
if not IsArray(command) or command.Count() <> 2
|
||||||
|
continue for
|
||||||
|
end if
|
||||||
|
|
||||||
|
commandIndex = command[0]
|
||||||
|
if commandIndex <= m.lastProcessedCommandIndex
|
||||||
|
LogDebug("Skipping command already processed:", command)
|
||||||
|
continue for
|
||||||
|
end if
|
||||||
|
m.lastProcessedCommandIndex = commandIndex
|
||||||
|
|
||||||
|
commandId = command[0]
|
||||||
|
commandData = command[1]
|
||||||
|
commandType = commandData[0]
|
||||||
|
commandArgs = invalid
|
||||||
|
if commandData.Count() > 1
|
||||||
|
commandArgs = commandData[1]
|
||||||
|
end if
|
||||||
|
|
||||||
|
handler = COMMAND_HANDLER_PREFIX + commandType
|
||||||
|
if m.DoesExist(handler)
|
||||||
|
LogInfo(commandType)
|
||||||
|
m[handler](commandId, commandType, commandArgs, messagesToSend)
|
||||||
|
else
|
||||||
|
LogWarn("Unknown command type:", commandType, "command:", command)
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
end function
|
||||||
|
|
||||||
|
function HandleIgnoreCommand(commandId as integer, commandType as string, commandArgs as object, messagesToSend as object)
|
||||||
|
LogDebug("Ignoring command:", commandType, "args:", commandArgs)
|
||||||
|
end function
|
||||||
|
|
||||||
|
function HandleSessionId(commandId as integer, commandType as string, commandArgs as object, messagesToSend as object)
|
||||||
|
m.sessionId = commandArgs
|
||||||
|
LogInfo("sessionId:", m.sessionId)
|
||||||
|
end function
|
||||||
|
|
||||||
|
function HandleGSessionId(commandId as integer, commandType as string, commandArgs as object, messagesToSend as object)
|
||||||
|
m.gSessionId = commandArgs
|
||||||
|
LogInfo("gSessionId:", m.gSessionId)
|
||||||
|
end function
|
||||||
|
|
||||||
|
function HandleGetPlayingNow(commandId as integer, commandType as string, commandArgs as object, messagesToSend as object) as void
|
||||||
|
player = m.videoQueueNode.player
|
||||||
|
|
||||||
|
message = LoungeMessages.OnHasPreviousNextChanged(m.videoQueueNode.hasPrevious, m.videoQueueNode.hasNext)
|
||||||
|
message["commandId"] = commandId
|
||||||
|
messagesToSend.Push(message)
|
||||||
|
|
||||||
|
message = LoungeMessages.NowPlaying(player)
|
||||||
|
message["commandId"] = commandId
|
||||||
|
messagesToSend.Push(message)
|
||||||
|
|
||||||
|
message = LoungeMessages.OnStateChange(player)
|
||||||
|
message["commandId"] = commandId
|
||||||
|
messagesToSend.Push(message)
|
||||||
|
end function
|
||||||
|
|
||||||
|
function HandleLoungeStatus(commandId as integer, commandType as string, commandArgs as object, messagesToSend as object) as void
|
||||||
|
LogInfo(commandType, FormatJson(commandArgs))
|
||||||
|
devices = commandArgs["devices"]
|
||||||
|
if not IsString(devices)
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
devices = ParseJson(devices)
|
||||||
|
if devices = invalid
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
devicesDict = {}
|
||||||
|
for each device in devices
|
||||||
|
devicesDict[device.id] = device
|
||||||
|
end for
|
||||||
|
|
||||||
|
m.loungeServiceNode.devices = devicesDict
|
||||||
|
end function
|
||||||
|
|
||||||
|
function HandleRemoteConnected(commandId as integer, commandType as string, commandArgs as object, messagesToSend as object) as void
|
||||||
|
LogInfo(commandType)
|
||||||
|
newDevice = commandArgs
|
||||||
|
id = newDevice.id
|
||||||
|
if StringUtils.IsNullOrEmpty(id)
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
devices = m.loungeServiceNode.devices
|
||||||
|
if devices = invalid
|
||||||
|
devices = {}
|
||||||
|
end if
|
||||||
|
|
||||||
|
if devices.DoesExist(id)
|
||||||
|
device = devices[id]
|
||||||
|
device.Append(newDevice)
|
||||||
|
newDevice = device
|
||||||
|
end if
|
||||||
|
|
||||||
|
devices[id] = newDevice
|
||||||
|
m.loungeServiceNode.devices = devices
|
||||||
|
|
||||||
|
userName = newDevice.user
|
||||||
|
deviceName = newDevice.name
|
||||||
|
userAvatarUri = newDevice.userAvatarUri
|
||||||
|
|
||||||
|
LoungeDeviceConnected.ShowNotifcation(m.notificationsNode, deviceName, userName, userAvatarUri)
|
||||||
|
end function
|
||||||
|
|
||||||
|
function HandleRemoteDisconnected(commandId as integer, commandType as string, commandArgs as object, messagesToSend as object) as void
|
||||||
|
LogInfo(commandType)
|
||||||
|
device = commandArgs
|
||||||
|
id = device.id
|
||||||
|
if StringUtils.IsNullOrEmpty(id)
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
devices = m.loungeServiceNode.devices
|
||||||
|
if devices = invalid
|
||||||
|
devices = {}
|
||||||
|
end if
|
||||||
|
if devices.Delete(id)
|
||||||
|
m.loungeServiceNode.devices = devices
|
||||||
|
end if
|
||||||
|
' TODO:P1 disconnect notification
|
||||||
|
end function
|
||||||
|
|
||||||
|
function HandleSetVolume(commandId as integer, commandType as string, commandArgs as object, messagesToSend as object) as void
|
||||||
|
player = m.videoQueueNode.player
|
||||||
|
if player = invalid
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
volume = Val(commandArgs["volume"])
|
||||||
|
isMute = volume = 0
|
||||||
|
LogInfo("Setting volume is not supported:", volume, "but can mute:", isMute)
|
||||||
|
' TODO:P2 volume should be set to the lounge state.
|
||||||
|
' Also the state needs to be separate from the player, since SponsorBlock can mute sections.
|
||||||
|
player.mute = isMute
|
||||||
|
end function
|
||||||
|
|
||||||
|
function HandleSetPlaylist(commandId as integer, commandType as string, commandArgs as object, messagesToSend as object)
|
||||||
|
LogDebug(commandType, commandArgs)
|
||||||
|
LoungeVideoQueue.SetPlaylist(m.videoQueueNode, m.invService, commandArgs)
|
||||||
|
end function
|
||||||
|
|
||||||
|
function HandleUpdatePlaylist(commandId as integer, commandType as string, commandArgs as object, messagesToSend as object)
|
||||||
|
LogDebug(commandType, commandArgs)
|
||||||
|
LoungeVideoQueue.UpdatePlaylist(m.videoQueueNode, m.invService, commandArgs)
|
||||||
|
end function
|
||||||
|
|
||||||
|
function HandlePause(commandId as integer, commandType as string, commandArgs as object, messagesToSend as object)
|
||||||
|
m.videoQueueNode.pause = true
|
||||||
|
end function
|
||||||
|
|
||||||
|
function HandlePlay(commandId as integer, commandType as string, commandArgs as object, messagesToSend as object)
|
||||||
|
m.videoQueueNode.play = true
|
||||||
|
end function
|
||||||
|
|
||||||
|
function HandleStopVideo(commandId as integer, commandType as string, commandArgs as object, messagesToSend as object)
|
||||||
|
m.videoQueueNode.closePlayer = true
|
||||||
|
end function
|
||||||
|
|
||||||
|
function HandleSeekTo(commandId as integer, commandType as string, commandArgs as object, messagesToSend as object) as void
|
||||||
|
player = m.videoQueueNode.player
|
||||||
|
if player = invalid
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
seekTo = Val(commandArgs[FIELD_NEW_TIME])
|
||||||
|
LogInfo("Seeking to:", seekTo)
|
||||||
|
player.seek = seekTo
|
||||||
|
end function
|
||||||
|
|
||||||
|
function SendMessages(messages as object, loungeData = invalid as object) as void
|
||||||
|
if messages.Count() = 0
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
baseUrl = "https://www.youtube.com/api/lounge/bc/bind"
|
||||||
|
queryParams = {
|
||||||
|
"device": "LOUNGE_SCREEN"
|
||||||
|
"theme": "cl"
|
||||||
|
"capabilities": ""
|
||||||
|
"mdxVersion": "2"
|
||||||
|
"VER": "8"
|
||||||
|
"v": "2"
|
||||||
|
"t": "1"
|
||||||
|
"app": "lb-v4"
|
||||||
|
"RID": "1337"
|
||||||
|
}
|
||||||
|
|
||||||
|
if loungeData = invalid
|
||||||
|
loungeData = m
|
||||||
|
end if
|
||||||
|
|
||||||
|
queryParams["name"] = loungeData.screenName
|
||||||
|
queryParams["id"] = loungeData.deviceId
|
||||||
|
queryParams["loungeIdToken"] = loungeData.loungeToken
|
||||||
|
queryParams["SID"] = loungeData.sessionId
|
||||||
|
queryParams["gsessionid"] = loungeData.gSessionId
|
||||||
|
queryParams["zx"] = m.Zx()
|
||||||
|
if messages[0].commandId <> invalid
|
||||||
|
queryParams["AID"] = messages[0].commandId
|
||||||
|
end if
|
||||||
|
|
||||||
|
url = UrlUtils.BuildUrl(baseUrl, invalid, queryParams)
|
||||||
|
|
||||||
|
postData = [
|
||||||
|
{ key: "count", value: messages.Count() }
|
||||||
|
{ key: "ofs", value: loungeData.ofs }
|
||||||
|
]
|
||||||
|
|
||||||
|
loungeData.ofs += messages.Count()
|
||||||
|
|
||||||
|
for i = 0 to messages.Count() - 1
|
||||||
|
message = messages[i]
|
||||||
|
keyPrefix = `req${i}_`
|
||||||
|
|
||||||
|
postData.Push({ key: `${keyPrefix}${FIELD_COMMAND_NAME}`, value: message.commandType })
|
||||||
|
|
||||||
|
commandArgs = message.commandArgs
|
||||||
|
if commandArgs <> invalid
|
||||||
|
for each key in commandArgs
|
||||||
|
postData.Push({ key: `${keyPrefix}${key}`, value: commandArgs[key] })
|
||||||
|
end for
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
|
||||||
|
LogDebug("Sending messages:", postData)
|
||||||
|
|
||||||
|
body = UrlUtils.GetUrlEncodedForm(postData)
|
||||||
|
request = HttpClient.Post(url, body)
|
||||||
|
request.Header("Content-Type", "application/x-www-form-urlencoded")
|
||||||
|
request.Send()
|
||||||
|
|
||||||
|
' we do not need to wait for requests to finish, we check on them later
|
||||||
|
' to avoid blocking the thread.
|
||||||
|
' This is specific to sent lounge messages, since we're not waiting for a response.
|
||||||
|
requestId = request.urlTransfer.GetIdentity().ToStr()
|
||||||
|
m.outgoingMessagesRequests[requestId] = request
|
||||||
|
end function
|
||||||
|
|
||||||
|
function ProcessPendingOutgoingMessages()
|
||||||
|
for each key in m.outgoingMessagesRequests
|
||||||
|
request = m.outgoingMessagesRequests[key]
|
||||||
|
if request.IsCompleted()
|
||||||
|
response = request.Await()
|
||||||
|
if not response.IsSuccess()
|
||||||
|
LogError(response.ErrorMessage())
|
||||||
|
end if
|
||||||
|
|
||||||
|
m.outgoingMessagesRequests.Delete(key)
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
end function
|
||||||
|
|
||||||
|
function SaveCurrentLoungeData() as void
|
||||||
|
loungeData = {
|
||||||
|
"__version": 1
|
||||||
|
}
|
||||||
|
fields = ["screenName", "deviceId", "loungeToken", "sessionId", "gSessionId"]
|
||||||
|
for each field in fields
|
||||||
|
if StringUtils.IsNullOrEmpty(m[field])
|
||||||
|
LogWarn("Lounge data will not be saved. missing field:", field)
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
loungeData[field] = m[field]
|
||||||
|
end for
|
||||||
|
|
||||||
|
loungeData = FormatJson(loungeData)
|
||||||
|
RegistryUtils.Write(RegistryUtils.LAST_LOUNGE_DATA, loungeData)
|
||||||
|
end function
|
||||||
|
|
||||||
|
function DisconnectFromLastLounge() as void
|
||||||
|
loungeData = RegistryUtils.Read(RegistryUtils.LAST_LOUNGE_DATA)
|
||||||
|
if loungeData = invalid
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
RegistryUtils.Delete(RegistryUtils.LAST_LOUNGE_DATA)
|
||||||
|
|
||||||
|
loungeData = ParseJson(loungeData)
|
||||||
|
if not IsAssociativeArray(loungeData)
|
||||||
|
LogWarn("Can't disconnect from lounge. Invalid data:", loungeData)
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
if ValidInt(loungeData.__version) <> 1
|
||||||
|
LogWarn("Can't disconnect from lounge. Unknown version:", loungeData.__version)
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
fields = ["screenName", "deviceId", "loungeToken", "sessionId", "gSessionId"]
|
||||||
|
for each field in fields
|
||||||
|
if StringUtils.IsNullOrEmpty(loungeData[field])
|
||||||
|
LogWarn("Can't disconnect from lounge. Missing field:", field)
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
|
||||||
|
messages = [{
|
||||||
|
"commandType": COMMAND_LOUNGE_SCREEN_DISCONNECTED
|
||||||
|
}]
|
||||||
|
|
||||||
|
LogInfo("Disconnecting from last lounge")
|
||||||
|
' Every time we send messages, we need to increment the ofs.
|
||||||
|
' This is so that the server recognizes old messages and doesn't process them.
|
||||||
|
' But we're currently disconnecting from a previous session, and since
|
||||||
|
' we didn't keep track of the ofs, so we'll just set it to a large number.
|
||||||
|
' This is the last message we'll be sending to this lounge.
|
||||||
|
loungeData.ofs = 99999999
|
||||||
|
m.SendMessages(messages, loungeData)
|
||||||
|
end function
|
||||||
|
|
||||||
|
end class
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
' Outgoing commands
|
||||||
|
const COMMAND_NOW_PLAYING = "nowPlaying"
|
||||||
|
const COMMAND_ON_STATE_CHANGE = "onStateChange"
|
||||||
|
const COMMAND_ON_VOLUME_CHANGED = "onVolumeChanged"
|
||||||
|
const COMMAND_ON_PREVIOUS_NEXT_CHANGE = "onHasPreviousNextChanged"
|
||||||
|
const COMMAND_LOUNGE_SCREEN_DISCONNECTED = "loungeScreenDisconnected"
|
||||||
|
' Incoming commands
|
||||||
|
const COMMAND_TYPE_SET_PLAYLIST = "setPlaylist"
|
||||||
|
const COMMAND_TYPE_LOUNGE_STATUS = "loungeStatus"
|
||||||
|
const COMMAND_TYPE_REMOTE_CONNECTED = "remoteConnected"
|
||||||
|
const COMMAND_TYPE_REMOTE_DISCONNECTED = "remoteDisconnected"
|
||||||
|
const COMMAND_TYPE_GET_NOW_PLAYING = "getNowPlaying"
|
||||||
|
const COMMAND_TYPE_GET_VOLUME = "getVolume"
|
||||||
|
const COMMAND_TYPE_GET_SUBTITLES_TRACK = "getSubtitlesTrack"
|
||||||
|
const COMMAND_TYPE_UPDATE_PLAYLIST = "updatePlaylist"
|
||||||
|
const COMMAND_TYPE_NOOP = "noop"
|
||||||
|
const COMMAND_TYPE_PLAY = "play"
|
||||||
|
const COMMAND_TYPE_PAUSE = "pause"
|
||||||
|
const COMMAND_TYPE_NEXT = "next"
|
||||||
|
const COMMAND_TYPE_PREVIOUS = "previous"
|
||||||
|
const COMMAND_TYPE_SEEK_TO = "seekTo"
|
||||||
|
const COMMAND_TYPE_SET_VOLUME = "setVolume"
|
||||||
|
const COMMAND_TYPE_STOP_VIDEO = "stopVideo"
|
||||||
|
const COMMAND_TYPE_DPAD_COMMAND = "dpadCommand"
|
||||||
|
const COMMAND_TYPE_VOICE_COMMAND = "voiceCommand"
|
||||||
|
const COMMAND_TYPE_SET_SUBTITLES = "setSubtitlesTrack"
|
||||||
|
const COMMAND_TYPE_ON_USER_ACTIVITY = "onUserActivity"
|
||||||
|
' Special commands
|
||||||
|
const COMMAND_TYPE_SESSION_ID = "c"
|
||||||
|
const COMMAND_TYPE_G_SESSION_ID = "S"
|
||||||
|
' Dpad commands
|
||||||
|
const COMMAND_KEY_UP = "UP"
|
||||||
|
const COMMAND_KEY_DOWN = "DOWN"
|
||||||
|
const COMMAND_KEY_LEFT = "LEFT"
|
||||||
|
const COMMAND_KEY_RIGHT = "RIGHT"
|
||||||
|
const COMMAND_KEY_ENTER = "ENTER"
|
||||||
|
const COMMAND_KEY_BACK = "BACK"
|
||||||
|
' Fields
|
||||||
|
const FIELD_COUNT = "count"
|
||||||
|
const FIELD_OFS = "ofs"
|
||||||
|
const FIELD_COMMAND_NAME = "_sc"
|
||||||
|
const FIELD_STATE = "state"
|
||||||
|
const FIELD_VIDEO_ID = "videoId"
|
||||||
|
const FIELD_VIDEO_IDS = "videoIds"
|
||||||
|
const FIELD_EVENT_DETAILS = "eventDetails"
|
||||||
|
const FIELD_LIST_ID = "listId"
|
||||||
|
const FIELD_CURRENT_TIME = "currentTime"
|
||||||
|
const FIELD_DURATION = "duration"
|
||||||
|
const FIELD_VOLUME = "volume"
|
||||||
|
const FIELD_MUTED = "muted"
|
||||||
|
const FIELD_CPN = "cpn"
|
||||||
|
const FIELD_CTT = "ctt"
|
||||||
|
const FIELD_CURRENT_INDEX = "currentIndex"
|
||||||
|
const FIELD_LOADED_TIME = "loadedTime"
|
||||||
|
const FIELD_SEEKABLE_START_TIME = "seekableStartTime"
|
||||||
|
const FIELD_SEEKABLE_END_TIME = "seekableEndTime"
|
||||||
|
const FIELD_HAS_PREVIOUS = "hasPrevious"
|
||||||
|
const FIELD_HAS_NEXT = "hasNext"
|
||||||
|
const FIELD_NEW_TIME = "newTime"
|
||||||
|
|
||||||
|
enum PlayerState
|
||||||
|
UNSTARTED = -1
|
||||||
|
ENDED = 0
|
||||||
|
PLAYING = 1
|
||||||
|
PAUSED = 2
|
||||||
|
BUFFERING = 3
|
||||||
|
STOPPED = 4
|
||||||
|
VIDEO_CUED = 5
|
||||||
|
ADVERTISEMENT = 1081
|
||||||
|
UNCONFIRMED = -8002
|
||||||
|
ERROR = -8003
|
||||||
|
UNKNOWN = -8001
|
||||||
|
end enum
|
||||||
+64
@@ -0,0 +1,64 @@
|
|||||||
|
import "pkg:/components/Services/LoungeService/LoungeApi.bs"
|
||||||
|
import "pkg:/source/services/HttpClient.bs"
|
||||||
|
import "pkg:/source/utils/StringUtils.bs"
|
||||||
|
|
||||||
|
@asynctask
|
||||||
|
function LoungeGenerateManualPairingCodeTask(input as object) as object
|
||||||
|
loungeService = input.loungeService
|
||||||
|
|
||||||
|
if StringUtils.IsNullOrEmpty(input.loungeToken)
|
||||||
|
messagePort = CreateObject("roMessagePort")
|
||||||
|
loungeService.observeFieldScoped("loungeToken", messagePort)
|
||||||
|
loungeService.join = true
|
||||||
|
message = wait(30000, messagePort)
|
||||||
|
loungeService.unobserveFieldScoped("loungeToken")
|
||||||
|
if message = invalid or StringUtils.IsNullOrEmpty(message.GetData())
|
||||||
|
return {
|
||||||
|
"success": false
|
||||||
|
"error": "Couldn't join lounge"
|
||||||
|
}
|
||||||
|
end if
|
||||||
|
|
||||||
|
input.screenId = loungeService.screenId
|
||||||
|
input.loungeToken = loungeService.loungeToken
|
||||||
|
end if
|
||||||
|
|
||||||
|
bodyParams = {
|
||||||
|
"lounge_token": input.loungeToken
|
||||||
|
"screen_id": input.screenId
|
||||||
|
"screen_name": input.screenName
|
||||||
|
"device_id": input.deviceId
|
||||||
|
}
|
||||||
|
|
||||||
|
for each key in bodyParams
|
||||||
|
if StringUtils.IsNullOrEmpty(bodyParams[key])
|
||||||
|
return {
|
||||||
|
"success": false
|
||||||
|
"error": key + " is empty"
|
||||||
|
}
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
|
||||||
|
bodyParams["access_type"] = "permanent"
|
||||||
|
bodyParams["app"] = "Playlet"
|
||||||
|
|
||||||
|
baseUrl = "https://www.youtube.com/api/lounge/pairing/get_pairing_code?ctx=pair"
|
||||||
|
|
||||||
|
body = UrlUtils.GetUrlEncodedForm(bodyParams)
|
||||||
|
request = HttpClient.Post(baseUrl, body)
|
||||||
|
request.Header("Content-Type", "application/x-www-form-urlencoded")
|
||||||
|
|
||||||
|
response = request.Await()
|
||||||
|
if not response.IsSuccess()
|
||||||
|
return {
|
||||||
|
"success": false
|
||||||
|
"error": response.ErrorMessage()
|
||||||
|
}
|
||||||
|
end if
|
||||||
|
|
||||||
|
code = response.Text()
|
||||||
|
return {
|
||||||
|
"success": true
|
||||||
|
"code": code
|
||||||
|
}
|
||||||
|
end function
|
||||||
@@ -0,0 +1,126 @@
|
|||||||
|
import "pkg:/components/Services/LoungeService/LoungeConstants.bs"
|
||||||
|
import "pkg:/source/utils/StringUtils.bs"
|
||||||
|
import "pkg:/source/utils/Types.bs"
|
||||||
|
|
||||||
|
namespace LoungeMessages
|
||||||
|
|
||||||
|
function OnHasPreviousNextChanged(hasPrevious as boolean, hasNext as boolean) as object
|
||||||
|
message = {
|
||||||
|
commandType: COMMAND_ON_PREVIOUS_NEXT_CHANGE
|
||||||
|
}
|
||||||
|
commandArgs = {}
|
||||||
|
commandArgs[FIELD_HAS_PREVIOUS] = hasPrevious
|
||||||
|
commandArgs[FIELD_HAS_NEXT] = hasNext
|
||||||
|
message.commandArgs = commandArgs
|
||||||
|
return message
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnStateChange(player as object, overrides = invalid as object) as object
|
||||||
|
message = {
|
||||||
|
commandType: COMMAND_ON_STATE_CHANGE
|
||||||
|
}
|
||||||
|
|
||||||
|
commandArgs = {}
|
||||||
|
|
||||||
|
if player = invalid
|
||||||
|
commandArgs[FIELD_STATE] = PlayerState.UNSTARTED
|
||||||
|
message.commandArgs = commandArgs
|
||||||
|
return message
|
||||||
|
end if
|
||||||
|
|
||||||
|
commandArgs[FIELD_STATE] = GetPlayerState(player)
|
||||||
|
commandArgs[FIELD_CURRENT_TIME] = ValidDouble(player.position)
|
||||||
|
commandArgs[FIELD_SEEKABLE_START_TIME] = 0
|
||||||
|
|
||||||
|
content = player.content
|
||||||
|
if content <> invalid
|
||||||
|
metadata = content.metadata
|
||||||
|
if metadata <> invalid
|
||||||
|
lengthSeconds = metadata.lengthSeconds
|
||||||
|
if IsInt(lengthSeconds)
|
||||||
|
commandArgs[FIELD_DURATION] = lengthSeconds
|
||||||
|
commandArgs[FIELD_SEEKABLE_END_TIME] = lengthSeconds
|
||||||
|
|
||||||
|
if commandArgs[FIELD_STATE] = PlayerState.PLAYING or commandArgs[FIELD_STATE] = PlayerState.PAUSED or commandArgs[FIELD_STATE] = PlayerState.BUFFERING
|
||||||
|
commandArgs[FIELD_LOADED_TIME] = lengthSeconds
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
|
||||||
|
if overrides <> invalid
|
||||||
|
commandArgs.Append(overrides)
|
||||||
|
end if
|
||||||
|
|
||||||
|
message.commandArgs = commandArgs
|
||||||
|
|
||||||
|
return message
|
||||||
|
end function
|
||||||
|
|
||||||
|
function NowPlaying(player as object, overrides = invalid as object) as object
|
||||||
|
message = {
|
||||||
|
commandType: COMMAND_NOW_PLAYING
|
||||||
|
}
|
||||||
|
|
||||||
|
if player = invalid
|
||||||
|
return message
|
||||||
|
end if
|
||||||
|
|
||||||
|
commandArgs = {}
|
||||||
|
|
||||||
|
commandArgs[FIELD_CURRENT_TIME] = ValidDouble(player.position)
|
||||||
|
commandArgs[FIELD_SEEKABLE_START_TIME] = 0
|
||||||
|
commandArgs[FIELD_CURRENT_INDEX] = 0
|
||||||
|
|
||||||
|
commandArgs[FIELD_STATE] = GetPlayerState(player)
|
||||||
|
|
||||||
|
content = player.content
|
||||||
|
if content <> invalid
|
||||||
|
metadata = content.metadata
|
||||||
|
if metadata <> invalid
|
||||||
|
lengthSeconds = metadata.lengthSeconds
|
||||||
|
if IsInt(lengthSeconds)
|
||||||
|
commandArgs[FIELD_DURATION] = lengthSeconds
|
||||||
|
commandArgs[FIELD_SEEKABLE_END_TIME] = lengthSeconds
|
||||||
|
|
||||||
|
if commandArgs[FIELD_STATE] = PlayerState.PLAYING or commandArgs[FIELD_STATE] = PlayerState.PAUSED or commandArgs[FIELD_STATE] = PlayerState.BUFFERING
|
||||||
|
commandArgs[FIELD_LOADED_TIME] = lengthSeconds
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
videoId = metadata.videoId
|
||||||
|
if not StringUtils.IsNullOrEmpty(videoId)
|
||||||
|
commandArgs[FIELD_VIDEO_ID] = videoId
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
|
||||||
|
if overrides <> invalid
|
||||||
|
commandArgs.Append(overrides)
|
||||||
|
end if
|
||||||
|
|
||||||
|
message.commandArgs = commandArgs
|
||||||
|
return message
|
||||||
|
end function
|
||||||
|
|
||||||
|
function GetPlayerState(player as object) as PlayerState
|
||||||
|
if player = invalid
|
||||||
|
return PlayerState.UNSTARTED
|
||||||
|
end if
|
||||||
|
|
||||||
|
state = player.state
|
||||||
|
if state = "playing"
|
||||||
|
return PlayerState.PLAYING
|
||||||
|
else if state = "paused"
|
||||||
|
return PlayerState.PAUSED
|
||||||
|
else if state = "buffering"
|
||||||
|
return PlayerState.BUFFERING
|
||||||
|
else if state = "finished"
|
||||||
|
return PlayerState.ENDED
|
||||||
|
else if state = "stopped" or state = "stopping"
|
||||||
|
return PlayerState.STOPPED
|
||||||
|
end if
|
||||||
|
|
||||||
|
return PlayerState.UNSTARTED
|
||||||
|
end function
|
||||||
|
|
||||||
|
end namespace
|
||||||
@@ -0,0 +1,132 @@
|
|||||||
|
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
|
||||||
|
import "pkg:/components/Services/LoungeService/LoungeApi.bs"
|
||||||
|
' TODO:P0
|
||||||
|
' 1. Add a section about the lounge in the privacy policy
|
||||||
|
|
||||||
|
function Init()
|
||||||
|
m.top.functionName = "LoungeServiceLoop"
|
||||||
|
|
||||||
|
deviceInfo = CreateObject("roDeviceInfo")
|
||||||
|
m.top.deviceId = deviceInfo.GetRandomUUID()
|
||||||
|
deviceFriendlyName = deviceInfo.GetFriendlyName()
|
||||||
|
if StringUtils.IsNullOrEmpty(deviceFriendlyName)
|
||||||
|
deviceFriendlyName = "TV"
|
||||||
|
end if
|
||||||
|
m.top.deviceName = "Playlet on " + deviceFriendlyName
|
||||||
|
end function
|
||||||
|
|
||||||
|
function StartService(_unused as dynamic) as boolean
|
||||||
|
if m.top.isRunning = true
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
|
||||||
|
m.top.control = "run"
|
||||||
|
return true
|
||||||
|
end function
|
||||||
|
|
||||||
|
function StopService(_unused as dynamic) as void
|
||||||
|
if m.top.isRunning = false
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
m.top.shouldQuit = true
|
||||||
|
end function
|
||||||
|
|
||||||
|
function LoungeServiceLoop() as void
|
||||||
|
api = new LoungeApi(m.top, m.top.videoQueue, m.top.notifications, m.top.invidious)
|
||||||
|
' Mobile app can remain connected to devices even after restarts.
|
||||||
|
' Since we create a new lounge every time, we signal to the last lounge
|
||||||
|
' that we're no longer there, and we're not coming back.
|
||||||
|
api.DisconnectFromLastLounge()
|
||||||
|
|
||||||
|
messagePort = CreateObject("roMessagePort")
|
||||||
|
|
||||||
|
' We do not join a lounge until something asks us to like
|
||||||
|
' - A remote connects through DIAL
|
||||||
|
' - Generating a TV link code
|
||||||
|
m.top.observeField("join", messagePort)
|
||||||
|
wait(0, messagePort)
|
||||||
|
m.top.unobserveField("join")
|
||||||
|
|
||||||
|
|
||||||
|
screenId = api.GetScreenId()
|
||||||
|
if StringUtils.IsNullOrEmpty(screenId)
|
||||||
|
m.top.isRunning = false
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
m.top.screenId = screenId
|
||||||
|
|
||||||
|
loungeToken = api.GetToken()
|
||||||
|
if StringUtils.IsNullOrEmpty(loungeToken)
|
||||||
|
m.top.isRunning = false
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
m.top.loungeToken = loungeToken
|
||||||
|
|
||||||
|
m.top.observeField("outgoingMessages", messagePort)
|
||||||
|
|
||||||
|
if not api.GetSessionData()
|
||||||
|
m.top.unobserveField("outgoingMessages", messagePort)
|
||||||
|
m.top.isRunning = false
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
api.SaveCurrentLoungeData()
|
||||||
|
api.FetchCommandsRpc(messagePort)
|
||||||
|
|
||||||
|
m.top.shouldQuit = false
|
||||||
|
isOpen = false
|
||||||
|
outgoingLoungeMessages = []
|
||||||
|
portMessages = []
|
||||||
|
socketMessages = []
|
||||||
|
|
||||||
|
while true
|
||||||
|
if m.top.shouldQuit = true
|
||||||
|
exit while
|
||||||
|
end if
|
||||||
|
|
||||||
|
message = wait(60000, messagePort)
|
||||||
|
portMessages.Clear()
|
||||||
|
portMessages.Push(message)
|
||||||
|
|
||||||
|
' There's a chance messages were piling up while we were sending messages to the lounge
|
||||||
|
' This could happen if we were sending things to the lounge and the player state
|
||||||
|
' changed many times.
|
||||||
|
while messagePort.PeekMessage() <> invalid
|
||||||
|
portMessages.Push(messagePort.GetMessage())
|
||||||
|
end while
|
||||||
|
|
||||||
|
' At this point:
|
||||||
|
' - We check if we need to send messages to the lounge based on player state
|
||||||
|
' - We check the lounge for new commands, which might need responding to
|
||||||
|
' - Finally, we send the outgoing messages to the lounge in one go
|
||||||
|
outgoingLoungeMessages.Clear()
|
||||||
|
socketMessages.Clear()
|
||||||
|
|
||||||
|
for each portMessage in portMessages
|
||||||
|
messageType = type(portMessage)
|
||||||
|
if messageType = "roSocketEvent"
|
||||||
|
socketMessages.Push(portMessage)
|
||||||
|
else if messageType = "roSGNodeEvent"
|
||||||
|
field = portMessage.GetField()
|
||||||
|
if field = "outgoingMessages"
|
||||||
|
messages = portMessage.GetData()
|
||||||
|
outgoingLoungeMessages.Append(messages)
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
|
||||||
|
isOpen = api.Poll(socketMessages, outgoingLoungeMessages)
|
||||||
|
|
||||||
|
api.SendMessages(outgoingLoungeMessages)
|
||||||
|
api.ProcessPendingOutgoingMessages()
|
||||||
|
|
||||||
|
if not isOpen
|
||||||
|
sleep(3000)
|
||||||
|
api.FetchCommandsRpc(messagePort)
|
||||||
|
end if
|
||||||
|
end while
|
||||||
|
|
||||||
|
m.top.unobserveField("outgoingMessages", messagePort)
|
||||||
|
m.top.isRunning = false
|
||||||
|
end function
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<component name="LoungeService" extends="Task" includes="AutoBind">
|
||||||
|
<interface>
|
||||||
|
<field id="deviceId" type="string" />
|
||||||
|
<!-- We treat device name and screen name the same -->
|
||||||
|
<field id="deviceName" type="string" />
|
||||||
|
<field id="screenId" type="string" />
|
||||||
|
<field id="loungeToken" type="string" />
|
||||||
|
|
||||||
|
<field id="devices" type="assocarray" />
|
||||||
|
|
||||||
|
<field id="join" type="boolean" alwaysNotify="true" />
|
||||||
|
<field id="outgoingMessages" type="array" alwaysNotify="true" />
|
||||||
|
|
||||||
|
<field id="videoQueue" type="node" />
|
||||||
|
<field id="notifications" type="node" />
|
||||||
|
<field id="invidious" type="node" />
|
||||||
|
|
||||||
|
<field id="isRunning" type="boolean" />
|
||||||
|
<function name="StartService" />
|
||||||
|
<function name="StopService" />
|
||||||
|
|
||||||
|
<field id="shouldQuit" type="boolean" alwaysNotify="true" />
|
||||||
|
</interface>
|
||||||
|
</component>
|
||||||
@@ -0,0 +1,120 @@
|
|||||||
|
import "pkg:/components/Services/Invidious/InvidiousService.bs"
|
||||||
|
import "pkg:/components/Services/Invidious/InvidiousToContentNode.bs"
|
||||||
|
import "pkg:/components/Services/LoungeService/LoungeConstants.bs"
|
||||||
|
import "pkg:/components/VideoQueue/Notifications/VideoQueueNotificationUtils.bs"
|
||||||
|
|
||||||
|
namespace LoungeVideoQueue
|
||||||
|
function SetPlaylist(videoQueueNode as object, invService as object, playlistData as object)
|
||||||
|
HandleLoungePlaylist(videoQueueNode, invService, playlistData)
|
||||||
|
end function
|
||||||
|
|
||||||
|
function UpdatePlaylist(videoQueueNode as object, invService as object, playlistData as object)
|
||||||
|
HandleLoungePlaylist(videoQueueNode, invService, playlistData)
|
||||||
|
end function
|
||||||
|
|
||||||
|
function HandleLoungePlaylist(videoQueueNode as object, invService as object, playlistData as object) as void
|
||||||
|
videoIds = playlistData[FIELD_VIDEO_IDS]
|
||||||
|
if StringUtils.IsNullOrEmpty(videoIds)
|
||||||
|
videoQueueNode.clearQueue = true
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
videoIds = videoIds.Split(",")
|
||||||
|
queueContent = videoQueueNode.content
|
||||||
|
currentQueueNodes = queueContent.getChildren(-1, 0)
|
||||||
|
queueNodesDict = {}
|
||||||
|
for each node in currentQueueNodes
|
||||||
|
queueNodesDict[node.id] = node
|
||||||
|
end for
|
||||||
|
|
||||||
|
instance = invalid
|
||||||
|
newQueueNodes = []
|
||||||
|
for each vId in videoIds
|
||||||
|
if queueNodesDict.DoesExist(vId)
|
||||||
|
newQueueNodes.Push(queueNodesDict[vId])
|
||||||
|
else
|
||||||
|
payload = {
|
||||||
|
"type": "video"
|
||||||
|
"videoId": vId
|
||||||
|
}
|
||||||
|
|
||||||
|
if instance = invalid
|
||||||
|
instance = invService.GetInstance()
|
||||||
|
end if
|
||||||
|
|
||||||
|
contentNode = InvidiousContent.ToVideoContentNode(invalid, payload, instance)
|
||||||
|
newQueueNodes.Push(contentNode)
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
|
||||||
|
index = -1
|
||||||
|
currentIndex = playlistData[FIELD_CURRENT_INDEX]
|
||||||
|
if IsString(currentIndex)
|
||||||
|
currentIndex = CInt(Val(currentIndex))
|
||||||
|
index = currentIndex
|
||||||
|
else
|
||||||
|
index = videoQueueNode.index
|
||||||
|
end if
|
||||||
|
|
||||||
|
videoQueueNode.setQueueAndIndex = {
|
||||||
|
videoNodes: newQueueNodes
|
||||||
|
index: index
|
||||||
|
}
|
||||||
|
|
||||||
|
videoId = playlistData[FIELD_VIDEO_ID]
|
||||||
|
timestamp = playlistData[FIELD_CURRENT_TIME]
|
||||||
|
|
||||||
|
if not StringUtils.IsNullOrEmpty(videoId)
|
||||||
|
if not StringUtils.IsNullOrEmpty(timestamp)
|
||||||
|
timestamp = CInt(Val(timestamp))
|
||||||
|
if timestamp > 0
|
||||||
|
node = newQueueNodes[index]
|
||||||
|
node.timestamp = timestamp
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
|
||||||
|
videoQueueNode.play = true
|
||||||
|
end if
|
||||||
|
|
||||||
|
if StringUtils.IsNullOrEmpty(videoId)
|
||||||
|
' TODO:P1 - Handle the case where a video is removed from the queue
|
||||||
|
' with an index lower than the current index. In this case, the
|
||||||
|
' video queue index is not updated, and we end up highlighting the wrong
|
||||||
|
' video in the queue (the next video in the queue is highlighted instead of
|
||||||
|
' the video that was previously highlighted). This also leads to skipping
|
||||||
|
' a video that's supposed to play next.
|
||||||
|
' When a video is removed from the queue:
|
||||||
|
' - There's no videoId
|
||||||
|
' - There's no currentIndex
|
||||||
|
' - eventDetails is of the form {"eventType":"VIDEO_REMOVED","videoId":"<videoId>"}
|
||||||
|
eventDetails = playlistData[FIELD_EVENT_DETAILS]
|
||||||
|
if IsString(eventDetails)
|
||||||
|
eventDetails = ParseJson(eventDetails)
|
||||||
|
end if
|
||||||
|
if eventDetails <> invalid and eventDetails["eventType"] = "VIDEO_ADDED"
|
||||||
|
eventVideoId = eventDetails[FIELD_VIDEO_ID]
|
||||||
|
if not StringUtils.IsNullOrEmpty(eventVideoId)
|
||||||
|
preferences = videoQueueNode.preferences
|
||||||
|
queueNotifications = preferences["misc.queue_notifications"]
|
||||||
|
if queueNotifications
|
||||||
|
payload = {
|
||||||
|
"type": "video"
|
||||||
|
"videoId": eventVideoId
|
||||||
|
}
|
||||||
|
|
||||||
|
if instance = invalid
|
||||||
|
instance = invService.GetInstance()
|
||||||
|
end if
|
||||||
|
|
||||||
|
node = InvidiousContent.ToVideoContentNode(invalid, payload, instance)
|
||||||
|
|
||||||
|
notifications = videoQueueNode.notifications
|
||||||
|
hintVisible = videoQueueNode.player = invalid or not videoQueueNode.videoContainer.fullscreen
|
||||||
|
VideoQueue.ShowNotifcation(notifications, node, hintVisible)
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
end function
|
||||||
|
|
||||||
|
end namespace
|
||||||
+50
@@ -0,0 +1,50 @@
|
|||||||
|
import "pkg:/source/utils/StringUtils.bs"
|
||||||
|
import "pkg:/source/utils/Types.bs"
|
||||||
|
|
||||||
|
' TODO:P2 a lot of shared logic with the SponsorBlock notification, should be refactored into a common notification
|
||||||
|
function Init()
|
||||||
|
m.translationAnimation = m.top.findNode("translationAnimation")
|
||||||
|
m.translationAnimationInterpolator = m.top.findNode("translationAnimationInterpolator")
|
||||||
|
m.animationTimer = m.top.findNode("animationTimer")
|
||||||
|
|
||||||
|
m.top.translation = [1280, 20]
|
||||||
|
m.translationAnimation.observeField("state", FuncName(OnAnimationState))
|
||||||
|
m.animationTimer.observeField("fire", FuncName(OnAnimationTimer))
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnShow()
|
||||||
|
AnimateIn()
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnAnimationTimer()
|
||||||
|
AnimateOut()
|
||||||
|
end function
|
||||||
|
|
||||||
|
function AnimateIn()
|
||||||
|
m.translationAnimation.unobserveField("state")
|
||||||
|
m.animationTimer.control = "stop"
|
||||||
|
m.animationTimer.control = "start"
|
||||||
|
m.translationAnimation.observeField("state", FuncName(OnAnimationState))
|
||||||
|
|
||||||
|
Animate(false)
|
||||||
|
end function
|
||||||
|
|
||||||
|
function AnimateOut()
|
||||||
|
Animate(true)
|
||||||
|
end function
|
||||||
|
|
||||||
|
function Animate(reverse as boolean) as void
|
||||||
|
' We are already animating in the requested direction
|
||||||
|
if m.translationAnimationInterpolator.reverse = reverse and m.translationAnimation.control <> "none"
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
m.translationAnimationInterpolator.reverse = reverse
|
||||||
|
m.translationAnimation.control = "start"
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnAnimationState()
|
||||||
|
if m.translationAnimation.state = "stopped" and m.translationAnimationInterpolator.reverse = true
|
||||||
|
m.top.getParent().removeChild(m.top)
|
||||||
|
end if
|
||||||
|
end function
|
||||||
+58
@@ -0,0 +1,58 @@
|
|||||||
|
<component name="DeviceConnectedNotification" extends="Group">
|
||||||
|
<interface>
|
||||||
|
<field id="thumbnail" type="uri" alias="thumbnailPoster.uri" />
|
||||||
|
<field id="line1" type="string" alias="line1Label.text" />
|
||||||
|
<field id="line2" type="string" alias="line2Label.text" />
|
||||||
|
<field id="show" type="boolean" alwaysNotify="true" onChange="OnShow" />
|
||||||
|
</interface>
|
||||||
|
<children>
|
||||||
|
<Poster
|
||||||
|
width="350"
|
||||||
|
height="100"
|
||||||
|
opacity="0.9"
|
||||||
|
blendColor="#414141"
|
||||||
|
uri="pkg:/images/white.9.png">
|
||||||
|
|
||||||
|
<CirclePoster
|
||||||
|
id="thumbnailPoster"
|
||||||
|
width="80"
|
||||||
|
height="80"
|
||||||
|
failedBitmapUri="pkg:/images/icons/user.png"
|
||||||
|
translation="[10,10]" />
|
||||||
|
|
||||||
|
<LayoutGroup
|
||||||
|
itemSpacings="[5,5]"
|
||||||
|
translation="[100,15]">
|
||||||
|
<Label
|
||||||
|
width="230"
|
||||||
|
font="font:SmallestBoldSystemFont"
|
||||||
|
horizAlign="center"
|
||||||
|
text="Device connected">
|
||||||
|
</Label>
|
||||||
|
<Label
|
||||||
|
id="line1Label"
|
||||||
|
width="230"
|
||||||
|
font="font:SmallestBoldSystemFont"
|
||||||
|
horizAlign="center" />
|
||||||
|
<Label
|
||||||
|
id="line2Label"
|
||||||
|
width="230"
|
||||||
|
font="font:SmallestSystemFont"
|
||||||
|
horizAlign="center" />
|
||||||
|
</LayoutGroup>
|
||||||
|
</Poster>
|
||||||
|
<Animation
|
||||||
|
id="translationAnimation"
|
||||||
|
duration="0.3"
|
||||||
|
optional="true">
|
||||||
|
<Vector2DFieldInterpolator
|
||||||
|
id="translationAnimationInterpolator"
|
||||||
|
key="[0.0, 0.5, 1.0]"
|
||||||
|
keyValue="[ [1280.0, 20.0], [1095.0, 20.0], [910.0, 20.0] ]"
|
||||||
|
fieldToInterp="DeviceConnectedNotification.translation" />
|
||||||
|
</Animation>
|
||||||
|
<Timer
|
||||||
|
id="animationTimer"
|
||||||
|
duration="3" />
|
||||||
|
</children>
|
||||||
|
</component>
|
||||||
+38
@@ -0,0 +1,38 @@
|
|||||||
|
namespace LoungeDeviceConnected
|
||||||
|
const NOTIFICATION_NODE_ID = "DeviceConnectedNotification"
|
||||||
|
|
||||||
|
function ShowNotifcation(notifications as object, deviceName as dynamic, userName as dynamic, userAvatarUri as dynamic) as void
|
||||||
|
notification = notifications.findNode(NOTIFICATION_NODE_ID)
|
||||||
|
if notification = invalid
|
||||||
|
notification = notifications.createChild("DeviceConnectedNotification")
|
||||||
|
notification.id = NOTIFICATION_NODE_ID
|
||||||
|
end if
|
||||||
|
|
||||||
|
if StringUtils.IsNullOrEmpty(deviceName)
|
||||||
|
deviceName = "Device"
|
||||||
|
end if
|
||||||
|
if StringUtils.IsNullOrEmpty(userAvatarUri)
|
||||||
|
userAvatarUri = "pkg:/images/icons/user.png"
|
||||||
|
end if
|
||||||
|
|
||||||
|
notification.line1 = deviceName
|
||||||
|
notification.line2 = userName
|
||||||
|
notification.thumbnail = userAvatarUri
|
||||||
|
notification.show = true
|
||||||
|
end function
|
||||||
|
|
||||||
|
function RemoveNotifcation(notifications as object) as void
|
||||||
|
notification = notifications.findNode(NOTIFICATION_NODE_ID)
|
||||||
|
if notification <> invalid
|
||||||
|
notifications.RemoveChild(notification)
|
||||||
|
end if
|
||||||
|
end function
|
||||||
|
|
||||||
|
function SetVisible(notifications as object, visible as boolean)
|
||||||
|
notification = notifications.findNode(NOTIFICATION_NODE_ID)
|
||||||
|
if notification <> invalid
|
||||||
|
notification.visible = visible
|
||||||
|
end if
|
||||||
|
end function
|
||||||
|
|
||||||
|
end namespace
|
||||||
@@ -5,6 +5,7 @@ function Init()
|
|||||||
m.typeMapping = {
|
m.typeMapping = {
|
||||||
"boolean": "boolean"
|
"boolean": "boolean"
|
||||||
"string": "string"
|
"string": "string"
|
||||||
|
"number": "integer"
|
||||||
"radio": "string"
|
"radio": "string"
|
||||||
"array": "array"
|
"array": "array"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
<component name="Preferences" extends="Node">
|
<component name="Preferences" extends="Node">
|
||||||
<interface>
|
<interface>
|
||||||
|
<!--
|
||||||
|
The version of the preferences model. This is used to determine if the
|
||||||
|
user prefs saved need to be migrated. If the version is less than the
|
||||||
|
current version, a migration is needed.
|
||||||
|
-->
|
||||||
<field id="__version" type="integer" value="1" />
|
<field id="__version" type="integer" value="1" />
|
||||||
<field id="prefsModel" type="array" />
|
<field id="prefsModel" type="array" />
|
||||||
<field id="preferenceFields" type="assocarray" />
|
<field id="preferenceFields" type="assocarray" />
|
||||||
|
|||||||
-2
@@ -1,5 +1,3 @@
|
|||||||
import "pkg:/components/VideoPlayer/VideoUtils.bs"
|
|
||||||
|
|
||||||
namespace SponsorBlock
|
namespace SponsorBlock
|
||||||
const NOTIFICATION_NODE_ID = "SponsorBlockNotification"
|
const NOTIFICATION_NODE_ID = "SponsorBlockNotification"
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ function OnContentSet() as void
|
|||||||
end if
|
end if
|
||||||
|
|
||||||
m.top.title = content.title
|
m.top.title = content.title
|
||||||
m.top.author = content.author
|
' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
|
||||||
|
m.top.author = content._author
|
||||||
|
|
||||||
if content.isUpcoming = true
|
if content.isUpcoming = true
|
||||||
m.top.viewCountDate = content.premiereTimestampText
|
m.top.viewCountDate = content.premiereTimestampText
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import "pkg:/components/Navigation/LongPress.bs"
|
|||||||
import "pkg:/components/PlaylistView/PlaylistUtils.bs"
|
import "pkg:/components/PlaylistView/PlaylistUtils.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"
|
||||||
import "pkg:/components/VideoPlayer/VideoUtils.bs"
|
|
||||||
import "pkg:/source/AsyncTask/AsyncTask.bs"
|
import "pkg:/source/AsyncTask/AsyncTask.bs"
|
||||||
import "pkg:/source/AsyncTask/Tasks.bs"
|
import "pkg:/source/AsyncTask/Tasks.bs"
|
||||||
import "pkg:/source/utils/DisposableObserve.bs"
|
import "pkg:/source/utils/DisposableObserve.bs"
|
||||||
@@ -100,7 +99,7 @@ function OnRowItemSelected(index as object) as void
|
|||||||
if rowItem.type = "video"
|
if rowItem.type = "video"
|
||||||
videoId = rowItem.videoId
|
videoId = rowItem.videoId
|
||||||
LogInfo("Play video: " + videoId)
|
LogInfo("Play video: " + videoId)
|
||||||
m.playQueue@.Play(rowItem, -1)
|
m.videoQueue.playVideo = rowItem
|
||||||
else if rowItem.type = "playlist"
|
else if rowItem.type = "playlist"
|
||||||
playlistId = rowItem.playlistId
|
playlistId = rowItem.playlistId
|
||||||
LogInfo("Open playlist: " + playlistId)
|
LogInfo("Open playlist: " + playlistId)
|
||||||
@@ -151,18 +150,15 @@ end function
|
|||||||
function GetContextMenuOptionsForItem(rowItem as object) as object
|
function GetContextMenuOptionsForItem(rowItem as object) as object
|
||||||
options = []
|
options = []
|
||||||
|
|
||||||
playAction = ContextMenuUtils.CreateOption("Play", m.playQueue, "Play", [rowItem, -1])
|
|
||||||
queueAction = ContextMenuUtils.CreateOption("Queue", m.playQueue, "AddToQueue", [rowItem])
|
|
||||||
|
|
||||||
if rowItem.type = "video"
|
if rowItem.type = "video"
|
||||||
options.push(playAction)
|
options.push(ContextMenuUtils.CreateOption("Play", m.videoQueue, "FuncPlayVideo", [rowItem]))
|
||||||
options.push(queueAction)
|
options.push(ContextMenuUtils.CreateOption("Queue", m.videoQueue, "FuncAddToQueueVideo", [rowItem]))
|
||||||
|
|
||||||
item = ContextMenuUtils.CreateOption("Open channel", m.top, "OpenVideoChannel", [rowItem])
|
item = ContextMenuUtils.CreateOption("Open channel", m.top, "OpenVideoChannel", [rowItem])
|
||||||
options.push(item)
|
options.push(item)
|
||||||
else if rowItem.type = "playlist"
|
else if rowItem.type = "playlist"
|
||||||
options.push(playAction)
|
options.push(ContextMenuUtils.CreateOption("Play", m.videoQueue, "FuncPlayPlaylist", [rowItem, 0]))
|
||||||
options.push(queueAction)
|
options.push(ContextMenuUtils.CreateOption("Queue", m.videoQueue, "FuncAddToQueuePlaylist", [rowItem]))
|
||||||
|
|
||||||
item = ContextMenuUtils.CreateOption("Open", m.top, "OpenPlaylist", [rowItem])
|
item = ContextMenuUtils.CreateOption("Open", m.top, "OpenPlaylist", [rowItem])
|
||||||
options.push(item)
|
options.push(item)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<interface>
|
<interface>
|
||||||
<field id="appController" type="node" bind="/AppController" />
|
<field id="appController" type="node" bind="/AppController" />
|
||||||
<field id="invidious" type="node" bind="/Invidious" />
|
<field id="invidious" type="node" bind="/Invidious" />
|
||||||
<field id="playQueue" type="node" bind="/PlayQueue" />
|
<field id="videoQueue" type="node" bind="/VideoQueue" />
|
||||||
<field id="bookmarks" type="node" bind="/Bookmarks" />
|
<field id="bookmarks" type="node" bind="/Bookmarks" />
|
||||||
<field id="screen" type="node" />
|
<field id="screen" type="node" />
|
||||||
<field id="feeds" type="array" onChange="OnFeedsChange" />
|
<field id="feeds" type="array" onChange="OnFeedsChange" />
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import "pkg:/components/Services/LoungeService/LoungeConstants.bs"
|
||||||
|
import "pkg:/components/Services/LoungeService/LoungeMessages.bs"
|
||||||
|
import "pkg:/source/utils/StringUtils.bs"
|
||||||
|
|
||||||
|
namespace Lounge
|
||||||
|
|
||||||
|
function SendNowPlayingLoading(videoId as dynamic) as void
|
||||||
|
if StringUtils.IsNullOrEmpty(m.loungeService.loungeToken)
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
overrides = {}
|
||||||
|
overrides[FIELD_STATE] = PlayerState.BUFFERING
|
||||||
|
loungeStateMsg = LoungeMessages.OnStateChange(m.top, overrides)
|
||||||
|
if not StringUtils.IsNullOrEmpty(videoId)
|
||||||
|
overrides[FIELD_VIDEO_ID] = videoId
|
||||||
|
end if
|
||||||
|
nowPlayingMsg = LoungeMessages.NowPlaying(m.top, overrides)
|
||||||
|
m.loungeService.outgoingMessages = [nowPlayingMsg, loungeStateMsg]
|
||||||
|
end function
|
||||||
|
|
||||||
|
function SendOnStateChange() as void
|
||||||
|
if StringUtils.IsNullOrEmpty(m.loungeService.loungeToken)
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
loungeStateMsg = LoungeMessages.OnStateChange(m.top)
|
||||||
|
m.loungeService.outgoingMessages = [loungeStateMsg]
|
||||||
|
end function
|
||||||
|
|
||||||
|
end namespace
|
||||||
@@ -17,7 +17,7 @@ function VideoContentTask(input as object) as object
|
|||||||
|
|
||||||
service = new Invidious.InvidiousService(invidiousNode)
|
service = new Invidious.InvidiousService(invidiousNode)
|
||||||
|
|
||||||
response = service.GetVideoMetadata(contentNode.videoId, m.top.cancellation)
|
response = service.GetVideoMetadata(contentNode.videoId, { cancellation: m.top.cancellation })
|
||||||
|
|
||||||
if m.top.cancel
|
if m.top.cancel
|
||||||
return invalid
|
return invalid
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import "pkg:/components/Dialog/DialogUtils.bs"
|
import "pkg:/components/Dialog/DialogUtils.bs"
|
||||||
import "pkg:/components/Services/Invidious/InvidiousToContentNode.bs"
|
import "pkg:/components/Services/Invidious/InvidiousToContentNode.bs"
|
||||||
|
import "pkg:/components/VideoPlayer/Lounge.bs"
|
||||||
import "pkg:/components/VideoPlayer/SponsorBlock.bs"
|
import "pkg:/components/VideoPlayer/SponsorBlock.bs"
|
||||||
import "pkg:/components/VideoPlayer/VideoPlayerStyle.bs"
|
import "pkg:/components/VideoPlayer/VideoPlayerStyle.bs"
|
||||||
import "pkg:/components/VideoPlayer/VideoUtils.bs"
|
import "pkg:/components/VideoQueue/VideoQueueUtils.bs"
|
||||||
import "pkg:/source/AsyncTask/AsyncTask.bs"
|
import "pkg:/source/AsyncTask/AsyncTask.bs"
|
||||||
import "pkg:/source/AsyncTask/Tasks.bs"
|
import "pkg:/source/AsyncTask/Tasks.bs"
|
||||||
import "pkg:/source/utils/ErrorUtils.bs"
|
import "pkg:/source/utils/ErrorUtils.bs"
|
||||||
@@ -70,11 +71,13 @@ function PlayWithContent(contentNode as object)
|
|||||||
if not StringUtils.IsNullOrEmpty(contentNode.title)
|
if not StringUtils.IsNullOrEmpty(contentNode.title)
|
||||||
videoContentNode.title = contentNode.title
|
videoContentNode.title = contentNode.title
|
||||||
end if
|
end if
|
||||||
if not StringUtils.IsNullOrEmpty(contentNode.author)
|
' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
|
||||||
videoContentNode.secondaryTitle = contentNode.author
|
if not StringUtils.IsNullOrEmpty(contentNode._author)
|
||||||
|
videoContentNode.secondaryTitle = contentNode._author
|
||||||
end if
|
end if
|
||||||
|
|
||||||
StartVideoContentTask(videoContentNode)
|
StartVideoContentTask(videoContentNode)
|
||||||
|
Lounge.SendNowPlayingLoading(contentNode.videoId)
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function StartVideoContentTask(videoContentNode as object)
|
function StartVideoContentTask(videoContentNode as object)
|
||||||
@@ -113,7 +116,8 @@ function OnVideoContentTaskResults(output as object) as void
|
|||||||
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)
|
DialogUtils.ShowDialog(message, "Video load fail", true)
|
||||||
' TODO:P1 play next video in the queue after showing the error dialog
|
' TODO:P1 play next video in the queue after showing the error dialog
|
||||||
VideoUtils.CloseVideo()
|
m.videoQueue.closePlayer = true
|
||||||
|
Lounge.SendOnStateChange()
|
||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
|
|
||||||
@@ -144,16 +148,25 @@ function Close(_unused as dynamic)
|
|||||||
m.sponsorBlockTask = invalid
|
m.sponsorBlockTask = invalid
|
||||||
end if
|
end if
|
||||||
|
|
||||||
m.top.control = "stop"
|
|
||||||
m.top.content = invalid
|
|
||||||
parent = m.top.getParent()
|
parent = m.top.getParent()
|
||||||
if parent <> invalid
|
if parent <> invalid
|
||||||
parent.RemoveChild(m.top)
|
parent.RemoveChild(m.top)
|
||||||
end if
|
end if
|
||||||
SponsorBlock.RemoveNotifcation(m.notifications)
|
SponsorBlock.RemoveNotifcation(m.notifications)
|
||||||
|
|
||||||
|
' Stopping a video is slow and synchronous, and can lead to execution timeout crashes.
|
||||||
|
try
|
||||||
|
m.top.control = "stop"
|
||||||
|
catch error
|
||||||
|
DialogUtils.ShowDialog(ErrorUtils.Format(error), "Error closing video", true)
|
||||||
|
end try
|
||||||
|
|
||||||
|
m.top.content = invalid
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function OnVideoPlayerStateChange() as void
|
function OnVideoPlayerStateChange() as void
|
||||||
|
Lounge.SendOnStateChange()
|
||||||
|
|
||||||
state = m.top.state
|
state = m.top.state
|
||||||
content = m.top.content
|
content = m.top.content
|
||||||
' If we successfully played the video, then any error that comes later is not due to a 403 (FORBIDDEN).
|
' If we successfully played the video, then any error that comes later is not due to a 403 (FORBIDDEN).
|
||||||
@@ -220,67 +233,14 @@ function OnVideoPlayerStateChange() as void
|
|||||||
LogError(title, messageLines)
|
LogError(title, messageLines)
|
||||||
DialogUtils.ShowDialog(messageLines, title, true)
|
DialogUtils.ShowDialog(messageLines, title, true)
|
||||||
' TODO:P1 play next video in the queue after showing the error dialog
|
' TODO:P1 play next video in the queue after showing the error dialog
|
||||||
VideoUtils.CloseVideo()
|
m.videoQueue.closePlayer = true
|
||||||
end if
|
end if
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function OnVideoFinished() as void
|
function OnVideoFinished() as void
|
||||||
content = m.top.content
|
if not VideoQueueUtils.PlayNext(m.videoQueue, m.invidious, m.preferences)
|
||||||
if content = invalid
|
m.videoQueue.closePlayer = true
|
||||||
m.playQueue@.watchedVideosClear()
|
|
||||||
VideoUtils.CloseVideo()
|
|
||||||
return
|
|
||||||
end if
|
end if
|
||||||
|
|
||||||
metadata = content.metadata
|
|
||||||
if metadata = invalid
|
|
||||||
m.playQueue@.watchedVideosClear()
|
|
||||||
VideoUtils.CloseVideo()
|
|
||||||
return
|
|
||||||
end if
|
|
||||||
|
|
||||||
if not PlayNext(metadata.recommendedVideos)
|
|
||||||
m.playQueue@.watchedVideosClear()
|
|
||||||
VideoUtils.CloseVideo()
|
|
||||||
end if
|
|
||||||
end function
|
|
||||||
|
|
||||||
function PlayNext(recommendedVideos as object) as boolean
|
|
||||||
if m.playQueue@.PlayNextItem()
|
|
||||||
return true
|
|
||||||
end if
|
|
||||||
|
|
||||||
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
|
|
||||||
end if
|
|
||||||
|
|
||||||
if recommendedVideos = invalid or recommendedVideos.Count() = 0
|
|
||||||
return false
|
|
||||||
end if
|
|
||||||
|
|
||||||
for each metadata in recommendedVideos
|
|
||||||
if metadata = invalid
|
|
||||||
continue for
|
|
||||||
end if
|
|
||||||
videoId = metadata.videoId
|
|
||||||
if videoId = invalid
|
|
||||||
continue for
|
|
||||||
end if
|
|
||||||
if not m.playQueue@.watchedVideosContain(videoId)
|
|
||||||
LogInfo(`Playing next recommended video (${videoId})`)
|
|
||||||
instance = m.invidious@.GetCurrentInstance()
|
|
||||||
node = InvidiousContent.ToVideoContentNode(invalid, metadata, instance)
|
|
||||||
m.playQueue@.Play(node, -1)
|
|
||||||
return true
|
|
||||||
end if
|
|
||||||
end for
|
|
||||||
|
|
||||||
return false
|
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function OnkeyEvent(key as string, press as boolean) as boolean
|
function OnkeyEvent(key as string, press as boolean) as boolean
|
||||||
@@ -291,14 +251,13 @@ function OnkeyEvent(key as string, press as boolean) as boolean
|
|||||||
' https://community.roku.com/t5/Roku-Developer-Program/Bug-in-10-0-1-Options-key-is-not-being-consumed-by-onKeyEvent-when-Video-node-is-in-focus/m-p/709200/highlight/true#M49312
|
' https://community.roku.com/t5/Roku-Developer-Program/Bug-in-10-0-1-Options-key-is-not-being-consumed-by-onKeyEvent-when-Video-node-is-in-focus/m-p/709200/highlight/true#M49312
|
||||||
' Because of that, the button "down" is used to shrink the video for picture in picture mode
|
' Because of that, the button "down" is used to shrink the video for picture in picture mode
|
||||||
if key = "down"
|
if key = "down"
|
||||||
if VideoUtils.ToggleVideoPictureInPicture()
|
if VideoQueueUtils.ToggleVideoPictureInPicture(m.videoQueue)
|
||||||
return true
|
return true
|
||||||
end if
|
end if
|
||||||
end if
|
end if
|
||||||
|
|
||||||
if key = "back"
|
if key = "back"
|
||||||
m.playQueue@.watchedVideosClear()
|
m.videoQueue.closePlayer = true
|
||||||
VideoUtils.CloseVideo()
|
|
||||||
return true
|
return true
|
||||||
end if
|
end if
|
||||||
return false
|
return false
|
||||||
|
|||||||
@@ -3,10 +3,11 @@
|
|||||||
<field id="appController" type="node" bind="/AppController" />
|
<field id="appController" type="node" bind="/AppController" />
|
||||||
<field id="container" type="node" bind=".." />
|
<field id="container" type="node" bind=".." />
|
||||||
<field id="notifications" type="node" bind="../../Notifications" />
|
<field id="notifications" type="node" bind="../../Notifications" />
|
||||||
<field id="playQueue" type="node" bind="../../PlayQueue" />
|
<field id="videoQueue" type="node" bind="../../VideoQueue" />
|
||||||
<field id="preferences" type="node" bind="../../Preferences" />
|
<field id="preferences" type="node" bind="../../Preferences" />
|
||||||
<field id="invidious" type="node" bind="../../Invidious" />
|
<field id="invidious" type="node" bind="../../Invidious" />
|
||||||
<field id="webServer" type="node" bind="../../WebServer" />
|
<field id="webServer" type="node" bind="../../WebServer" />
|
||||||
|
<field id="loungeService" type="node" bind="../../LoungeService" />
|
||||||
<field id="minRect" type="rect2D" value="[834,460,426,240]" />
|
<field id="minRect" type="rect2D" value="[834,460,426,240]" />
|
||||||
<field id="maxRect" type="rect2D" value="[0,0,1280,720]" />
|
<field id="maxRect" type="rect2D" value="[0,0,1280,720]" />
|
||||||
<field id="chapter" type="string" alias="chapterLabel.text" />
|
<field id="chapter" type="string" alias="chapterLabel.text" />
|
||||||
|
|||||||
@@ -1,123 +0,0 @@
|
|||||||
import "pkg:/components/Dialog/DialogUtils.bs"
|
|
||||||
import "pkg:/source/utils/FocusManagement.bs"
|
|
||||||
import "pkg:/source/utils/StringUtils.bs"
|
|
||||||
|
|
||||||
namespace VideoUtils
|
|
||||||
function PlayVideo(contentNode as object) as void
|
|
||||||
CloseVideo(false)
|
|
||||||
|
|
||||||
container = GetVideoContainer()
|
|
||||||
' There should be no reason for this to be invalid, but there was a crash report
|
|
||||||
' with this being invalid, so we'll abort playing a video and try to restore focus to the top screen
|
|
||||||
if container = invalid
|
|
||||||
LogError("VideoContainer not found! Attempting to restore focus to top screen...")
|
|
||||||
appController = m.top.getScene().findNode("AppController")
|
|
||||||
if appController <> invalid
|
|
||||||
appController@.FocusTopScreen()
|
|
||||||
end if
|
|
||||||
DialogUtils.ShowDialog(`VideoContainer not found!\nPlease try again. If the problem persist, contact Playlet authors.`, "Error playing video")
|
|
||||||
return
|
|
||||||
end if
|
|
||||||
videoPlayer = container.createChild("videoPlayer")
|
|
||||||
videoPlayer.id = "VideoPlayer"
|
|
||||||
videoPlayer@.BindNode()
|
|
||||||
|
|
||||||
videoPlayer@.PlayWithContent(contentNode)
|
|
||||||
|
|
||||||
if container.fullscreen
|
|
||||||
NodeSetFocus(videoPlayer, true)
|
|
||||||
|
|
||||||
dialog = m.top.getScene().dialog
|
|
||||||
if dialog <> invalid
|
|
||||||
dialog.close = true
|
|
||||||
end if
|
|
||||||
end if
|
|
||||||
end function
|
|
||||||
|
|
||||||
function CloseVideo(setFocus = true as boolean) as void
|
|
||||||
videoPlayer = GetVideoPlayer()
|
|
||||||
if videoPlayer = invalid
|
|
||||||
return
|
|
||||||
end if
|
|
||||||
videoPlayer@.Close()
|
|
||||||
|
|
||||||
if setFocus
|
|
||||||
videoPlayer.appController@.FocusTopScreen()
|
|
||||||
end if
|
|
||||||
end function
|
|
||||||
|
|
||||||
function GetVideoPlayer() as object
|
|
||||||
container = GetVideoContainer()
|
|
||||||
if container = invalid or container.getChildCount() = 0
|
|
||||||
return invalid
|
|
||||||
end if
|
|
||||||
return container.getChild(0)
|
|
||||||
end function
|
|
||||||
|
|
||||||
function GetVideoContainer() as object
|
|
||||||
return m.top.getScene().findNode("VideoContainer")
|
|
||||||
end function
|
|
||||||
|
|
||||||
function IsVideoPlayerFullScreen() as boolean
|
|
||||||
videoContainer = GetVideoContainer()
|
|
||||||
if videoContainer = invalid
|
|
||||||
return false
|
|
||||||
end if
|
|
||||||
return videoContainer.fullscreen
|
|
||||||
end function
|
|
||||||
|
|
||||||
function ToggleVideoPictureInPicture() as boolean
|
|
||||||
videoPlayer = GetVideoPlayer()
|
|
||||||
if videoPlayer = invalid
|
|
||||||
return false
|
|
||||||
end if
|
|
||||||
videoContainer = GetVideoContainer()
|
|
||||||
videoContainer.fullscreen = not videoContainer.fullscreen
|
|
||||||
if videoContainer.fullscreen
|
|
||||||
NodeSetFocus(videoPlayer, true)
|
|
||||||
else
|
|
||||||
videoPlayer.appController@.FocusTopScreen()
|
|
||||||
end if
|
|
||||||
return true
|
|
||||||
end function
|
|
||||||
|
|
||||||
function IsVideoPlayerOpen() as boolean
|
|
||||||
return GetVideoPlayer() <> invalid
|
|
||||||
end function
|
|
||||||
|
|
||||||
function PauseVideo() as boolean
|
|
||||||
player = GetVideoPlayer()
|
|
||||||
if player = invalid
|
|
||||||
return false
|
|
||||||
end if
|
|
||||||
player.control = "pause"
|
|
||||||
return true
|
|
||||||
end function
|
|
||||||
|
|
||||||
function ResumeVideo() as boolean
|
|
||||||
player = GetVideoPlayer()
|
|
||||||
if player = invalid
|
|
||||||
return false
|
|
||||||
end if
|
|
||||||
player.control = "resume"
|
|
||||||
return true
|
|
||||||
end function
|
|
||||||
|
|
||||||
function TogglePause() as boolean
|
|
||||||
player = GetVideoPlayer()
|
|
||||||
if player = invalid
|
|
||||||
return false
|
|
||||||
end if
|
|
||||||
if player.state = "playing"
|
|
||||||
player.control = "pause"
|
|
||||||
return true
|
|
||||||
else if player.state = "paused"
|
|
||||||
player.control = "resume"
|
|
||||||
return true
|
|
||||||
end if
|
|
||||||
return false
|
|
||||||
end function
|
|
||||||
|
|
||||||
end namespace
|
|
||||||
|
|
||||||
|
|
||||||
-2
@@ -1,4 +1,3 @@
|
|||||||
import "pkg:/components/NodeByRef/NodeByRef.bs"
|
|
||||||
import "pkg:/source/utils/StringUtils.bs"
|
import "pkg:/source/utils/StringUtils.bs"
|
||||||
import "pkg:/source/utils/Types.bs"
|
import "pkg:/source/utils/Types.bs"
|
||||||
|
|
||||||
@@ -15,7 +14,6 @@ end function
|
|||||||
|
|
||||||
function OnContentSet() as void
|
function OnContentSet() as void
|
||||||
content = m.top.content
|
content = m.top.content
|
||||||
content = NodeByRef.Unwrap(content)
|
|
||||||
if content = invalid
|
if content = invalid
|
||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
+4
-2
@@ -1,8 +1,9 @@
|
|||||||
<component name="PlayQueueNotification" extends="Group">
|
<component name="VideoQueueNotification" extends="Group">
|
||||||
<interface>
|
<interface>
|
||||||
<field id="content" type="node" onChange="OnContentSet" />
|
<field id="content" type="node" onChange="OnContentSet" />
|
||||||
<field id="thumbnail" type="uri" alias="thumbnailPoster.uri" />
|
<field id="thumbnail" type="uri" alias="thumbnailPoster.uri" />
|
||||||
<field id="line1" type="string" alias="line1Label.text" />
|
<field id="line1" type="string" alias="line1Label.text" />
|
||||||
|
<field id="hintVisible" type="boolean" alias="hintLabel.visible" />
|
||||||
<field id="show" type="boolean" alwaysNotify="true" onChange="OnShow" />
|
<field id="show" type="boolean" alwaysNotify="true" onChange="OnShow" />
|
||||||
</interface>
|
</interface>
|
||||||
<children>
|
<children>
|
||||||
@@ -41,6 +42,7 @@
|
|||||||
wrap="true" />
|
wrap="true" />
|
||||||
</LayoutGroup>
|
</LayoutGroup>
|
||||||
<Label
|
<Label
|
||||||
|
id="hintLabel"
|
||||||
width="480"
|
width="480"
|
||||||
font="font:SmallestSystemFont"
|
font="font:SmallestSystemFont"
|
||||||
color="0x262626ff"
|
color="0x262626ff"
|
||||||
@@ -55,7 +57,7 @@
|
|||||||
id="translationAnimationInterpolator"
|
id="translationAnimationInterpolator"
|
||||||
key="[0.0, 0.5, 1.0]"
|
key="[0.0, 0.5, 1.0]"
|
||||||
keyValue="[ [1280.0, 20.0], [1020.0, 20.0], [760.0, 20.0] ]"
|
keyValue="[ [1280.0, 20.0], [1020.0, 20.0], [760.0, 20.0] ]"
|
||||||
fieldToInterp="PlayQueueNotification.translation" />
|
fieldToInterp="VideoQueueNotification.translation" />
|
||||||
</Animation>
|
</Animation>
|
||||||
<Timer
|
<Timer
|
||||||
id="animationTimer"
|
id="animationTimer"
|
||||||
+5
-4
@@ -1,13 +1,14 @@
|
|||||||
namespace PlayQueue
|
namespace VideoQueue
|
||||||
const NOTIFICATION_NODE_ID = "PlayQueueNotification"
|
const NOTIFICATION_NODE_ID = "VideoQueueNotification"
|
||||||
|
|
||||||
function ShowNotifcation(notifications as object, contentNode as object) as void
|
function ShowNotifcation(notifications as object, contentNode as object, hintVisible as boolean) as void
|
||||||
notification = notifications.findNode(NOTIFICATION_NODE_ID)
|
notification = notifications.findNode(NOTIFICATION_NODE_ID)
|
||||||
if notification = invalid
|
if notification = invalid
|
||||||
notification = notifications.createChild("PlayQueueNotification")
|
notification = notifications.createChild("VideoQueueNotification")
|
||||||
notification.id = NOTIFICATION_NODE_ID
|
notification.id = NOTIFICATION_NODE_ID
|
||||||
end if
|
end if
|
||||||
notification.content = contentNode
|
notification.content = contentNode
|
||||||
|
notification.hintVisible = hintVisible
|
||||||
notification.show = true
|
notification.show = true
|
||||||
end function
|
end function
|
||||||
|
|
||||||
@@ -0,0 +1,373 @@
|
|||||||
|
import "pkg:/components/Services/LoungeService/LoungeMessages.bs"
|
||||||
|
import "pkg:/components/VideoFeed/FeedLoadState.bs"
|
||||||
|
import "pkg:/components/VideoQueue/Notifications/VideoQueueNotificationUtils.bs"
|
||||||
|
import "pkg:/source/AsyncTask/AsyncTask.bs"
|
||||||
|
import "pkg:/source/AsyncTask/Tasks.bs"
|
||||||
|
import "pkg:/source/utils/FocusManagement.bs"
|
||||||
|
import "pkg:/source/utils/Logging.bs"
|
||||||
|
import "pkg:/source/utils/MathUtils.bs"
|
||||||
|
import "VideoQueueFunctions.bs"
|
||||||
|
|
||||||
|
function Init()
|
||||||
|
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 OnIndexChange()
|
||||||
|
index = m.top.index
|
||||||
|
m.content.index = index
|
||||||
|
nodes = m.content.getChildren(-1, 0)
|
||||||
|
for each node in nodes
|
||||||
|
node.queueIndex = index
|
||||||
|
end for
|
||||||
|
UpdateHasPreviousNext()
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnPlay() as void
|
||||||
|
videoNode = m.content.getChild(m.top.index)
|
||||||
|
if videoNode = invalid
|
||||||
|
m.top.nowPlaying = invalid
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
player = m.top.player
|
||||||
|
if player <> invalid
|
||||||
|
content = player.content
|
||||||
|
if content <> invalid and content.videoId = videoNode.videoId
|
||||||
|
if player.state = "paused"
|
||||||
|
player.control = "resume"
|
||||||
|
else
|
||||||
|
player.control = "play"
|
||||||
|
end if
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
m.top.closePlayer = true
|
||||||
|
end if
|
||||||
|
|
||||||
|
player = CreateVideoPlayer()
|
||||||
|
player@.PlayWithContent(videoNode)
|
||||||
|
m.top.player = player
|
||||||
|
m.top.nowPlaying = videoNode
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnPause() as void
|
||||||
|
player = m.top.player
|
||||||
|
if player = invalid
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
player.control = "pause"
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnPrevious() as void
|
||||||
|
if not m.top.hasPrevious
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
m.top.closePlayer = true
|
||||||
|
m.top.index -= 1
|
||||||
|
m.top.play = true
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnNext() as void
|
||||||
|
if not m.top.hasNext
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
m.top.closePlayer = true
|
||||||
|
m.top.index += 1
|
||||||
|
m.top.play = true
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnClosePlayer() as void
|
||||||
|
m.top.nowPlaying = invalid
|
||||||
|
player = m.top.player
|
||||||
|
if player = invalid
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
player@.Close()
|
||||||
|
m.top.player = invalid
|
||||||
|
|
||||||
|
m.top.appController@.FocusTopScreen()
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnPlayVideo() as void
|
||||||
|
videoNode = m.top.playVideo
|
||||||
|
if videoNode = invalid
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
m.top.playVideo = invalid
|
||||||
|
|
||||||
|
nodeParent = videoNode.getParent()
|
||||||
|
if not m.content.isSameNode(nodeParent)
|
||||||
|
videoNode = videoNode.clone(false)
|
||||||
|
end if
|
||||||
|
|
||||||
|
queueCount = m.content.getChildCount()
|
||||||
|
index = m.top.index
|
||||||
|
index += 1
|
||||||
|
if index >= queueCount
|
||||||
|
m.content.appendChild(videoNode)
|
||||||
|
index = m.content.getChildCount() - 1
|
||||||
|
else
|
||||||
|
m.content.insertChild(videoNode, index)
|
||||||
|
end if
|
||||||
|
m.top.index = index
|
||||||
|
|
||||||
|
m.top.closePlayer = true
|
||||||
|
m.top.play = true
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnPlayPlaylist() as void
|
||||||
|
playPlaylist = m.top.playPlaylist
|
||||||
|
if playPlaylist = invalid
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
m.top.playPlaylist = invalid
|
||||||
|
|
||||||
|
if m.loadingPlaylist <> invalid
|
||||||
|
m.loadingPlaylist.UnobserveFieldScoped("loadState")
|
||||||
|
m.loadingPlaylist = invalid
|
||||||
|
end if
|
||||||
|
|
||||||
|
playlistNode = playPlaylist.playlistNode
|
||||||
|
playlistIndex = playPlaylist.playlistIndex
|
||||||
|
|
||||||
|
if playlistNode = invalid or playlistIndex < 0
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
m.loadingPlaylist = playlistNode
|
||||||
|
m.loadingPlaylistIndex = playlistIndex
|
||||||
|
m.loadingPlaylistOp = "play"
|
||||||
|
|
||||||
|
if playlistNode.loadState = FeedLoadState.Loaded
|
||||||
|
OnPlaylistLoadStateChange()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
playlistNode.ObserveFieldScoped("loadState", FuncName(OnPlaylistLoadStateChange))
|
||||||
|
playlistNode@.LoadPlaylistAll(m.top.invidious)
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnPlaylistLoadStateChange() as void
|
||||||
|
if m.loadingPlaylist = invalid
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
loadState = m.loadingPlaylist.loadState
|
||||||
|
if loadState = FeedLoadState.None or loadState = FeedLoadState.Error
|
||||||
|
m.loadingPlaylist.UnobserveFieldScoped("loadState")
|
||||||
|
m.loadingPlaylist = invalid
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
if loadState <> FeedLoadState.Loaded
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
playlistNode = m.loadingPlaylist
|
||||||
|
playlistIndex = m.loadingPlaylistIndex
|
||||||
|
playlistOp = m.loadingPlaylistOp
|
||||||
|
|
||||||
|
m.loadingPlaylist.UnobserveFieldScoped("loadState")
|
||||||
|
m.loadingPlaylist = invalid
|
||||||
|
|
||||||
|
videoNodes = playlistNode.getChildren(-1, 0)
|
||||||
|
if videoNodes.Count() = 0
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
LogInfo("Adding", videoNodes.Count(), "videos to the queue")
|
||||||
|
|
||||||
|
for i = 0 to videoNodes.Count() - 1
|
||||||
|
videoNodes[i] = videoNodes[i].clone(false)
|
||||||
|
end for
|
||||||
|
|
||||||
|
if playlistOp = "play"
|
||||||
|
playlistIndex = MathUtils.Clamp(playlistIndex, 0, videoNodes.Count() - 1)
|
||||||
|
|
||||||
|
' If the playlist is already in the queue as is, play it from there.
|
||||||
|
existingIndex = FindPlaylistVideosInQueue(videoNodes)
|
||||||
|
if existingIndex >= 0
|
||||||
|
m.top.index = existingIndex + playlistIndex
|
||||||
|
m.top.closePlayer = true
|
||||||
|
m.top.play = true
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
queueCount = m.content.getChildCount()
|
||||||
|
index = m.top.index
|
||||||
|
index += 1
|
||||||
|
if index >= queueCount
|
||||||
|
m.content.appendChildren(videoNodes)
|
||||||
|
else
|
||||||
|
m.content.insertChildren(videoNodes, index)
|
||||||
|
end if
|
||||||
|
|
||||||
|
m.top.index = index + playlistIndex
|
||||||
|
|
||||||
|
m.top.closePlayer = true
|
||||||
|
m.top.play = true
|
||||||
|
else if playlistOp = "queue"
|
||||||
|
m.content.appendChildren(videoNodes)
|
||||||
|
UpdateHasPreviousNext()
|
||||||
|
|
||||||
|
queueNotifications = m.top.preferences["misc.queue_notifications"]
|
||||||
|
if queueNotifications
|
||||||
|
hintVisible = m.top.player = invalid or not m.top.videoContainer.fullscreen
|
||||||
|
VideoQueue.ShowNotifcation(m.top.notifications, playlistNode, hintVisible)
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
end function
|
||||||
|
|
||||||
|
function FindPlaylistVideosInQueue(videoNodes as object) as integer
|
||||||
|
queueCount = m.content.getChildCount()
|
||||||
|
playlistCount = videoNodes.Count()
|
||||||
|
if queueCount < playlistCount
|
||||||
|
return -1
|
||||||
|
end if
|
||||||
|
|
||||||
|
queueVideos = m.content.getChildren(-1, 0)
|
||||||
|
|
||||||
|
' array in array search based on node.videoId, starting from the end
|
||||||
|
for i = queueCount - playlistCount to 0 step -1
|
||||||
|
found = true
|
||||||
|
for j = 0 to playlistCount - 1
|
||||||
|
if queueVideos[i + j].videoId <> videoNodes[j].videoId
|
||||||
|
found = false
|
||||||
|
exit for
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
if found
|
||||||
|
return i
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
|
||||||
|
return -1
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnClearQueue()
|
||||||
|
queueCount = m.content.getChildCount()
|
||||||
|
if queueCount > 0
|
||||||
|
m.content.removeChildrenIndex(queueCount, 0)
|
||||||
|
end if
|
||||||
|
|
||||||
|
m.top.closePlayer = true
|
||||||
|
m.top.index = -1
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnAddToQueue() as void
|
||||||
|
videoNodes = m.top.addToQueue
|
||||||
|
if videoNodes = invalid
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
m.top.addToQueue = invalid
|
||||||
|
if videoNodes.Count() = 0
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
for i = 0 to videoNodes.Count() - 1
|
||||||
|
videoNodes[i] = videoNodes[i].clone(false)
|
||||||
|
end for
|
||||||
|
|
||||||
|
m.content.appendChildren(videoNodes)
|
||||||
|
UpdateHasPreviousNext()
|
||||||
|
|
||||||
|
queueNotifications = m.top.preferences["misc.queue_notifications"]
|
||||||
|
if queueNotifications
|
||||||
|
node = videoNodes[0]
|
||||||
|
hintVisible = m.top.player = invalid or not m.top.videoContainer.fullscreen
|
||||||
|
VideoQueue.ShowNotifcation(m.top.notifications, node, hintVisible)
|
||||||
|
end if
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnAddToQueuePlaylist() as void
|
||||||
|
playlistNode = m.top.addToQueuePlaylist
|
||||||
|
if playlistNode = invalid
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
m.top.addToQueuePlaylist = invalid
|
||||||
|
|
||||||
|
if m.loadingPlaylist <> invalid
|
||||||
|
m.loadingPlaylist.UnobserveFieldScoped("loadState")
|
||||||
|
m.loadingPlaylist = invalid
|
||||||
|
end if
|
||||||
|
|
||||||
|
m.loadingPlaylist = playlistNode
|
||||||
|
m.loadingPlaylistOp = "queue"
|
||||||
|
|
||||||
|
if playlistNode.loadState = FeedLoadState.Loaded
|
||||||
|
OnPlaylistLoadStateChange()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
playlistNode.ObserveFieldScoped("loadState", FuncName(OnPlaylistLoadStateChange))
|
||||||
|
playlistNode@.LoadPlaylistAll(m.top.invidious)
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnSetQueueAndIndex() as void
|
||||||
|
setQueueAndIndex = m.top.setQueueAndIndex
|
||||||
|
if setQueueAndIndex = invalid
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
m.top.setQueueAndIndex = invalid
|
||||||
|
|
||||||
|
videoNodes = setQueueAndIndex.videoNodes
|
||||||
|
index = setQueueAndIndex.index
|
||||||
|
|
||||||
|
queueCount = m.content.getChildCount()
|
||||||
|
if queueCount > 0
|
||||||
|
m.content.removeChildrenIndex(queueCount, 0)
|
||||||
|
end if
|
||||||
|
|
||||||
|
if videoNodes.Count() > 0
|
||||||
|
m.content.appendChildren(videoNodes)
|
||||||
|
end if
|
||||||
|
|
||||||
|
m.top.index = index
|
||||||
|
end function
|
||||||
|
|
||||||
|
function UpdateHasPreviousNext()
|
||||||
|
queueCount = m.content.getChildCount()
|
||||||
|
index = MathUtils.Clamp(m.top.index, 0, queueCount - 1)
|
||||||
|
m.top.hasPrevious = index > 0
|
||||||
|
m.top.hasNext = index < queueCount - 1
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnHasPrevious()
|
||||||
|
message = LoungeMessages.OnHasPreviousNextChanged(m.top.hasPrevious, m.top.hasNext)
|
||||||
|
m.top.loungeService.outgoingMessages = [message]
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnHasNext()
|
||||||
|
' TODO:P1 the hasNext currently does not account for autoplay.
|
||||||
|
message = LoungeMessages.OnHasPreviousNextChanged(m.top.hasPrevious, m.top.hasNext)
|
||||||
|
m.top.loungeService.outgoingMessages = [message]
|
||||||
|
end function
|
||||||
|
|
||||||
|
function CreateVideoPlayer() as object
|
||||||
|
container = m.top.videoContainer
|
||||||
|
videoPlayer = container.createChild("VideoPlayer")
|
||||||
|
videoPlayer.id = "VideoPlayer"
|
||||||
|
videoPlayer@.BindNode()
|
||||||
|
|
||||||
|
if container.fullscreen
|
||||||
|
NodeSetFocus(videoPlayer, true)
|
||||||
|
|
||||||
|
dialog = m.top.getScene().dialog
|
||||||
|
if dialog <> invalid
|
||||||
|
dialog.close = true
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
|
||||||
|
return videoPlayer
|
||||||
|
end function
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
<component name="VideoQueue" extends="Node">
|
||||||
|
<interface>
|
||||||
|
<field id="content" type="node" />
|
||||||
|
<field id="index" type="integer" value="-1" onChange="OnIndexChange" alwaysNotify="true" />
|
||||||
|
|
||||||
|
<field id="hasPrevious" type="boolean" onChange="OnHasPrevious" />
|
||||||
|
<field id="hasNext" type="boolean" onChange="OnHasNext" />
|
||||||
|
|
||||||
|
<field id="play" type="boolean" alwaysNotify="true" onChange="OnPlay" />
|
||||||
|
<field id="pause" type="boolean" alwaysNotify="true" onChange="OnPause" />
|
||||||
|
<field id="previous" type="boolean" alwaysNotify="true" onChange="OnPrevious" />
|
||||||
|
<field id="next" type="boolean" alwaysNotify="true" onChange="OnNext" />
|
||||||
|
<field id="closePlayer" type="boolean" alwaysNotify="true" onChange="OnClosePlayer" />
|
||||||
|
<field id="playVideo" type="node" alwaysNotify="true" onChange="OnPlayVideo" />
|
||||||
|
<field id="playPlaylist" type="assocarray" alwaysNotify="true" onChange="OnPlayPlaylist" />
|
||||||
|
|
||||||
|
<field id="clearQueue" type="boolean" alwaysNotify="true" onChange="OnClearQueue" />
|
||||||
|
<field id="addToQueue" type="array" onChange="OnAddToQueue" />
|
||||||
|
<field id="addToQueuePlaylist" type="node" onChange="OnAddToQueuePlaylist" />
|
||||||
|
<field id="setQueueAndIndex" type="assocarray" onChange="OnSetQueueAndIndex" />
|
||||||
|
|
||||||
|
<field id="player" type="node" />
|
||||||
|
<field id="nowPlaying" type="node" />
|
||||||
|
|
||||||
|
<field id="invidious" type="node" />
|
||||||
|
<field id="notifications" type="node" />
|
||||||
|
<field id="preferences" type="node" />
|
||||||
|
<field id="videoContainer" type="node" />
|
||||||
|
<field id="appController" type="node" />
|
||||||
|
<field id="loungeService" type="node" />
|
||||||
|
|
||||||
|
<!-- Convenience functions to use from context menu -->
|
||||||
|
<function name="FuncPlayVideo" />
|
||||||
|
<function name="FuncPlayPlaylist" />
|
||||||
|
<function name="FuncAddToQueueVideo" />
|
||||||
|
<function name="FuncAddToQueuePlaylist" />
|
||||||
|
</interface>
|
||||||
|
<children>
|
||||||
|
<ContentNode id="Content" />
|
||||||
|
</children>
|
||||||
|
</component>
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
' Convenience functions to use from context menu
|
||||||
|
|
||||||
|
function FuncPlayVideo(videoNode as object)
|
||||||
|
m.top.playVideo = videoNode
|
||||||
|
end function
|
||||||
|
|
||||||
|
function FuncPlayPlaylist(playlistNode as object, playlistIndex as integer)
|
||||||
|
m.top.playPlaylist = {
|
||||||
|
playlistNode: playlistNode
|
||||||
|
playlistIndex: playlistIndex
|
||||||
|
}
|
||||||
|
end function
|
||||||
|
|
||||||
|
function FuncAddToQueueVideo(videoNode as object)
|
||||||
|
m.top.addToQueue = [videoNode]
|
||||||
|
end function
|
||||||
|
|
||||||
|
function FuncAddToQueuePlaylist(playlistNode as object)
|
||||||
|
m.top.addToQueuePlaylist = playlistNode
|
||||||
|
end function
|
||||||
@@ -0,0 +1,162 @@
|
|||||||
|
import "pkg:/source/utils/FocusManagement.bs"
|
||||||
|
|
||||||
|
namespace VideoQueueUtils
|
||||||
|
|
||||||
|
function GetQueueDto(videoQueue as object) as object
|
||||||
|
items = []
|
||||||
|
nowPlaying = invalid
|
||||||
|
|
||||||
|
queueNodes = videoQueue.content.getChildren(-1, 0)
|
||||||
|
for each node in queueNodes
|
||||||
|
items.push({
|
||||||
|
type: node.type
|
||||||
|
videoId: node.videoId
|
||||||
|
title: node.title
|
||||||
|
author: node._author
|
||||||
|
thumbnail: node.thumbnail
|
||||||
|
})
|
||||||
|
end for
|
||||||
|
|
||||||
|
nowPlayingNode = videoQueue.nowPlaying
|
||||||
|
if nowPlayingNode <> invalid
|
||||||
|
nowPlaying = {
|
||||||
|
type: nowPlayingNode.type
|
||||||
|
videoId: nowPlayingNode.videoId
|
||||||
|
title: nowPlayingNode.title
|
||||||
|
author: nowPlayingNode._author
|
||||||
|
thumbnail: nowPlayingNode.thumbnail
|
||||||
|
}
|
||||||
|
end if
|
||||||
|
|
||||||
|
return {
|
||||||
|
items: items
|
||||||
|
nowPlaying: nowPlaying
|
||||||
|
index: videoQueue.index
|
||||||
|
}
|
||||||
|
end function
|
||||||
|
|
||||||
|
function IsVideoPlayerFullScreen(videoQueue as object) as boolean
|
||||||
|
return videoQueue.videoContainer.fullscreen
|
||||||
|
end function
|
||||||
|
|
||||||
|
function ToggleVideoPictureInPicture(videoQueue as object) as boolean
|
||||||
|
player = videoQueue.player
|
||||||
|
if player = invalid
|
||||||
|
return false
|
||||||
|
end if
|
||||||
|
videoContainer = videoQueue.videoContainer
|
||||||
|
videoContainer.fullscreen = not videoContainer.fullscreen
|
||||||
|
if videoContainer.fullscreen
|
||||||
|
NodeSetFocus(player, true)
|
||||||
|
else
|
||||||
|
videoQueue.appController@.FocusTopScreen()
|
||||||
|
end if
|
||||||
|
return true
|
||||||
|
end function
|
||||||
|
|
||||||
|
function IsVideoPlayerOpen(videoQueue as object) as boolean
|
||||||
|
return videoQueue.player <> invalid
|
||||||
|
end function
|
||||||
|
|
||||||
|
function Play(videoQueue as object) as boolean
|
||||||
|
player = videoQueue.player
|
||||||
|
if player = invalid
|
||||||
|
return false
|
||||||
|
end if
|
||||||
|
videoQueue.play = true
|
||||||
|
return true
|
||||||
|
end function
|
||||||
|
|
||||||
|
function Pause(videoQueue as object) as boolean
|
||||||
|
player = videoQueue.player
|
||||||
|
if player = invalid
|
||||||
|
return false
|
||||||
|
end if
|
||||||
|
videoQueue.pause = true
|
||||||
|
return true
|
||||||
|
end function
|
||||||
|
|
||||||
|
function Resume(videoQueue as object) as boolean
|
||||||
|
player = videoQueue.player
|
||||||
|
if player = invalid
|
||||||
|
return false
|
||||||
|
end if
|
||||||
|
videoQueue.play = true
|
||||||
|
return true
|
||||||
|
end function
|
||||||
|
|
||||||
|
function TogglePause(videoQueue as object) as boolean
|
||||||
|
player = videoQueue.player
|
||||||
|
if player = invalid
|
||||||
|
return false
|
||||||
|
end if
|
||||||
|
if player.state = "playing"
|
||||||
|
player.control = "pause"
|
||||||
|
return true
|
||||||
|
else if player.state = "paused"
|
||||||
|
player.control = "resume"
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
return false
|
||||||
|
end function
|
||||||
|
|
||||||
|
function PlayNext(videoQueue as object, invidiousNode as object, preferences as object) as boolean
|
||||||
|
if videoQueue.hasNext
|
||||||
|
videoQueue.next = true
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
|
||||||
|
if preferences["playback.autoplay"] <> true
|
||||||
|
return false
|
||||||
|
end if
|
||||||
|
|
||||||
|
player = videoQueue.player
|
||||||
|
if player = invalid
|
||||||
|
return false
|
||||||
|
end if
|
||||||
|
|
||||||
|
content = player.content
|
||||||
|
if content = invalid
|
||||||
|
return false
|
||||||
|
end if
|
||||||
|
|
||||||
|
metadata = content.metadata
|
||||||
|
if metadata = invalid
|
||||||
|
return false
|
||||||
|
end if
|
||||||
|
|
||||||
|
recommendedVideos = metadata.recommendedVideos
|
||||||
|
if recommendedVideos = invalid
|
||||||
|
return false
|
||||||
|
end if
|
||||||
|
|
||||||
|
if recommendedVideos = invalid or recommendedVideos.Count() = 0
|
||||||
|
return false
|
||||||
|
end if
|
||||||
|
|
||||||
|
queueContent = videoQueue.content
|
||||||
|
for each recommendedVideo in recommendedVideos
|
||||||
|
if recommendedVideo = invalid
|
||||||
|
continue for
|
||||||
|
end if
|
||||||
|
videoId = recommendedVideo.videoId
|
||||||
|
if videoId = invalid
|
||||||
|
continue for
|
||||||
|
end if
|
||||||
|
|
||||||
|
existingVideo = queueContent.findNode(videoId)
|
||||||
|
if existingVideo <> invalid
|
||||||
|
continue for
|
||||||
|
end if
|
||||||
|
|
||||||
|
LogInfo(`Playing next recommended video (${videoId})`)
|
||||||
|
instance = invidiousNode@.GetCurrentInstance()
|
||||||
|
node = InvidiousContent.ToVideoContentNode(invalid, recommendedVideo, instance)
|
||||||
|
videoQueue.playVideo = node
|
||||||
|
return true
|
||||||
|
end for
|
||||||
|
|
||||||
|
return false
|
||||||
|
end function
|
||||||
|
|
||||||
|
end namespace
|
||||||
@@ -0,0 +1,154 @@
|
|||||||
|
import "pkg:/components/Navigation/Navigation.bs"
|
||||||
|
import "pkg:/source/AsyncTask/AsyncTask.bs"
|
||||||
|
import "pkg:/source/AsyncTask/Tasks.bs"
|
||||||
|
import "pkg:/source/utils/DisposableObserve.bs"
|
||||||
|
import "pkg:/source/utils/FocusManagement.bs"
|
||||||
|
import "pkg:/source/utils/Logging.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")
|
||||||
|
|
||||||
|
DisposableObserveField(m.clearButton, "buttonSelected", FuncName(OnClearButtonSelected))
|
||||||
|
DisposableObserveField(m.queueList, "itemSelected", FuncName(OnItemSelected))
|
||||||
|
|
||||||
|
SetNavigation(m.queueList, "up", m.clearButton)
|
||||||
|
SetNavigation(m.clearButton, "down", m.queueList)
|
||||||
|
|
||||||
|
m.videosDetailsToLoad = []
|
||||||
|
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
|
||||||
|
if m.loadDetailsTask <> invalid
|
||||||
|
m.loadDetailsTask.cancel = true
|
||||||
|
m.loadDetailsTask = invalid
|
||||||
|
end if
|
||||||
|
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
|
||||||
|
|
||||||
|
LoadVideoDetailsIfNeeded()
|
||||||
|
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()
|
||||||
|
m.top.dispose = true
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnClearButtonSelected()
|
||||||
|
m.top.videoQueue.clearQueue = true
|
||||||
|
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
|
||||||
|
|
||||||
|
videoQueue = m.top.videoQueue
|
||||||
|
videoQueue.index = index
|
||||||
|
videoQueue.play = true
|
||||||
|
end function
|
||||||
|
|
||||||
|
function LoadVideoDetailsIfNeeded() as void
|
||||||
|
content = m.queueList.content
|
||||||
|
if content = invalid
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
videoNodes = content.getChildren(-1, 0)
|
||||||
|
|
||||||
|
index = m.top.videoQueue.index
|
||||||
|
indexInLoadingArray = -1
|
||||||
|
|
||||||
|
m.videosDetailsToLoad.Clear()
|
||||||
|
for i = 0 to videoNodes.Count() - 1
|
||||||
|
videoNode = videoNodes[i]
|
||||||
|
' If the title is empty, it is likely that the details have not been loaded yet
|
||||||
|
if videoNode.title = ""
|
||||||
|
m.videosDetailsToLoad.Push(videoNode)
|
||||||
|
end if
|
||||||
|
|
||||||
|
if index = i
|
||||||
|
indexInLoadingArray = m.videosDetailsToLoad.Count() - 1
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
|
||||||
|
for each videoNode in videoNodes
|
||||||
|
if videoNode.title = ""
|
||||||
|
m.videosDetailsToLoad.Push(videoNode)
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
|
||||||
|
if m.videosDetailsToLoad.Count() = 0
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
LogInfo("Loading video details for", m.videosDetailsToLoad.Count(), "videos")
|
||||||
|
|
||||||
|
if m.loadDetailsTask <> invalid
|
||||||
|
m.loadDetailsTask.cancel = true
|
||||||
|
end if
|
||||||
|
|
||||||
|
m.loadDetailsTask = AsyncTask.Start(Tasks.VideoQueueViewContentTask, {
|
||||||
|
videoNodes: m.videosDetailsToLoad
|
||||||
|
invidious: m.top.invidious
|
||||||
|
index: indexInLoadingArray
|
||||||
|
})
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnDispose()
|
||||||
|
m.queueList.content = invalid
|
||||||
|
DisposeObservers()
|
||||||
|
if m.loadDetailsTask <> invalid
|
||||||
|
m.loadDetailsTask.cancel = true
|
||||||
|
m.loadDetailsTask = invalid
|
||||||
|
end if
|
||||||
|
end function
|
||||||
Loaded 100 of 176 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user