@xsynaptic/plazmoid-player 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/LICENSE +21 -0
- package/README.md +57 -2
- package/dist/astro.d.ts +4 -0
- package/dist/astro.js +33 -0
- package/dist/constants.d.ts +4 -0
- package/dist/constants.js +7 -0
- package/dist/define/artist-line.d.ts +1 -0
- package/dist/define/artist-line.js +6 -0
- package/dist/define/artwork.d.ts +1 -0
- package/dist/define/artwork.js +5 -0
- package/dist/define/bar.d.ts +1 -0
- package/dist/define/bar.js +5 -0
- package/dist/define/cue-list.d.ts +1 -0
- package/dist/define/cue-list.js +5 -0
- package/dist/define/mute-button.d.ts +1 -0
- package/dist/define/mute-button.js +6 -0
- package/dist/define/overlay-content.d.ts +1 -0
- package/dist/define/overlay-content.js +6 -0
- package/dist/define/overlay-toggle.d.ts +1 -0
- package/dist/define/overlay-toggle.js +6 -0
- package/dist/define/overlay.d.ts +1 -0
- package/dist/define/overlay.js +5 -0
- package/dist/define/panel-toggle.d.ts +1 -0
- package/dist/define/panel-toggle.js +6 -0
- package/dist/define/panel-zoom.d.ts +1 -0
- package/dist/define/panel-zoom.js +6 -0
- package/dist/define/panel.d.ts +1 -0
- package/dist/define/panel.js +5 -0
- package/dist/define/play-button.d.ts +1 -0
- package/dist/define/play-button.js +6 -0
- package/dist/define/progress.d.ts +1 -0
- package/dist/define/progress.js +6 -0
- package/dist/define/queue-actions.d.ts +1 -0
- package/dist/define/queue-actions.js +6 -0
- package/dist/define/queue-button.d.ts +1 -0
- package/dist/define/queue-button.js +6 -0
- package/dist/define/root.d.ts +1 -0
- package/dist/define/root.js +5 -0
- package/dist/define/scope.d.ts +1 -0
- package/dist/define/scope.js +5 -0
- package/dist/define/scrub-readout.d.ts +1 -0
- package/dist/define/scrub-readout.js +5 -0
- package/dist/define/seek-button.d.ts +1 -0
- package/dist/define/seek-button.js +6 -0
- package/dist/define/status.d.ts +1 -0
- package/dist/define/status.js +5 -0
- package/dist/define/step-button.d.ts +1 -0
- package/dist/define/step-button.js +6 -0
- package/dist/define/time-slider.d.ts +1 -0
- package/dist/define/time-slider.js +6 -0
- package/dist/define/time.d.ts +1 -0
- package/dist/define/time.js +5 -0
- package/dist/define/title.d.ts +1 -0
- package/dist/define/title.js +6 -0
- package/dist/define/tray.d.ts +1 -0
- package/dist/define/tray.js +6 -0
- package/dist/define/volume.d.ts +1 -0
- package/dist/define/volume.js +6 -0
- package/dist/define.d.ts +1 -0
- package/dist/define.js +4 -0
- package/dist/elements/artist-line.js +30 -0
- package/dist/elements/artwork.js +40 -0
- package/dist/elements/bind-buffered.js +20 -0
- package/dist/elements/bind-player.js +22 -0
- package/dist/elements/bind-scrub-preview.js +13 -0
- package/dist/elements/button-part.js +32 -0
- package/dist/elements/create-player.d.ts +16 -0
- package/dist/elements/create-player.js +22 -0
- package/dist/elements/define-once.js +6 -0
- package/dist/elements/define.js +60 -0
- package/dist/elements/mute-button.js +25 -0
- package/dist/elements/overlay/overlay-body.js +172 -0
- package/dist/elements/overlay/overlay-content.js +23 -0
- package/dist/elements/overlay/overlay-grab.js +69 -0
- package/dist/elements/overlay/overlay-module.js +12 -0
- package/dist/elements/overlay/overlay-sheets.js +38 -0
- package/dist/elements/overlay/overlay-tabs.js +95 -0
- package/dist/elements/overlay/overlay.js +54 -0
- package/dist/elements/overlay/tracklist.js +76 -0
- package/dist/elements/overlay-toggle.js +39 -0
- package/dist/elements/panel/panel-module.js +9 -0
- package/dist/elements/panel/panel-surface.js +92 -0
- package/dist/elements/panel/panel-zoom.js +55 -0
- package/dist/elements/panel/panel.js +45 -0
- package/dist/elements/panel-toggle.js +43 -0
- package/dist/elements/place-seek-buttons.js +11 -0
- package/dist/elements/play-button.js +32 -0
- package/dist/elements/player-bar.js +54 -0
- package/dist/elements/player-context.js +19 -0
- package/dist/elements/player-element.d.ts +9 -0
- package/dist/elements/player-element.js +36 -0
- package/dist/elements/player-root.d.ts +27 -0
- package/dist/elements/player-root.js +96 -0
- package/dist/elements/progress.js +50 -0
- package/dist/elements/queue-button.js +92 -0
- package/dist/elements/scope/scope-module.js +9 -0
- package/dist/elements/scope/scope-surface.js +26 -0
- package/dist/elements/scope/scope.js +61 -0
- package/dist/elements/scrub-readout.js +63 -0
- package/dist/elements/seek-button.js +42 -0
- package/dist/elements/status.js +37 -0
- package/dist/elements/step-button.js +36 -0
- package/dist/elements/time-slider/label-placement.js +11 -0
- package/dist/elements/time-slider/spoken-time.js +39 -0
- package/dist/elements/time-slider/time-slider.js +139 -0
- package/dist/elements/time.js +47 -0
- package/dist/elements/title.js +46 -0
- package/dist/elements/tray/drop-index.js +8 -0
- package/dist/elements/tray/queue-actions.js +58 -0
- package/dist/elements/tray/row-drag.js +123 -0
- package/dist/elements/tray/tray-module.js +11 -0
- package/dist/elements/tray/tray-rows.js +85 -0
- package/dist/elements/tray/tray.js +102 -0
- package/dist/elements/volume-level.js +23 -0
- package/dist/elements/volume.js +41 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +5 -0
- package/dist/labels.d.ts +36 -0
- package/dist/labels.js +39 -0
- package/dist/lib/bind-button.js +12 -0
- package/dist/lib/bind-preload.js +11 -0
- package/dist/lib/can-set-volume.js +15 -0
- package/dist/lib/dialog-exit.js +50 -0
- package/dist/lib/dismiss.js +15 -0
- package/dist/lib/format.js +12 -0
- package/dist/lib/icons.js +106 -0
- package/dist/lib/keyed-children.js +34 -0
- package/dist/lib/lazy-module.d.ts +5 -0
- package/dist/lib/lazy-module.js +41 -0
- package/dist/lib/observe-resize.js +10 -0
- package/dist/lib/preload-when-queued.js +29 -0
- package/dist/lib/read-px-property.js +7 -0
- package/dist/lib/render.js +22 -0
- package/dist/lib/sonic-button.js +22 -0
- package/dist/lib/supersede.js +19 -0
- package/dist/player.css +33 -0
- package/dist/styles/bar.css +253 -0
- package/dist/styles/coarse.css +47 -0
- package/dist/styles/controls.css +220 -0
- package/dist/styles/cue.css +53 -0
- package/dist/styles/focus.css +12 -0
- package/dist/styles/host.css +34 -0
- package/dist/styles/overlay-layout.css +258 -0
- package/dist/styles/overlay.css +282 -0
- package/dist/styles/panel.css +94 -0
- package/dist/styles/primitives.css +176 -0
- package/dist/styles/reset.css +21 -0
- package/dist/styles/status.css +42 -0
- package/dist/styles/tokens.css +142 -0
- package/dist/styles/track.css +150 -0
- package/dist/styles/tray.css +151 -0
- package/dist/types.d.ts +37 -0
- package/dist/view/view-persistence.js +33 -0
- package/dist/view/view-store.d.ts +30 -0
- package/dist/view/view-store.js +64 -0
- package/dist/view/zoom-levels.js +21 -0
- package/dist/waveform/bind-loaded-waveform.js +36 -0
- package/dist/waveform/cue-markers.js +31 -0
- package/dist/waveform/known-peaks.js +9 -0
- package/dist/waveform/overview-values.js +13 -0
- package/dist/waveform/retry-delay.js +8 -0
- package/dist/waveform/tint-cell.js +15 -0
- package/dist/waveform/waveform-peaks.js +144 -0
- package/package.json +80 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# @xsynaptic/plazmoid-player
|
|
2
|
+
|
|
3
|
+
## 0.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- The skin resets its own buttons, paragraphs and lists, so it no longer needs a host reset.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @xsynaptic/plazmoid-core@0.1.1
|
|
10
|
+
- @xsynaptic/plazmoid-wavedata@0.1.1
|
|
11
|
+
|
|
12
|
+
## 0.1.0
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- First release
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
- @xsynaptic/plazmoid-core@0.1.0
|
|
22
|
+
- @xsynaptic/plazmoid-wavedata@0.1.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Alexander Synaptic
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,58 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @xsynaptic/plazmoid-player
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The interface for the Plazmoid audio player: a player bar with a queue tray, a waveform panel, a scope and a full-screen view on phones. It's built from light-DOM custom elements on [sonic-ui](https://www.npmjs.com/package/@xsynaptic/sonic-ui) controls, and comes with a dark skin. Playback is handled by [`@xsynaptic/plazmoid-core`](https://www.npmjs.com/package/@xsynaptic/plazmoid-core).
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
Install this package along with its peer dependencies, `@xsynaptic/plazmoid-core` and `@xsynaptic/sonic-ui`.
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { createPlayerStore } from '@xsynaptic/plazmoid-core';
|
|
11
|
+
import { createPlayer, createViewStore } from '@xsynaptic/plazmoid-player';
|
|
12
|
+
import { defaultLabels } from '@xsynaptic/plazmoid-player/labels';
|
|
13
|
+
|
|
14
|
+
import '@xsynaptic/plazmoid-player/player.css';
|
|
15
|
+
|
|
16
|
+
const root = createPlayer({
|
|
17
|
+
labels: { ...defaultLabels },
|
|
18
|
+
store: createPlayerStore(),
|
|
19
|
+
urls,
|
|
20
|
+
view: createViewStore(),
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
document.body.append(root);
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
`createPlayer` returns a `<pzm-root>` holding the bar. Its options are read once, when the bar is first added to the page. Core's README covers `urls`, play buttons on the page and loading the player late.
|
|
27
|
+
|
|
28
|
+
`labels` is required, so a translated site doesn't ship the English strings. Spread `defaultLabels` and override what you need.
|
|
29
|
+
|
|
30
|
+
The main entry registers nothing on import and can't load in Node. `./define` registers the elements by side effect, so a bundler that ignores this package's `sideEffects` field will drop it. The queue tray, waveform panel, scope and full-screen view load the first time they open.
|
|
31
|
+
|
|
32
|
+
## Astro's client router
|
|
33
|
+
|
|
34
|
+
To keep the bar playing across page changes, put it in an element with `transition:persist` and use the helpers from `./astro`:
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import { bindAstroRouter, loadPersistedStylesheet } from '@xsynaptic/plazmoid-player/astro';
|
|
38
|
+
|
|
39
|
+
await loadPersistedStylesheet(stylesheetUrl);
|
|
40
|
+
|
|
41
|
+
bindAstroRouter(view, bindPageControls(store, document));
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
The router drops any head stylesheet the next page doesn't link, so `loadPersistedStylesheet` carries the skin across. `bindAstroRouter` closes the full-screen view before a navigation and refreshes the page controls after it.
|
|
45
|
+
|
|
46
|
+
## Styling
|
|
47
|
+
|
|
48
|
+
The elements, the `pzm-*` classes and the `--pzm-*` custom properties are all public. `<pzm-root>` also reflects the player's state in `data-*` attributes, such as `data-status` and `data-paused`, for your own rules.
|
|
49
|
+
|
|
50
|
+
Some animations carry meaning, like the loading ring on the play button. While one runs, its element has `data-pzm-essential-motion`, so a global reduced-motion reset can leave it alone:
|
|
51
|
+
|
|
52
|
+
```css
|
|
53
|
+
@media (prefers-reduced-motion: reduce) {
|
|
54
|
+
*:not([data-pzm-essential-motion])::after {
|
|
55
|
+
animation-duration: 0.01ms !important;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
package/dist/astro.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { PageControls } from "@xsynaptic/plazmoid-core";
|
|
2
|
+
import { ViewStoreApi } from "./view/view-store.js";
|
|
3
|
+
export declare function bindAstroRouter(view: ViewStoreApi, controls: PageControls): () => void;
|
|
4
|
+
export declare function loadPersistedStylesheet(href: string): Promise<void>;
|
package/dist/astro.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// src/astro.ts
|
|
2
|
+
function bindAstroRouter(view, controls) {
|
|
3
|
+
const connection = new AbortController();
|
|
4
|
+
const { signal } = connection;
|
|
5
|
+
document.addEventListener("astro:before-preparation", () => {
|
|
6
|
+
view.getState().setOverlayOpen(false);
|
|
7
|
+
}, { signal });
|
|
8
|
+
document.addEventListener("astro:after-swap", () => {
|
|
9
|
+
controls.refresh();
|
|
10
|
+
}, { signal });
|
|
11
|
+
return () => {
|
|
12
|
+
connection.abort();
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function loadPersistedStylesheet(href) {
|
|
16
|
+
const link = document.createElement("link");
|
|
17
|
+
link.href = href;
|
|
18
|
+
link.rel = "stylesheet";
|
|
19
|
+
document.addEventListener("astro:before-swap", { handleEvent: ({ newDocument }) => {
|
|
20
|
+
newDocument.head.append(link.cloneNode());
|
|
21
|
+
} });
|
|
22
|
+
return new Promise((resolve) => {
|
|
23
|
+
link.addEventListener("error", () => {
|
|
24
|
+
resolve();
|
|
25
|
+
});
|
|
26
|
+
link.addEventListener("load", () => {
|
|
27
|
+
resolve();
|
|
28
|
+
});
|
|
29
|
+
document.head.append(link);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { bindAstroRouter, loadPersistedStylesheet };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// src/constants.ts
|
|
2
|
+
const barArtworkSize = 120;
|
|
3
|
+
const panelOpenStorageKey = "pzm-panel-open";
|
|
4
|
+
const panelZoomStorageKey = "pzm-panel-zoom";
|
|
5
|
+
const timeModeStorageKey = "pzm-time-mode";
|
|
6
|
+
|
|
7
|
+
export { barArtworkSize, panelOpenStorageKey, panelZoomStorageKey, timeModeStorageKey };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@xsynaptic/sonic-ui/define/ticker";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@xsynaptic/sonic-ui/define/button";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@xsynaptic/sonic-ui/define/button";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import "@xsynaptic/sonic-ui/define/button";
|
|
2
|
+
import { defineOnce } from "../elements/define-once.js";
|
|
3
|
+
import { PlayerOverlayContent } from "../elements/overlay/overlay-content.js";
|
|
4
|
+
|
|
5
|
+
// src/define/overlay-content.ts
|
|
6
|
+
defineOnce("pzm-overlay-content", PlayerOverlayContent);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@xsynaptic/sonic-ui/define/button";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@xsynaptic/sonic-ui/define/button";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@xsynaptic/sonic-ui/define/button";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@xsynaptic/sonic-ui/define/button";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@xsynaptic/sonic-ui/define/slider";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@xsynaptic/sonic-ui/define/button";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@xsynaptic/sonic-ui/define/button";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@xsynaptic/sonic-ui/define/button";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@xsynaptic/sonic-ui/define/button";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@xsynaptic/sonic-ui/define/wavestrip";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@xsynaptic/sonic-ui/define/ticker";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@xsynaptic/sonic-ui/define/button";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@xsynaptic/sonic-ui/define/dial";
|
package/dist/define.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
package/dist/define.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { bind, displayedTrack } from "@xsynaptic/plazmoid-core";
|
|
2
|
+
import { playerContext } from "./player-context.js";
|
|
3
|
+
import { PlayerElement } from "./player-element.js";
|
|
4
|
+
import { template } from "../lib/render.js";
|
|
5
|
+
|
|
6
|
+
// src/elements/artist-line.ts
|
|
7
|
+
const renderLine = template("<span class=\"pzm-track-artist\"></span>", HTMLSpanElement);
|
|
8
|
+
var PlayerArtistLine = class extends PlayerElement {
|
|
9
|
+
#ticker = document.createElement("sonic-ticker");
|
|
10
|
+
#line = lineAround(this.#ticker);
|
|
11
|
+
connect(signal) {
|
|
12
|
+
const { store } = playerContext(this);
|
|
13
|
+
this.#ticker.cancellable = true;
|
|
14
|
+
this.appendOnce(this.#line);
|
|
15
|
+
bind(store, selectArtistLine, (artistLine) => {
|
|
16
|
+
this.hidden = artistLine === void 0;
|
|
17
|
+
this.#ticker.text = artistLine;
|
|
18
|
+
}, signal);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
function lineAround(ticker) {
|
|
22
|
+
const line = renderLine();
|
|
23
|
+
line.append(ticker);
|
|
24
|
+
return line;
|
|
25
|
+
}
|
|
26
|
+
function selectArtistLine(state) {
|
|
27
|
+
return displayedTrack(state)?.artistLine;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { PlayerArtistLine };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { bind, displayedTrack } from "@xsynaptic/plazmoid-core";
|
|
2
|
+
import { barArtworkSize } from "../constants.js";
|
|
3
|
+
import { playerContext } from "./player-context.js";
|
|
4
|
+
import { PlayerElement } from "./player-element.js";
|
|
5
|
+
import { template } from "../lib/render.js";
|
|
6
|
+
|
|
7
|
+
// src/elements/artwork.ts
|
|
8
|
+
const barSize = String(120);
|
|
9
|
+
const renderImage = template(`<img alt="" class="pzm-artwork" decoding="async" height="${barSize}" loading="lazy" width="${barSize}">`, HTMLImageElement);
|
|
10
|
+
var PlayerArtwork = class extends PlayerElement {
|
|
11
|
+
#failedSrc;
|
|
12
|
+
#image = renderImage();
|
|
13
|
+
connect(signal) {
|
|
14
|
+
const { store } = playerContext(this);
|
|
15
|
+
const image = this.#image;
|
|
16
|
+
image.sizes = this.getAttribute("sizes") ?? `${barSize}px`;
|
|
17
|
+
image.addEventListener("error", () => {
|
|
18
|
+
this.#failedSrc = image.getAttribute("src") ?? void 0;
|
|
19
|
+
this.#apply(selectArtwork(store.getState()));
|
|
20
|
+
}, { signal });
|
|
21
|
+
bind(store, selectArtwork, (artwork) => {
|
|
22
|
+
this.#apply(artwork);
|
|
23
|
+
}, signal);
|
|
24
|
+
}
|
|
25
|
+
#apply(artwork) {
|
|
26
|
+
const first = artwork?.[0];
|
|
27
|
+
if (!artwork || !first || first.src === this.#failedSrc) {
|
|
28
|
+
this.#image.remove();
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
this.#image.srcset = artwork.map(({ src, width }) => `${src} ${String(width)}w`).join(", ");
|
|
32
|
+
this.#image.src = first.src;
|
|
33
|
+
this.appendOnce(this.#image);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
function selectArtwork(state) {
|
|
37
|
+
return displayedTrack(state)?.artwork;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { PlayerArtwork };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { bind } from "@xsynaptic/plazmoid-core";
|
|
2
|
+
|
|
3
|
+
// src/elements/bind-buffered.ts
|
|
4
|
+
const bufferedEvents = [
|
|
5
|
+
"emptied",
|
|
6
|
+
"loadeddata",
|
|
7
|
+
"progress",
|
|
8
|
+
"suspend"
|
|
9
|
+
];
|
|
10
|
+
function bindBuffered(control, store, signal) {
|
|
11
|
+
bind(store, (state) => state.getMediaElement(), (element) => {
|
|
12
|
+
const showBuffered = () => {
|
|
13
|
+
control.buffered = element?.buffered;
|
|
14
|
+
};
|
|
15
|
+
for (const type of bufferedEvents) element?.addEventListener(type, showBuffered, { signal });
|
|
16
|
+
showBuffered();
|
|
17
|
+
}, signal);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { bindBuffered };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { bind } from "@xsynaptic/plazmoid-core";
|
|
2
|
+
|
|
3
|
+
// src/elements/bind-player.ts
|
|
4
|
+
function bindPlayer({ store, view }, select, apply, signal) {
|
|
5
|
+
const read = () => [store.getState(), view.getState()];
|
|
6
|
+
bind({
|
|
7
|
+
getState: read,
|
|
8
|
+
subscribe: (listener) => {
|
|
9
|
+
const notify = () => {
|
|
10
|
+
listener(read());
|
|
11
|
+
};
|
|
12
|
+
const unsubscribeStore = store.subscribe(notify);
|
|
13
|
+
const unsubscribeView = view.subscribe(notify);
|
|
14
|
+
return () => {
|
|
15
|
+
unsubscribeStore();
|
|
16
|
+
unsubscribeView();
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
}, ([state, viewState]) => select(state, viewState), apply, signal);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { bindPlayer };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// src/elements/bind-scrub-preview.ts
|
|
2
|
+
function bindScrubPreview(control, preview, signal) {
|
|
3
|
+
const showPreview = () => {
|
|
4
|
+
preview(control.pointerType === "touch" && control.revealed ? control.value : void 0);
|
|
5
|
+
};
|
|
6
|
+
control.addEventListener("input", showPreview, { signal });
|
|
7
|
+
control.addEventListener("sonic-reveal", showPreview, { signal });
|
|
8
|
+
signal.addEventListener("abort", () => {
|
|
9
|
+
preview(void 0);
|
|
10
|
+
}, { once: true });
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { bindScrubPreview };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { playerContext } from "./player-context.js";
|
|
2
|
+
import { PlayerElement } from "./player-element.js";
|
|
3
|
+
import { bindButton } from "../lib/bind-button.js";
|
|
4
|
+
|
|
5
|
+
// src/elements/button-part.ts
|
|
6
|
+
var PlayerButtonPart = class extends PlayerElement {};
|
|
7
|
+
function buttonPart(readPart) {
|
|
8
|
+
return class extends PlayerButtonPart {
|
|
9
|
+
#button;
|
|
10
|
+
connect(signal) {
|
|
11
|
+
const part = readPart(this);
|
|
12
|
+
const context = playerContext(this);
|
|
13
|
+
const { labels } = context;
|
|
14
|
+
if (this.#button === void 0) this.#button = part.render();
|
|
15
|
+
const button = this.#button;
|
|
16
|
+
this.appendOnce(button);
|
|
17
|
+
if (part.label !== void 0) button.setAttribute("aria-label", labels[part.label]);
|
|
18
|
+
bindButton({
|
|
19
|
+
apply: (selected) => {
|
|
20
|
+
part.apply(button, selected, labels);
|
|
21
|
+
},
|
|
22
|
+
button,
|
|
23
|
+
press: part.press,
|
|
24
|
+
select: part.select,
|
|
25
|
+
store: part.store(context)
|
|
26
|
+
}, signal);
|
|
27
|
+
part.connect?.(button, context, signal);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { PlayerButtonPart, buttonPart };
|