@remotion/player
Advanced tools
Comparing version 2.1.7 to 2.1.8
@@ -1,2 +0,1 @@ | ||
import './event-target-polyfill'; | ||
declare type SeekPayload = { | ||
@@ -8,14 +7,21 @@ frame: number; | ||
}; | ||
interface StateEventMap { | ||
seeked: CustomEvent<SeekPayload>; | ||
pause: CustomEvent<undefined>; | ||
play: CustomEvent<undefined>; | ||
ended: CustomEvent<undefined>; | ||
error: CustomEvent<ErrorPayload>; | ||
} | ||
export interface PlayerEventTarget extends EventTarget { | ||
addEventListener<K extends keyof StateEventMap>(type: K, listener: (ev: StateEventMap[K]) => void, options?: boolean | AddEventListenerOptions): void; | ||
addEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: EventListenerOptions | boolean): void; | ||
} | ||
export declare class PlayerEmitter extends EventTarget { | ||
declare type StateEventMap = { | ||
seeked: SeekPayload; | ||
pause: undefined; | ||
play: undefined; | ||
ended: undefined; | ||
error: ErrorPayload; | ||
}; | ||
declare type EventTypes = keyof StateEventMap; | ||
declare type CallbackListener<T extends EventTypes> = (data: { | ||
detail: StateEventMap[T]; | ||
}) => void; | ||
declare type Listeners = { | ||
[EventType in EventTypes]: CallbackListener<EventType>[]; | ||
}; | ||
export declare class PlayerEmitter { | ||
listeners: Listeners; | ||
addEventListener<Q extends EventTypes>(name: Q, callback: CallbackListener<Q>): void; | ||
removeEventListener<Q extends EventTypes>(name: Q, callback: CallbackListener<Q>): void; | ||
private dispatchEvent; | ||
dispatchSeek(frame: number): void; | ||
@@ -22,0 +28,0 @@ dispatchPause(): void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.PlayerEmitter = void 0; | ||
require("./event-target-polyfill"); | ||
class PlayerEmitter extends EventTarget { | ||
class PlayerEmitter { | ||
constructor() { | ||
this.listeners = { | ||
ended: [], | ||
error: [], | ||
pause: [], | ||
play: [], | ||
seeked: [], | ||
}; | ||
} | ||
addEventListener(name, callback) { | ||
this.listeners[name].push(callback); | ||
} | ||
removeEventListener(name, callback) { | ||
this.listeners[name] = this.listeners[name].filter((l) => l !== callback); | ||
} | ||
dispatchEvent(dispatchName, context) { | ||
this.listeners[dispatchName].forEach((callback) => { | ||
callback({ detail: context }); | ||
}); | ||
} | ||
dispatchSeek(frame) { | ||
this.dispatchEvent(new CustomEvent('seeked', { | ||
detail: { | ||
frame, | ||
}, | ||
})); | ||
this.dispatchEvent('seeked', { | ||
frame, | ||
}); | ||
} | ||
dispatchPause() { | ||
this.dispatchEvent(new CustomEvent('pause')); | ||
this.dispatchEvent('pause', undefined); | ||
} | ||
dispatchPlay() { | ||
this.dispatchEvent(new CustomEvent('play')); | ||
this.dispatchEvent('play', undefined); | ||
} | ||
dispatchEnded() { | ||
this.dispatchEvent(new CustomEvent('ended')); | ||
this.dispatchEvent('ended', undefined); | ||
} | ||
dispatchError(error) { | ||
this.dispatchEvent(new CustomEvent('error', { | ||
detail: { | ||
error, | ||
}, | ||
})); | ||
this.dispatchEvent('error', { | ||
error, | ||
}); | ||
} | ||
@@ -29,0 +44,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { PlayerEventTarget } from './event-emitter'; | ||
import { PlayerEmitter } from './event-emitter'; | ||
export declare type PlayerMethods = { | ||
@@ -17,3 +17,3 @@ play: () => void; | ||
}; | ||
export declare type PlayerRef = PlayerEventTarget & PlayerMethods; | ||
export declare type PlayerRef = PlayerEmitter & PlayerMethods; | ||
//# sourceMappingURL=player-methods.d.ts.map |
@@ -52,5 +52,5 @@ "use strict"; | ||
}; | ||
}, [config, loop, pause, playing, setFrame]); | ||
}, [config, loop, pause, playing, setFrame, emitter]); | ||
}; | ||
exports.usePlayback = usePlayback; | ||
//# sourceMappingURL=use-playback.js.map |
{ | ||
"name": "@remotion/player", | ||
"version": "2.1.7", | ||
"version": "2.1.8", | ||
"description": "Remotion Player", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
141219
130
1818