@bycrux/editor 0.6.1 → 0.6.2
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/package.json
CHANGED
|
@@ -185,6 +185,29 @@ export function useVideoPlayback(
|
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
+
/**
|
|
189
|
+
* Start playback on a wired <video> from a user gesture. Video frame
|
|
190
|
+
* production is gated on the shared AudioContext clock running, and the
|
|
191
|
+
* context is created suspended inside a useEffect — so the FIRST play after a
|
|
192
|
+
* hard refresh fires while resume() is still pending and renders no frames
|
|
193
|
+
* until the next seek. resume() is gesture-credited at the synchronous call
|
|
194
|
+
* site here, so wait for it to actually resolve to 'running' before calling
|
|
195
|
+
* play(); the page already has sticky activation from the click, so the
|
|
196
|
+
* deferred play() is not autoplay-blocked.
|
|
197
|
+
*/
|
|
198
|
+
function playFromGesture(video: HTMLVideoElement) {
|
|
199
|
+
const w = window as Window & MontajWindow
|
|
200
|
+
const ctx = w.__montajSharedCtx
|
|
201
|
+
if (ctx && ctx.state === 'suspended') {
|
|
202
|
+
ctx.resume().then(
|
|
203
|
+
() => { void video.play().catch(() => {}) },
|
|
204
|
+
() => { void video.play().catch(() => {}) },
|
|
205
|
+
)
|
|
206
|
+
} else {
|
|
207
|
+
void video.play().catch(() => {})
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
188
211
|
function ensureVideoGain(slot: 0 | 1): GainNode | null {
|
|
189
212
|
if (videoGainRef.current[slot]) return videoGainRef.current[slot]
|
|
190
213
|
const video = slot === 0 ? video0Ref.current : video1Ref.current
|
|
@@ -447,7 +470,7 @@ export function useVideoPlayback(
|
|
|
447
470
|
}
|
|
448
471
|
const video = getActiveVideo()
|
|
449
472
|
if (!video) return
|
|
450
|
-
if (video.paused) { video
|
|
473
|
+
if (video.paused) { playFromGesture(video) } else { video.pause() }
|
|
451
474
|
}
|
|
452
475
|
}
|
|
453
476
|
document.addEventListener('keydown', onKeyDown)
|
|
@@ -815,7 +838,7 @@ export function useVideoPlayback(
|
|
|
815
838
|
}
|
|
816
839
|
const video = getActiveVideo()
|
|
817
840
|
if (!video) return
|
|
818
|
-
if (video.paused) { video
|
|
841
|
+
if (video.paused) { playFromGesture(video) } else { video.pause() }
|
|
819
842
|
}
|
|
820
843
|
|
|
821
844
|
return {
|