fix(refboard): force seek to decode poster frame with preload='metadata'
preload='metadata' doesn't decode video frames, so readyState stays at 1 (HAVE_METADATA) and loadeddata never fires. capturePoster() now detects this state and forces a seek to 0.1s via _trySeekCapture(), which triggers frame decode and captures on the 'seeked' event.
This commit is contained in:
@@ -117,10 +117,15 @@ export class VideoSprite extends Container {
|
|||||||
capturePoster(): void {
|
capturePoster(): void {
|
||||||
if (this._hasPoster || !this.videoEl || this.destroyed) return;
|
if (this._hasPoster || !this.videoEl || this.destroyed) return;
|
||||||
|
|
||||||
// Need loadeddata to capture a frame — listen if not yet ready
|
|
||||||
if (this.videoEl.readyState >= 2) {
|
if (this.videoEl.readyState >= 2) {
|
||||||
|
// Frame data already available — capture directly
|
||||||
this._captureFirstFrame();
|
this._captureFirstFrame();
|
||||||
|
} else if (this.videoEl.readyState >= 1) {
|
||||||
|
// Metadata loaded but no frame decoded (preload='metadata').
|
||||||
|
// Force a seek to trigger frame decode, capture on 'seeked'.
|
||||||
|
this._trySeekCapture();
|
||||||
} else {
|
} else {
|
||||||
|
// Not even metadata yet — wait for loadeddata
|
||||||
this.videoEl.addEventListener('loadeddata', this._onLoadedData, { once: true });
|
this.videoEl.addEventListener('loadeddata', this._onLoadedData, { once: true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user