Skip to content

Commit

Permalink
fix(player): vimeo should fire seeking
Browse files Browse the repository at this point in the history
  • Loading branch information
mihar-22 committed Dec 20, 2023
1 parent 5f11163 commit 298be0c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
1 change: 1 addition & 0 deletions packages/vidstack/src/providers/vimeo/embed/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export interface VimeoEventPayload {
loaded: { id: number };
ended: void;
seeking: void;
seek: void;
seeked: void;
cuechange: void;
fullscreenchange: { fullscreen: boolean };
Expand Down
18 changes: 7 additions & 11 deletions packages/vidstack/src/providers/vimeo/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ export class VimeoProvider

async play() {
const { paused } = this._ctx.$state;
if (!peek(paused)) return;

if (!this._playPromise) {
this._playPromise = timedPromise<void, string>(() => {
Expand All @@ -166,7 +165,6 @@ export class VimeoProvider

async pause() {
const { paused } = this._ctx.$state;
if (peek(paused)) return;

if (!this._pausePromise) {
this._pausePromise = timedPromise<void, string>(() => {
Expand All @@ -186,6 +184,7 @@ export class VimeoProvider

setCurrentTime(time) {
this._remote('seekTo', time);
this._notify('seeking', time);
}

setVolume(volume) {
Expand Down Expand Up @@ -327,16 +326,11 @@ export class VimeoProvider
}

protected _onTimeUpdate(time: number, trigger: Event) {
const { currentTime, paused, seeking, bufferedEnd } = this._ctx.$state;
const { realCurrentTime, paused, bufferedEnd } = this._ctx.$state;

if (seeking() && paused()) {
this._remote('getBuffered');
if (bufferedEnd() > time) this._notify('seeked', time, trigger);
}

if (currentTime() === time) return;
if (realCurrentTime() === time) return;

const prevTime = currentTime(),
const prevTime = realCurrentTime(),
detail = {
currentTime: time,
played:
Expand Down Expand Up @@ -373,7 +367,6 @@ export class VimeoProvider
{ controls } = this._ctx.$state,
showControls = controls() || $iosControls();

this._timeRAF._start();
this._pro.set(pro);
this._seekableRange = new TimeRange(0, duration);
this._notify('poster-change', poster, trigger);
Expand Down Expand Up @@ -446,12 +439,14 @@ export class VimeoProvider
}

protected _onPause(trigger: Event) {
this._timeRAF._stop();
this._notify('pause', undefined, trigger);
this._pausePromise?.resolve();
this._pausePromise = null;
}

protected _onPlay(trigger: Event) {
this._timeRAF._start();
this._notify('play', undefined, trigger);
this._playPromise?.resolve();
this._playPromise = null;
Expand Down Expand Up @@ -633,6 +628,7 @@ export class VimeoProvider
case 'error':
this._onError(payload, trigger);
break;
case 'seek':
case 'seeked':
this._onSeeked(payload.seconds, trigger);
break;
Expand Down

0 comments on commit 298be0c

Please sign in to comment.