@octane-xplat/video 0.0.0 → 0.7.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.
@@ -0,0 +1,359 @@
1
+ import { defineUniversalComponent, hookSlots, universalChildren, universalComponent, universalIf, universalPlan, universalProps, universalValue, useEffect, useState } from "@nativescript-community/octane";
2
+ import { Icon, Image, Pressable, Row, Slider, Text, View } from "@octane-xplat/ui";
3
+ //#region src/video-chrome.tsrx
4
+ var _hs$ = /* @__PURE__ */ hookSlots(2);
5
+ var _h$0 = /* @__PURE__ */ Symbol(_hs$);
6
+ var _h$1 = /* @__PURE__ */ Symbol(_hs$ + 1);
7
+ var __octaneUniversalPlan0 = universalPlan("nativescript", {
8
+ "kind": "slot",
9
+ "slot": 0
10
+ });
11
+ var __octaneUniversalPlan1 = universalPlan("nativescript", {
12
+ "kind": "slot",
13
+ "slot": 0
14
+ });
15
+ var __octaneUniversalPlan2 = universalPlan("nativescript", {
16
+ "kind": "slot",
17
+ "slot": 0
18
+ });
19
+ var __octaneUniversalPlan3 = universalPlan("nativescript", {
20
+ "kind": "slot",
21
+ "slot": 0
22
+ });
23
+ var __octaneUniversalPlan4 = universalPlan("nativescript", {
24
+ "kind": "slot",
25
+ "slot": 0
26
+ });
27
+ var __octaneUniversalPlan5 = universalPlan("nativescript", {
28
+ "kind": "slot",
29
+ "slot": 0
30
+ });
31
+ var __octaneUniversalPlan6 = universalPlan("nativescript", {
32
+ "kind": "range",
33
+ "children": [
34
+ {
35
+ "kind": "slot",
36
+ "slot": 0
37
+ },
38
+ {
39
+ "kind": "slot",
40
+ "slot": 1
41
+ },
42
+ {
43
+ "kind": "slot",
44
+ "slot": 2
45
+ },
46
+ {
47
+ "kind": "slot",
48
+ "slot": 3
49
+ },
50
+ {
51
+ "kind": "slot",
52
+ "slot": 4
53
+ }
54
+ ]
55
+ });
56
+ var __octaneUniversalPlan7 = universalPlan("nativescript", {
57
+ "kind": "slot",
58
+ "slot": 0
59
+ });
60
+ var __octaneUniversalPlan8 = universalPlan("nativescript", {
61
+ "kind": "range",
62
+ "children": [{
63
+ "kind": "slot",
64
+ "slot": 0
65
+ }, {
66
+ "kind": "slot",
67
+ "slot": 1
68
+ }]
69
+ });
70
+ var __octaneUniversalPlan9 = universalPlan("nativescript", {
71
+ "kind": "range",
72
+ "children": [
73
+ {
74
+ "kind": "slot",
75
+ "slot": 0
76
+ },
77
+ {
78
+ "kind": "slot",
79
+ "slot": 1
80
+ },
81
+ {
82
+ "kind": "slot",
83
+ "slot": 2
84
+ }
85
+ ]
86
+ });
87
+ function stamp(ms) {
88
+ const total = Math.max(0, Math.floor(ms / 1e3));
89
+ return `${Math.floor(total / 60)}:${String(total % 60).padStart(2, "0")}`;
90
+ }
91
+ var VideoChrome = defineUniversalComponent("nativescript", function VideoChrome(props) {
92
+ const [visible, setVisible] = useState(true, _h$0);
93
+ useEffect(() => {
94
+ if (!props.playing || !visible) return;
95
+ const t = setTimeout(() => setVisible(false), 2500);
96
+ return () => clearTimeout(t);
97
+ }, [props.playing, visible], _h$1);
98
+ return universalValue(__octaneUniversalPlan9, [
99
+ universalIf(props.poster && !props.started, () => {
100
+ return universalValue(__octaneUniversalPlan0, [universalComponent("nativescript", Image, universalProps([
101
+ [
102
+ "set",
103
+ "className",
104
+ "vx-video-poster"
105
+ ],
106
+ [
107
+ "set",
108
+ "src",
109
+ props.poster
110
+ ],
111
+ [
112
+ "set",
113
+ "ios",
114
+ { stretch: "aspectFill" }
115
+ ],
116
+ [
117
+ "set",
118
+ "android",
119
+ { stretch: "aspectFill" }
120
+ ]
121
+ ]))]);
122
+ }),
123
+ universalComponent("nativescript", Pressable, universalProps([
124
+ [
125
+ "set",
126
+ "className",
127
+ "vx-video-tap"
128
+ ],
129
+ [
130
+ "set",
131
+ "accessibilityRole",
132
+ "button"
133
+ ],
134
+ [
135
+ "set",
136
+ "accessibilityLabel",
137
+ visible ? "Hide video controls" : "Show video controls"
138
+ ],
139
+ [
140
+ "set",
141
+ "onPress",
142
+ () => setVisible(props.playing ? !visible : true)
143
+ ]
144
+ ])),
145
+ universalIf(visible, () => {
146
+ return universalValue(__octaneUniversalPlan8, [universalIf(!props.playing, () => {
147
+ return universalValue(__octaneUniversalPlan3, [universalComponent("nativescript", Pressable, universalProps([
148
+ [
149
+ "set",
150
+ "className",
151
+ "vx-video-center"
152
+ ],
153
+ [
154
+ "set",
155
+ "justifyContent",
156
+ "center"
157
+ ],
158
+ [
159
+ "set",
160
+ "alignItems",
161
+ "center"
162
+ ],
163
+ [
164
+ "set",
165
+ "accessibilityRole",
166
+ "button"
167
+ ],
168
+ [
169
+ "set",
170
+ "accessibilityLabel",
171
+ "Play"
172
+ ],
173
+ [
174
+ "set",
175
+ "onPress",
176
+ props.onTogglePlay
177
+ ]
178
+ ], universalChildren("nativescript", () => {
179
+ return universalValue(__octaneUniversalPlan2, [universalComponent("nativescript", View, universalProps([[
180
+ "set",
181
+ "className",
182
+ "vx-video-centerbtn"
183
+ ]], universalChildren("nativescript", () => {
184
+ return universalValue(__octaneUniversalPlan1, [universalComponent("nativescript", Icon, universalProps([
185
+ [
186
+ "set",
187
+ "name",
188
+ "xplat-play"
189
+ ],
190
+ [
191
+ "set",
192
+ "size",
193
+ 28
194
+ ],
195
+ [
196
+ "set",
197
+ "color",
198
+ "#fff"
199
+ ]
200
+ ]))]);
201
+ })))]);
202
+ })))]);
203
+ }), universalComponent("nativescript", View, universalProps([[
204
+ "set",
205
+ "className",
206
+ "vx-video-barwrap"
207
+ ], [
208
+ "set",
209
+ "justifyContent",
210
+ "end"
211
+ ]], universalChildren("nativescript", () => {
212
+ return universalValue(__octaneUniversalPlan7, [universalComponent("nativescript", Row, universalProps([
213
+ [
214
+ "set",
215
+ "className",
216
+ "vx-video-bar"
217
+ ],
218
+ [
219
+ "set",
220
+ "alignItems",
221
+ "center"
222
+ ],
223
+ [
224
+ "set",
225
+ "gap",
226
+ 8
227
+ ]
228
+ ], universalChildren("nativescript", () => {
229
+ return universalValue(__octaneUniversalPlan6, [
230
+ universalComponent("nativescript", Pressable, universalProps([
231
+ [
232
+ "set",
233
+ "className",
234
+ "vx-video-btn"
235
+ ],
236
+ [
237
+ "set",
238
+ "accessibilityRole",
239
+ "button"
240
+ ],
241
+ [
242
+ "set",
243
+ "accessibilityLabel",
244
+ props.playing ? "Pause" : "Play"
245
+ ],
246
+ [
247
+ "set",
248
+ "onPress",
249
+ props.onTogglePlay
250
+ ]
251
+ ], universalChildren("nativescript", () => {
252
+ return universalValue(__octaneUniversalPlan4, [universalComponent("nativescript", Icon, universalProps([
253
+ [
254
+ "set",
255
+ "name",
256
+ props.playing ? "xplat-pause" : "xplat-play"
257
+ ],
258
+ [
259
+ "set",
260
+ "size",
261
+ 20
262
+ ],
263
+ [
264
+ "set",
265
+ "color",
266
+ "#fff"
267
+ ]
268
+ ]))]);
269
+ }))),
270
+ universalComponent("nativescript", Text, universalProps([[
271
+ "set",
272
+ "className",
273
+ "vx-video-time"
274
+ ]], stamp(props.position))),
275
+ universalComponent("nativescript", Slider, universalProps([
276
+ [
277
+ "set",
278
+ "className",
279
+ "vx-video-slider"
280
+ ],
281
+ [
282
+ "set",
283
+ "style",
284
+ { flexGrow: 1 }
285
+ ],
286
+ [
287
+ "set",
288
+ "value",
289
+ props.position
290
+ ],
291
+ [
292
+ "set",
293
+ "minValue",
294
+ 0
295
+ ],
296
+ [
297
+ "set",
298
+ "maxValue",
299
+ props.duration > 0 ? props.duration : 1
300
+ ],
301
+ [
302
+ "set",
303
+ "onValueChange",
304
+ props.onSeek
305
+ ]
306
+ ])),
307
+ universalComponent("nativescript", Text, universalProps([[
308
+ "set",
309
+ "className",
310
+ "vx-video-time"
311
+ ]], stamp(props.duration))),
312
+ universalComponent("nativescript", Pressable, universalProps([
313
+ [
314
+ "set",
315
+ "className",
316
+ "vx-video-btn"
317
+ ],
318
+ [
319
+ "set",
320
+ "accessibilityRole",
321
+ "button"
322
+ ],
323
+ [
324
+ "set",
325
+ "accessibilityLabel",
326
+ props.muted ? "Unmute" : "Mute"
327
+ ],
328
+ [
329
+ "set",
330
+ "onPress",
331
+ props.onToggleMute
332
+ ]
333
+ ], universalChildren("nativescript", () => {
334
+ return universalValue(__octaneUniversalPlan5, [universalComponent("nativescript", Icon, universalProps([
335
+ [
336
+ "set",
337
+ "name",
338
+ props.muted ? "xplat-volume-off" : "xplat-volume"
339
+ ],
340
+ [
341
+ "set",
342
+ "size",
343
+ 20
344
+ ],
345
+ [
346
+ "set",
347
+ "color",
348
+ "#fff"
349
+ ]
350
+ ]))]);
351
+ })))
352
+ ]);
353
+ })))]);
354
+ })))]);
355
+ })
356
+ ]);
357
+ }, { "module": "@nativescript-community/octane" });
358
+ //#endregion
359
+ export { VideoChrome };