@scarlett-player/ui 0.4.0 → 0.4.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/dist/index.cjs +12 -5
- package/dist/index.js +12 -5
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -647,12 +647,11 @@ var PlayButton = class {
|
|
|
647
647
|
const video = getVideo(this.api.container);
|
|
648
648
|
if (!video) return;
|
|
649
649
|
const ended = this.api.getState("ended");
|
|
650
|
-
const playing = this.api.getState("playing");
|
|
651
650
|
if (ended) {
|
|
652
651
|
video.currentTime = 0;
|
|
653
652
|
video.play().catch(() => {
|
|
654
653
|
});
|
|
655
|
-
} else if (
|
|
654
|
+
} else if (!video.paused) {
|
|
656
655
|
video.pause();
|
|
657
656
|
} else {
|
|
658
657
|
video.play().catch(() => {
|
|
@@ -1488,8 +1487,9 @@ function uiPlugin(config = {}) {
|
|
|
1488
1487
|
if (containerStyle.position === "static") {
|
|
1489
1488
|
container.style.position = "relative";
|
|
1490
1489
|
}
|
|
1490
|
+
const isPlaying = api.getState("playing");
|
|
1491
1491
|
gradient = document.createElement("div");
|
|
1492
|
-
gradient.className = "sp-gradient sp-gradient--visible";
|
|
1492
|
+
gradient.className = isPlaying ? "sp-gradient" : "sp-gradient sp-gradient--visible";
|
|
1493
1493
|
container.appendChild(gradient);
|
|
1494
1494
|
bufferingIndicator = document.createElement("div");
|
|
1495
1495
|
bufferingIndicator.className = "sp-buffering";
|
|
@@ -1498,9 +1498,11 @@ function uiPlugin(config = {}) {
|
|
|
1498
1498
|
container.appendChild(bufferingIndicator);
|
|
1499
1499
|
progressBar = new ProgressBar(api);
|
|
1500
1500
|
container.appendChild(progressBar.render());
|
|
1501
|
-
|
|
1501
|
+
if (!isPlaying) {
|
|
1502
|
+
progressBar.show();
|
|
1503
|
+
}
|
|
1502
1504
|
controlBar = document.createElement("div");
|
|
1503
|
-
controlBar.className = "sp-controls sp-controls--visible";
|
|
1505
|
+
controlBar.className = isPlaying ? "sp-controls sp-controls--hidden" : "sp-controls sp-controls--visible";
|
|
1504
1506
|
controlBar.setAttribute("role", "toolbar");
|
|
1505
1507
|
controlBar.setAttribute("aria-label", "Video controls");
|
|
1506
1508
|
for (const slot of layout) {
|
|
@@ -1523,6 +1525,11 @@ function uiPlugin(config = {}) {
|
|
|
1523
1525
|
if (!container.hasAttribute("tabindex")) {
|
|
1524
1526
|
container.setAttribute("tabindex", "0");
|
|
1525
1527
|
}
|
|
1528
|
+
controlsVisible = !isPlaying;
|
|
1529
|
+
api.setState("controlsVisible", controlsVisible);
|
|
1530
|
+
if (isPlaying) {
|
|
1531
|
+
resetHideTimer();
|
|
1532
|
+
}
|
|
1526
1533
|
api.logger.debug("UI controls plugin initialized");
|
|
1527
1534
|
},
|
|
1528
1535
|
async destroy() {
|
package/dist/index.js
CHANGED
|
@@ -616,12 +616,11 @@ var PlayButton = class {
|
|
|
616
616
|
const video = getVideo(this.api.container);
|
|
617
617
|
if (!video) return;
|
|
618
618
|
const ended = this.api.getState("ended");
|
|
619
|
-
const playing = this.api.getState("playing");
|
|
620
619
|
if (ended) {
|
|
621
620
|
video.currentTime = 0;
|
|
622
621
|
video.play().catch(() => {
|
|
623
622
|
});
|
|
624
|
-
} else if (
|
|
623
|
+
} else if (!video.paused) {
|
|
625
624
|
video.pause();
|
|
626
625
|
} else {
|
|
627
626
|
video.play().catch(() => {
|
|
@@ -1457,8 +1456,9 @@ function uiPlugin(config = {}) {
|
|
|
1457
1456
|
if (containerStyle.position === "static") {
|
|
1458
1457
|
container.style.position = "relative";
|
|
1459
1458
|
}
|
|
1459
|
+
const isPlaying = api.getState("playing");
|
|
1460
1460
|
gradient = document.createElement("div");
|
|
1461
|
-
gradient.className = "sp-gradient sp-gradient--visible";
|
|
1461
|
+
gradient.className = isPlaying ? "sp-gradient" : "sp-gradient sp-gradient--visible";
|
|
1462
1462
|
container.appendChild(gradient);
|
|
1463
1463
|
bufferingIndicator = document.createElement("div");
|
|
1464
1464
|
bufferingIndicator.className = "sp-buffering";
|
|
@@ -1467,9 +1467,11 @@ function uiPlugin(config = {}) {
|
|
|
1467
1467
|
container.appendChild(bufferingIndicator);
|
|
1468
1468
|
progressBar = new ProgressBar(api);
|
|
1469
1469
|
container.appendChild(progressBar.render());
|
|
1470
|
-
|
|
1470
|
+
if (!isPlaying) {
|
|
1471
|
+
progressBar.show();
|
|
1472
|
+
}
|
|
1471
1473
|
controlBar = document.createElement("div");
|
|
1472
|
-
controlBar.className = "sp-controls sp-controls--visible";
|
|
1474
|
+
controlBar.className = isPlaying ? "sp-controls sp-controls--hidden" : "sp-controls sp-controls--visible";
|
|
1473
1475
|
controlBar.setAttribute("role", "toolbar");
|
|
1474
1476
|
controlBar.setAttribute("aria-label", "Video controls");
|
|
1475
1477
|
for (const slot of layout) {
|
|
@@ -1492,6 +1494,11 @@ function uiPlugin(config = {}) {
|
|
|
1492
1494
|
if (!container.hasAttribute("tabindex")) {
|
|
1493
1495
|
container.setAttribute("tabindex", "0");
|
|
1494
1496
|
}
|
|
1497
|
+
controlsVisible = !isPlaying;
|
|
1498
|
+
api.setState("controlsVisible", controlsVisible);
|
|
1499
|
+
if (isPlaying) {
|
|
1500
|
+
resetHideTimer();
|
|
1501
|
+
}
|
|
1495
1502
|
api.logger.debug("UI controls plugin initialized");
|
|
1496
1503
|
},
|
|
1497
1504
|
async destroy() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scarlett-player/ui",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "UI Controls Plugin for Scarlett Player",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -22,14 +22,14 @@
|
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"@scarlett-player/core": "^0.
|
|
25
|
+
"@scarlett-player/core": "^0.2.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"tsup": "^8.0.0",
|
|
29
29
|
"typescript": "^5.3.0",
|
|
30
30
|
"vitest": "^1.6.0",
|
|
31
31
|
"jsdom": "^24.0.0",
|
|
32
|
-
"@scarlett-player/core": "0.4.
|
|
32
|
+
"@scarlett-player/core": "0.4.1"
|
|
33
33
|
},
|
|
34
34
|
"keywords": [
|
|
35
35
|
"video",
|