/** * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the Microsoft Live Share SDK License. */ import { ILiveEvent } from "@microsoft/live-share"; import { IRuntimeSignaler } from "@microsoft/live-share/internal"; import { ExtendedMediaMetadata, CoordinationWaitPoint, ExtendedMediaSessionActionDetails } from "./MediaSessionExtensions.js"; import { VolumeManager } from "./VolumeManager.js"; import { LiveMediaSession } from "./LiveMediaSession.js"; import { IMediaPlayer } from "./IMediaPlayer.js"; import { TypedEventEmitter } from "@fluid-internal/client-utils"; import { IEvent } from "@fluidframework/core-interfaces"; /** * Event data returned by `MediaPlayerSynchronizer` object. */ export interface IMediaPlayerSynchronizerEvent extends ILiveEvent { /** * Event details. */ details: ExtendedMediaSessionActionDetails; /** * Action errors, including DOMException errors thrown by HTMLMediaElement */ error?: Error; } /** * Events supported by `MediaPlayerSynchronizer` object. */ export declare enum MediaPlayerSynchronizerEvents { /** * */ coordinatorstatechange = "coordinatorstatechange", groupaction = "groupaction", useraction = "useraction" } /** * @hidden * Emitted events from the `MediaPlayerSynchronizer` class. */ export interface IMediaPlayerSynchronizerEvents extends IEvent { /** * Event listener for events emitted * @param event update * @param listener listener function * @param listener.event the event instance */ (event: string, listener: (event: any) => void): void; } /** * Synchronizes a local HTML Media Element with a group of remote HTML Media Elements. * * @remarks * All of an apps transport control commands should be routed through the synchronizer. If the * app is not currently joined to the group media session, the commands will be applied directly * to the local player. When the group session is joined the commands will be broadcast to the * group in addition to being applied to the local player. */ export declare class MediaPlayerSynchronizer extends TypedEventEmitter { private static SESSION_ACTIONS; private static PLAYER_EVENTS; private _logger; private _player; private _mediaSession; private _runtime; private _volumeManager; private _onEnd?; private _onPlayerEvent; private _seekSuspension?; private _viewOnly; private _blockUnexpectedPlayerEvents; private _expectedPlaybackState; private _expectedPlaybackRate; private _metadata; private _trackData; /** * Creates a new `MediaElementSynchronizer` instance. * @param player Media player element. This can be an HTML Media Element or any player that looks like an HTML Media Element. * @param mediaSession Group MediaSession object being used. * @param onEnd Optional. Function to call when synchronizers `end()` method is called. */ constructor(player: IMediaPlayer, mediaSession: LiveMediaSession, runtime: IRuntimeSignaler, onEnd: () => void); /** * Media player being synchronized. */ get player(): IMediaPlayer; /** * Synchronizers media session. */ get mediaSession(): LiveMediaSession; /** * If true the client is in a view only mode. * * @remarks * Toggling this value to true results in `mediaSession.coordinator.canPlayPause`, * `mediaSession.coordinator.canSeek`, `mediaSession.coordinator.canSetTrack`, * `mediaSession.coordinator.canSetTrackData`, and `mediaSession.coordinator.canSetPlaybackRate` * all being set to false. For more fine grained control over the local clients policies, * call the `mediaSession.coordinator` directly. */ get viewOnly(): boolean; set viewOnly(value: boolean); /** * @beta * If true, pause and play actions will be ignored unless explicitly invoked from the corresponding play() and pause() functions. * * @remarks * True is considered non-beta. If you set to false, this is an experimental beta behavior. * Setting it to false may cause unintended side effects, such as local buffer events sending a pause event to remote clients. * While setting this to false may prevent the need to add custom media controls for frameworks like video.js, we encourage you to be mindful of this and test thoroughly before using this setting. */ get blockUnexpectedPlayerEvents(): boolean; set blockUnexpectedPlayerEvents(value: boolean); /** * Volume limiter used to temporarily reduce the videos volume when someone speaks in a meeting. */ get volumeManager(): VolumeManager; /** * Registers a new event listener. * @param event Name of the event to add. * @param listener Function to call when the event is triggered. */ addEventListener(event: MediaPlayerSynchronizerEvents, listener: (evt: IMediaPlayerSynchronizerEvent) => void): this; /** * Un-registers an existing event listener. * @param event Name of the event to remove. * @param listener Function that was registered in call to `addEventListener()`. */ removeEventListener(event: MediaPlayerSynchronizerEvents, listener: (evt: IMediaPlayerSynchronizerEvent) => void): this; /** * Ends synchronization of the current media player. */ end(): void; /** * Begin a local seek operation. * * @remarks * UI can call this when a user grabs a timeline scrubber and starts scrubbing the video to a * new playback position. The synchronizer will being a new suspension which temporarily * disconnects the client for the rest of the group for synchronization purposes. Calling * `endSeek()` will end the suspension and seek the group to the users final seek position. */ beginSeek(): void; /** * Ends a seek operation that was started by calling `beginSeek()`. * @param seekTo Playback position in seconds to seek the group to. */ endSeek(seekTo: number): void; /** * Tells the group to begin playing the current video. * * @remarks * For proper operation apps should avoid calling `mediaSession.coordinator.play()` directly * and instead use the synchronizers `play()` method. * * @returns a void promise that resolves once complete, throws if user does not have proper roles */ play(): Promise; /** * Tells the group to pause the current video. * * @remarks * For proper operation apps should avoid calling `mediaSession.coordinator.pause()` directly * and instead use the synchronizers `pause()` method. * * @returns a void promise that resolves once complete, throws if user does not have proper roles */ pause(): Promise; /** * Tells the group to seek the current video to a new playback position. * * @remarks * For proper operation apps should avoid calling `mediaSession.coordinator.seekTo()` directly * and instead use the synchronizers `seekTo()` method. * * @returns a void promise that resolves once complete, throws if user does not have proper roles */ seekTo(time: number): Promise; setPlaybackRate(playbackRate: number): Promise; /** * Tells the group to change to a new track. * * @remarks * For proper operation apps should avoid calling `mediaSession.coordinator.setTrack()` directly * and instead use the synchronizers `setTrack()` method. * * @returns a void promise that resolves once complete, throws if user does not have proper roles */ setTrack(track: ExtendedMediaMetadata, waitPoints?: CoordinationWaitPoint[]): Promise; /** * Updates the current tracks data object. * * @remarks * For proper operation apps should avoid calling `mediaSession.coordinator.setTrackData()` directly * and instead use the synchronizers `setTrackData()` method. * * @returns a void promise that resolves once complete, throws if user does not have proper roles */ setTrackData(data: object | null): Promise; private dispatchGroupAction; private dispatchUserAction; private catchupPlayer; } //# sourceMappingURL=MediaPlayerSynchronizer.d.ts.map