@hanifhan1f/vidstack-react 1.12.30 → 1.12.31
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/dev/chunks/vidstack-3rdEWplD.js +189 -0
- package/dev/chunks/vidstack-BRTBRJ_I.js +288 -0
- package/dev/chunks/vidstack-C56TjAKZ.js +61 -0
- package/dev/chunks/vidstack-C5tZAkKo.js +11694 -0
- package/dev/chunks/vidstack-CXjRKTos.js +401 -0
- package/dev/chunks/vidstack-C_xw7iZ2.js +34 -0
- package/dev/chunks/vidstack-CaaASbOf.js +476 -0
- package/dev/chunks/vidstack-D2Bi2Td9.js +1537 -0
- package/dev/chunks/vidstack-D95QIbAo.js +551 -0
- package/dev/chunks/vidstack-DnmOVAbr.js +643 -0
- package/dev/chunks/vidstack-Dnoefs4z.js +180 -0
- package/dev/chunks/vidstack-S_S6XDnL.js +375 -0
- package/dev/chunks/vidstack-oOGofWSl.js +668 -0
- package/dev/chunks/vidstack-vh0BKYWJ.js +84 -0
- package/dev/player/vidstack-default-components.js +8 -9
- package/dev/player/vidstack-default-icons.js +1 -1
- package/dev/player/vidstack-default-layout.js +8 -9
- package/dev/player/vidstack-plyr-layout.js +63 -77
- package/dev/player/vidstack-remotion.js +6 -6
- package/dev/vidstack.js +133 -22
- package/package.json +1 -1
- package/prod/chunks/vidstack-B0SSIHIv.js +1537 -0
- package/prod/chunks/vidstack-B3E9kXKq.js +34 -0
- package/prod/chunks/vidstack-BLWRqo3I.js +470 -0
- package/prod/chunks/vidstack-BXAOpsiW.js +61 -0
- package/prod/chunks/vidstack-BzPma_p3.js +288 -0
- package/prod/chunks/vidstack-C48MQkXV.js +11199 -0
- package/prod/chunks/vidstack-CKBLQMZi.js +159 -0
- package/prod/chunks/vidstack-CwlfLr4v.js +504 -0
- package/prod/chunks/vidstack-DVMwXUgY.js +189 -0
- package/prod/chunks/vidstack-D_Sd7838.js +663 -0
- package/prod/chunks/vidstack-DgsBXr1J.js +84 -0
- package/prod/chunks/vidstack-DhSvljmQ.js +375 -0
- package/prod/chunks/vidstack-DlPpeEXU.js +545 -0
- package/prod/chunks/vidstack-xwdT591E.js +386 -0
- package/prod/player/vidstack-default-components.js +8 -9
- package/prod/player/vidstack-default-icons.js +1 -1
- package/prod/player/vidstack-default-layout.js +8 -9
- package/prod/player/vidstack-plyr-layout.js +63 -77
- package/prod/player/vidstack-remotion.js +6 -6
- package/prod/vidstack.js +204 -22
- package/server/chunks/vidstack--ufi23Q6.js +1537 -0
- package/server/chunks/vidstack-3hd9uS5U.js +386 -0
- package/server/chunks/vidstack-B_l_DXPI.js +61 -0
- package/server/chunks/vidstack-Bb44UuL8.js +470 -0
- package/server/chunks/vidstack-Bu9QXEz1.js +159 -0
- package/server/chunks/vidstack-Cb_tNfNU.js +11199 -0
- package/server/chunks/vidstack-D9vUNwri.js +288 -0
- package/server/chunks/vidstack-DM-5dPT-.js +663 -0
- package/server/chunks/vidstack-DWfS9vAY.js +84 -0
- package/server/chunks/vidstack-DY51lx0R.js +189 -0
- package/server/chunks/vidstack-VGPw_CQP.js +375 -0
- package/server/chunks/vidstack-dz2TmHzm.js +34 -0
- package/server/chunks/vidstack-e0ZPAI-d.js +504 -0
- package/server/chunks/vidstack-zzooMghu.js +545 -0
- package/server/player/vidstack-default-components.js +8 -9
- package/server/player/vidstack-default-icons.js +1 -1
- package/server/player/vidstack-default-layout.js +8 -9
- package/server/player/vidstack-plyr-layout.js +63 -77
- package/server/player/vidstack-remotion.js +6 -6
- package/server/vidstack.js +204 -22
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { RadioGroupController, useMediaContext, menuContext, MediaRemoteControl, MediaPlayerInstance, sortVideoQualities } from './vidstack-C48MQkXV.js';
|
|
5
|
+
import { useMediaContext as useMediaContext$1 } from './vidstack-D_Sd7838.js';
|
|
6
|
+
import { prop, method, Component, hasProvidedContext, useContext, effect, useSignal, isString } from './vidstack-CZgUA94N.js';
|
|
7
|
+
|
|
8
|
+
const DEFAULT_PLAYBACK_RATES = [0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2];
|
|
9
|
+
class SpeedRadioGroup extends Component {
|
|
10
|
+
static props = {
|
|
11
|
+
normalLabel: "Normal",
|
|
12
|
+
rates: DEFAULT_PLAYBACK_RATES
|
|
13
|
+
};
|
|
14
|
+
#media;
|
|
15
|
+
#menu;
|
|
16
|
+
#controller;
|
|
17
|
+
get value() {
|
|
18
|
+
return this.#controller.value;
|
|
19
|
+
}
|
|
20
|
+
get disabled() {
|
|
21
|
+
const { rates } = this.$props, { canSetPlaybackRate } = this.#media.$state;
|
|
22
|
+
return !canSetPlaybackRate() || rates().length === 0;
|
|
23
|
+
}
|
|
24
|
+
constructor() {
|
|
25
|
+
super();
|
|
26
|
+
this.#controller = new RadioGroupController();
|
|
27
|
+
this.#controller.onValueChange = this.#onValueChange.bind(this);
|
|
28
|
+
}
|
|
29
|
+
onSetup() {
|
|
30
|
+
this.#media = useMediaContext();
|
|
31
|
+
if (hasProvidedContext(menuContext)) {
|
|
32
|
+
this.#menu = useContext(menuContext);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
onConnect(el) {
|
|
36
|
+
effect(this.#watchValue.bind(this));
|
|
37
|
+
effect(this.#watchHintText.bind(this));
|
|
38
|
+
effect(this.#watchControllerDisabled.bind(this));
|
|
39
|
+
}
|
|
40
|
+
getOptions() {
|
|
41
|
+
const { rates, normalLabel } = this.$props;
|
|
42
|
+
return rates().map((rate) => ({
|
|
43
|
+
label: rate === 1 ? normalLabel : rate + "\xD7",
|
|
44
|
+
value: rate.toString()
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
#watchValue() {
|
|
48
|
+
this.#controller.value = this.#getValue();
|
|
49
|
+
}
|
|
50
|
+
#watchHintText() {
|
|
51
|
+
const { normalLabel } = this.$props, { playbackRate } = this.#media.$state, rate = playbackRate();
|
|
52
|
+
this.#menu?.hint.set(rate === 1 ? normalLabel() : rate + "\xD7");
|
|
53
|
+
}
|
|
54
|
+
#watchControllerDisabled() {
|
|
55
|
+
this.#menu?.disable(this.disabled);
|
|
56
|
+
}
|
|
57
|
+
#getValue() {
|
|
58
|
+
const { playbackRate } = this.#media.$state;
|
|
59
|
+
return playbackRate().toString();
|
|
60
|
+
}
|
|
61
|
+
#onValueChange(value, trigger) {
|
|
62
|
+
if (this.disabled) return;
|
|
63
|
+
const rate = +value;
|
|
64
|
+
this.#media.remote.changePlaybackRate(rate, trigger);
|
|
65
|
+
this.dispatch("change", { detail: rate, trigger });
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const speedradiogroup__proto = SpeedRadioGroup.prototype;
|
|
69
|
+
prop(speedradiogroup__proto, "value");
|
|
70
|
+
prop(speedradiogroup__proto, "disabled");
|
|
71
|
+
method(speedradiogroup__proto, "getOptions");
|
|
72
|
+
|
|
73
|
+
function useMediaRemote(target) {
|
|
74
|
+
const media = useMediaContext$1(), remote = React.useRef(null);
|
|
75
|
+
if (!remote.current) {
|
|
76
|
+
remote.current = new MediaRemoteControl();
|
|
77
|
+
}
|
|
78
|
+
React.useEffect(() => {
|
|
79
|
+
const ref = target && "current" in target ? target.current : target, isPlayerRef = ref instanceof MediaPlayerInstance, player = isPlayerRef ? ref : media?.player;
|
|
80
|
+
remote.current.setPlayer(player ?? null);
|
|
81
|
+
remote.current.setTarget(ref ?? null);
|
|
82
|
+
}, [media, target && "current" in target ? target.current : target]);
|
|
83
|
+
return remote.current;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function useVideoQualityOptions({
|
|
87
|
+
auto = true,
|
|
88
|
+
sort = "descending"
|
|
89
|
+
} = {}) {
|
|
90
|
+
const media = useMediaContext$1(), { qualities, quality, autoQuality, canSetQuality } = media.$state, $qualities = useSignal(qualities);
|
|
91
|
+
useSignal(quality);
|
|
92
|
+
useSignal(autoQuality);
|
|
93
|
+
useSignal(canSetQuality);
|
|
94
|
+
return React.useMemo(() => {
|
|
95
|
+
const sortedQualities = sortVideoQualities($qualities, sort === "descending"), options = sortedQualities.map((q) => {
|
|
96
|
+
return {
|
|
97
|
+
quality: q,
|
|
98
|
+
label: q.height + "p",
|
|
99
|
+
value: getQualityValue(q),
|
|
100
|
+
bitrateText: q.bitrate && q.bitrate > 0 ? `${(q.bitrate / 1e6).toFixed(2)} Mbps` : null,
|
|
101
|
+
get selected() {
|
|
102
|
+
return q === quality();
|
|
103
|
+
},
|
|
104
|
+
get autoSelected() {
|
|
105
|
+
return autoQuality();
|
|
106
|
+
},
|
|
107
|
+
select(trigger) {
|
|
108
|
+
const index = qualities().indexOf(q);
|
|
109
|
+
if (index >= 0) media.remote.changeQuality(index, trigger);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
});
|
|
113
|
+
if (auto) {
|
|
114
|
+
options.unshift({
|
|
115
|
+
quality: null,
|
|
116
|
+
label: isString(auto) ? auto : "Auto",
|
|
117
|
+
value: "auto",
|
|
118
|
+
bitrateText: null,
|
|
119
|
+
get selected() {
|
|
120
|
+
return autoQuality();
|
|
121
|
+
},
|
|
122
|
+
get autoSelected() {
|
|
123
|
+
return autoQuality();
|
|
124
|
+
},
|
|
125
|
+
select(trigger) {
|
|
126
|
+
media.remote.requestAutoQuality(trigger);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
Object.defineProperty(options, "disabled", {
|
|
131
|
+
get() {
|
|
132
|
+
return !canSetQuality() || $qualities.length <= 1;
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
Object.defineProperty(options, "selectedQuality", {
|
|
136
|
+
get() {
|
|
137
|
+
return quality();
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
Object.defineProperty(options, "selectedValue", {
|
|
141
|
+
get() {
|
|
142
|
+
const $quality = quality();
|
|
143
|
+
return !autoQuality() && $quality ? getQualityValue($quality) : "auto";
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
return options;
|
|
147
|
+
}, [$qualities, sort]);
|
|
148
|
+
}
|
|
149
|
+
function getQualityValue(quality) {
|
|
150
|
+
return quality.height + "_" + quality.bitrate;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function usePlaybackRateOptions({
|
|
154
|
+
rates = DEFAULT_PLAYBACK_RATES,
|
|
155
|
+
normalLabel = "Normal"
|
|
156
|
+
} = {}) {
|
|
157
|
+
const media = useMediaContext$1(), { playbackRate, canSetPlaybackRate } = media.$state;
|
|
158
|
+
useSignal(playbackRate);
|
|
159
|
+
useSignal(canSetPlaybackRate);
|
|
160
|
+
return React.useMemo(() => {
|
|
161
|
+
const options = rates.map((opt) => {
|
|
162
|
+
const label = typeof opt === "number" ? opt === 1 && normalLabel ? normalLabel : opt + "x" : opt.label, rate = typeof opt === "number" ? opt : opt.rate;
|
|
163
|
+
return {
|
|
164
|
+
label,
|
|
165
|
+
value: rate.toString(),
|
|
166
|
+
rate,
|
|
167
|
+
get selected() {
|
|
168
|
+
return playbackRate() === rate;
|
|
169
|
+
},
|
|
170
|
+
select(trigger) {
|
|
171
|
+
media.remote.changePlaybackRate(rate, trigger);
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
});
|
|
175
|
+
Object.defineProperty(options, "disabled", {
|
|
176
|
+
get() {
|
|
177
|
+
return !canSetPlaybackRate() || !options.length;
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
Object.defineProperty(options, "selectedValue", {
|
|
181
|
+
get() {
|
|
182
|
+
return playbackRate().toString();
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
return options;
|
|
186
|
+
}, [rates]);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export { DEFAULT_PLAYBACK_RATES, useMediaRemote, usePlaybackRateOptions, useVideoQualityOptions };
|