UNPKG

@mescius/dspdfviewer

Version:
210 lines (209 loc) 7.71 kB
import { RichMediaAnnotation } from "../Annotations/RichMediaAnnotation"; export declare function exitPictureInPictureMode(videoElement: HTMLVideoElement): Promise<void>; /** * Enters the Picture-in-Picture mode for the specified video element. * @param {HTMLVideoElement} videoElement - The video element to enter Picture-in-Picture mode for. * @returns {boolean} - Returns true if successful, false otherwise. */ export declare function requestPictureInPictureMode(videoElement: HTMLVideoElement): Promise<boolean>; /** * Class representing a player for rich media annotations. * This class provides functionality for initializing and controlling * the playback of rich media content within the context of PDF annotations. * * Example: * ```typescript * const playerContainer = document.getElementById('player-container'); * const player = new RichMediaAnnotationPlayer(playerContainer, richMediaAnnotation); * player.play(); * ``` */ export declare class RichMediaAnnotationPlayer { container: HTMLElement; richMediaAnnotation: RichMediaAnnotation; viewer: any; /** * Flag indicating whether the player has been initialized. * @private */ private _initialized; /** * Reference to the HTML5 media element (audio or video) used by the player. * @private */ private _html5MediaElement; private _unregisterViewerStateChange?; private _intersectionObserver?; private _audioOscilloscopeVisualizer?; private _streamVideoElement?; /** * Initiates the playback of rich media content within the specified HTML container. * * @param container - The HTML element that will host the rich media player. * @param richMediaAnnotation - The rich media annotation associated with the player. * @returns A reference to the initialized player instance. * * Example: * ```typescript * const playerContainer = document.getElementById('player-container'); * const player = new RichMediaAnnotationPlayer(playerContainer, richMediaAnnotation); * player.play(); * ``` */ constructor(container: HTMLElement, richMediaAnnotation: RichMediaAnnotation, viewer: any); /** * Retrieves the activation condition for rich media content. * Possible values: "XA" (Explicit activation), "PO" (Page Open), or "PV" (Page Visible). * Defaults to "XA" if the condition is not explicitly specified. */ get activationCondition(): "XA" | "PO" | "PV"; /** * Retrieves the deactivation condition for rich media content. * Possible values: "XD" (Explicit deactivation), "PC" (Page Close), or "PI" (Page Invisible). * Defaults to "XD" if the condition is not explicitly specified. */ get deactivationCondition(): "XD" | "PC" | "PI"; /** * Retrieves the index of the page to which the annotation is associated. * * @returns {number} The index of the page associated with the annotation. * */ get annotationPageIndex(): number; /** * Retrieves the file specification, including media content as a Uint8Array and filename. */ get fileSpec(): { content: Uint8Array; filename: string; }; /** * Gets whether the media content is Flash-based. */ get isFlash(): boolean; /** * Gets a boolean value indicating whether the rich media content is in the MP3 format. * * @returns `true` if the media content is in MP3 format, otherwise `false`. * * Example: * ```typescript * const player = new RichMediaAnnotationPlayer(container, richMediaAnnotation); * if (player.isMp3) { * console.log('Media content is in MP3 format.'); * } else { * console.log('Media content is not in MP3 format.'); * } * ``` */ get isMp3(): boolean; get isAudio(): boolean; get mimeType(): string; /** * Gets whether the media is windowed (non-embedded). */ get isWindowed(): boolean; /** * Gets the lowercased filename for case-insensitive comparisons. */ get lowerFileName(): string; /** * Gets a boolean value indicating whether the media element is currently paused. * * @returns `true` if the media element is paused, otherwise `false`. * * Example: * ```typescript * const player = new RichMediaAnnotationPlayer(container, richMediaAnnotation); * if (player.paused) { * console.log('Media playback is paused.'); * } else { * console.log('Media is currently playing.'); * } * ``` */ get paused(): boolean; /** * Toggles playback, stopping if playing and playing if stopped. */ togglePlayback(): void; /** * Plays the rich media content. */ play(): void; protected get richMediaAnnotationElement(): HTMLElement | undefined; protected onPlaybackStarted(): void; protected onPlaybackStopped(): void; get isPlaybackActivated(): boolean; /** * Stops playback and clears the player container. */ stop(): void; /** * Pauses playback by stopping and clearing the player container. */ pause(): void; private onViewerStateChange; get in17n(): any; onContentClick(): void; /** * Initializes the player, setting up intersection observer if applicable. * @private */ private initializeInternal; showClickToActivateTooltip(): void; hideClickToActivateTooltip(): void; /** * Pauses the HTML5 media element, if it exists. */ private pauseHtml5Media; /** * Stops the HTML5 media element, if it exists. */ private stopHtml5Media; private _ensureHtml5MediaElement; onEnterPictureInPicture(): void; onLeavePictureInPicture(): void; /** * Plays HTML5 media content (MP4/MP3 and others) within the specified container. * @param container - The HTML element that will host the media player. * @param fileSpec - The file specification containing media content and filename. * @param lowerFileName - The lowercased filename for case-insensitive comparisons. * @param isWindowed - Indicates whether the media is windowed (non-embedded). * @private */ private playHtml5Media; private tryExitPipMode; private removeCustomPiP; private createCustomPiP; private tryEnterPipMode; private static stopSwf; /** * Plays Flash-based media content within the specified container. * @param container - The HTML element that will host the Flash player. * @param fileSpec - The file specification containing Flash content. * @private */ private static playSwf; /** * Internal method to play Flash-based media content. * @param swfContainer - The HTML element that will host the Flash player. * @param swfContent - The Flash content as a Uint8Array. * @private */ private static playSwfInternal; private get isEditAnnotationsMode(); /** * Checks if the annotation has been disposed based on its container's visibility and context. * Disposes resources and returns true if disposed, otherwise returns false. */ private disposeIfNecessary; /** * Disposes the viewer state change event handler. */ private disposeViewerStateChange; /** * Disposes the Intersection Observer used for visibility checks. */ private disposeIntersectionObserver; }