From ed99f72403ef6aacba6ffe81ab14f65ee74a91ee Mon Sep 17 00:00:00 2001 From: Craig Bruce Date: Fri, 23 Mar 2018 14:15:59 +1100 Subject: [PATCH 1/5] Initial commit of cast types --- .../cast.framework.breaks.d.ts | 110 + .../cast.framework.d.ts | 773 +++++++ .../cast.framework.events.d.ts | 421 ++++ .../cast.framework.messages.d.ts | 1777 +++++++++++++++++ .../cast.framework.system.d.ts | 177 ++ .../cast.framework.ui.d.ts | 194 ++ .../chromecast-caf-receiver-tests.ts | 66 + types/chromecast-caf-receiver/index.d.ts | 25 + types/chromecast-caf-receiver/tsconfig.json | 22 + types/chromecast-caf-receiver/tslint.json | 1 + 10 files changed, 3566 insertions(+) create mode 100644 types/chromecast-caf-receiver/cast.framework.breaks.d.ts create mode 100644 types/chromecast-caf-receiver/cast.framework.d.ts create mode 100644 types/chromecast-caf-receiver/cast.framework.events.d.ts create mode 100644 types/chromecast-caf-receiver/cast.framework.messages.d.ts create mode 100644 types/chromecast-caf-receiver/cast.framework.system.d.ts create mode 100644 types/chromecast-caf-receiver/cast.framework.ui.d.ts create mode 100644 types/chromecast-caf-receiver/chromecast-caf-receiver-tests.ts create mode 100644 types/chromecast-caf-receiver/index.d.ts create mode 100644 types/chromecast-caf-receiver/tsconfig.json create mode 100644 types/chromecast-caf-receiver/tslint.json diff --git a/types/chromecast-caf-receiver/cast.framework.breaks.d.ts b/types/chromecast-caf-receiver/cast.framework.breaks.d.ts new file mode 100644 index 0000000000..4fed094a12 --- /dev/null +++ b/types/chromecast-caf-receiver/cast.framework.breaks.d.ts @@ -0,0 +1,110 @@ +// Type definitions for chromecast-caf-receiver 3.x +// Project: https://developers.google.com/cast/docs/reference/caf_receiver/ +// Definitions by: Craig Bruce https://github.com/craigrbruce +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// +/// +/// +/// +/// +/// + +import { Break, BreakClip } from './cast.framework.messages'; + +export = cast.framework.breaks; + +declare namespace cast.framework.breaks { + export class BreakSeekData { + constructor(seekFrom: number, seekTo: number, breaks: Break[]); + + /** + * List of breaks + */ + breaks: Break[]; + + /** + * Current playback time + */ + seekFrom: number; + + /** + * The time to seek to + */ + seekTo: number; + } + + /** Provide context information for break clip load interceptor. */ + export class BreakClipLoadInterceptorContext { + constructor(brk: Break); + + /** + * The container break for the break clip + */ + break: Break; + } + + /** Interface to manage breaks */ + export interface BreakManager { + /** + * Get current media break by id. + * @param {*} id + */ + getBreakById(id: string): Break; + + /** + * Get current media break clip by id + * @param {*} id + */ + getBreakClipById(id: string): BreakClip; + + /** Get current media break clips. */ + getBreakClips(): BreakClip[]; + + /** Get current media breaks. */ + getBreaks(): Break[]; + + /** Returns true if watched breaks should be played. */ + getPlayWatchedBreak(): boolean; + + /** + * Provide an interceptor to allow developer to insert more break clips or modify current break clip before a break is started. + * If interceptor is null it will reset the interceptor to default one. + * By default VAST fetching and parsing logic in default interceptor. + * So if customized interceptor is set by developer; + * the VAST logic will be overridden and developers should implement their own VAST fetching and parsing logic in the provided interceptor. + * @param {*} interceptor + */ + setBreakClipLoadInterceptor( + interceptor: ( + breakClip: BreakClip, + breakClipLoaderContext?: BreakClipLoadInterceptorContext + ) => void + ): void; + + /** + * Provide an interceptor for developer to specify what breaks they want to play after seek. + * @param {*} seekInterceptor + */ + setBreakSeekInterceptor( + seekInterceptor: (breakSeekData: BreakSeekData) => void + ): void; + + /** + * Set a flag to control if the watched client stitching break should be played. + * @param {*} playWatchedBreak + */ + setPlayWatchedBreak(playWatchedBreak: boolean): void; + + /** + * Provide an interceptor to modify VAST tracking URL before it is being sent to server. + * The input of the interceptor is a string of the tracking URL. + * The interceptor can either return a modified string of URL or a Promise of modified string of URL. + * The interceptor can also return null if you want to send the tracking URL by your own code instead of by CAF. + * @param {*} interceptor + */ + setVastTrackingInterceptor( + interceptor?: (trackingUrl: string) => void + ): void; + } +} diff --git a/types/chromecast-caf-receiver/cast.framework.d.ts b/types/chromecast-caf-receiver/cast.framework.d.ts new file mode 100644 index 0000000000..a22e9a24b9 --- /dev/null +++ b/types/chromecast-caf-receiver/cast.framework.d.ts @@ -0,0 +1,773 @@ +// Type definitions for chromecast-caf-receiver 3.x +// Project: https://developers.google.com/cast/docs/reference/caf_receiver/ +// Definitions by: Craig Bruce https://github.com/craigrbruce +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// +/// +/// +/// +/// +/// + +import { EventType } from './cast.framework.events'; +import { + PlayerState, + PlayStringId, + ErrorType, + ErrorReason, + IdleReason, + MessageType, + Track, + TextTrackStyle, + QueueItem, + LoadRequestData, + QueueData, + Break, + LiveSeekableRange, + MediaInformation, + ErrorData, + RequestData, +} from './cast.framework.messages'; +import { BreakManager } from './cast.framework.breaks'; +import { EventHandler, RequestHandler, BinaryHandler } from './cast'; +import { + ApplicationData, + Sender, + StandbyState, + SystemState, +} from './cast.framework.system'; + +export = cast.framework; + +declare namespace cast.framework { + export type LoggerLevel = + | 'DEBUG' + | 'VERBOSE' + | 'INFO' + | 'WARNING' + | 'ERROR' + | 'NONE'; + + export type ContentProtection = + | 'NONE' + | 'CLEARKEY' + | 'PLAYREADY' + | 'WIDEVINE'; + + /** + * Manages text tracks. + */ + export class TextTracksManager { + constructor(params: any); + + /** + * Adds text tracks to the list. + */ + addTracks(tracks: Track[]): void; + + /** + * Creates a text track. + */ + createTrack(): Track; + + /** + * Gets all active text ids. + */ + getActiveIds(): number[]; + + /** + * Gets all active text tracks. + */ + getActiveTracks(): Track[]; + + /** + * Returns the current text track style. + */ + getTextTracksStyle(): TextTrackStyle; + + /** + * Gets text track by id. + */ + getTrackById(id: number): Track; + + /** + * Returns all text tracks. + */ + getTracks(): Track[]; + + /** + * Gets text tracks by language. + */ + getTracksByLanguage(language: string): Track[]; + + /** + * Sets text tracks to be active by id. + */ + setActiveByIds(newIds: number[]): void; + + /** + * Sets text tracks to be active by language. + */ + setActiveByLanguage(language: string): void; + + /** + * Sets text track style. + */ + setTextTrackStyle(style: TextTrackStyle): void; + } + + /** + * QueueManager exposes several queue manipulation APIs to developers. + */ + export class QueueManager { + constructor(params: any); + + /** + * Returns the current queue item. + */ + getCurrentItem(): QueueItem; + + /** + * Returns the index of the current queue item. + */ + getCurrentItemIndex(): number; + + /** + * Returns the queue items. + */ + getItems(): QueueItem[]; + + /** + * Inserts items into the queue. + */ + insertItems(items: QueueItem[], insertBefore?: number): void; + + /** + * Removes items from the queue. + */ + removeItems(itemIds: number[]): void; + + /** + * Sets whether to limit the number of queue items to be reported in Media Status (default is true). + */ + setQueueStatusLimit(limitQueueItemsInStatus: boolean): void; + + /** + * Updates existing queue items by matching itemId. + */ + updateItems(items: QueueItem[]): void; + } + + /** + * Base implementation of a queue. + */ + export class QueueBase { + /** + * Fetches a window of items using the specified item id as reference; called by the receiver MediaManager when it needs more queue items; often as a request from senders. If only one of nextCount and prevCount is non-zero; fetchItems should only return items after or before the reference item; if both nextCount and prevCount are non-zero; a window of items including the reference item should be returned. + */ + fetchItems( + itemId: number, + nextCount: number, + prevCount: number + ): QueueItem[] | Promise; + + /** + * Initializes the queue with the requestData. This is called when a new LOAD request comes in to the receiver. If this returns or resolves to null; our default queueing implementation will create a queue based on queueData.items or the single media in the load request data. + */ + initialize(requestData: LoadRequestData): QueueData | Promise; + + /** + * Returns next items after the reference item; often the end of the current queue; called by the receiver MediaManager. + */ + nextItems(itemId?: number): QueueItem[] | Promise; + + /** + * Sets the current item with the itemId; called by the receiver MediaManager when it changes the current playing item. + */ + onCurrentItemIdChanged(itemId: number): void; + + /** + * A callback for informing the following items have been inserted into the receiver queue in this session. A cloud based implementation can optionally choose to update its queue based on the new information. + */ + onItemsInserted(items: QueueItem[], insertBefore?: number): void; + + /** + * A callback for informing the following items have been removed from the receiver queue in this session. A cloud based implementation can optionally choose to update its queue based on the new information. + */ + onItemsRemoved(itemIds: number[]): void; + + /** + * Returns previous items before the reference item; often at the beginning of the queue; called by the receiver MediaManager. + */ + prevItems(itemId?: number): QueueItem[] | Promise; + + /** + * Shuffles the queue and returns new queue items. Returns null if the operation is not supported. + */ + shuffle(): QueueItem[] | Promise; + } + + /** + * Controls and monitors media playback. + */ + export class PlayerManager { + constructor(params: any); + + /** + * Adds an event listener for player event. + */ + addEventListener: ( + eventType: EventType | EventType[], + eventListener: EventHandler + ) => void; + + /** + * Sends a media status message to all senders (broadcast). Applications use this to send a custom state change. + */ + broadcastStatus( + includeMedia?: boolean, + requestId?: number, + customData?: any, + includeQueueItems?: boolean + ): void; + + /** + * + */ + getAudioTracksManager(): AudioTracksManager; + + /** + * Returns current time in sec in currently-playing break clip. + */ + getBreakClipCurrentTimeSec(): number; + + /** + * Returns duration in sec of currently-playing break clip. + */ + getBreakClipDurationSec(): number; + + /** + * Obtain the breaks (Ads) manager. + */ + getBreakManager(): BreakManager; + + /** + * Returns list of breaks. + */ + getBreaks(): Break[]; + + /** + * Gets current time in sec of current media. + */ + getCurrentTimeSec(): number; + + /** + * Gets duration in sec of currently playing media. + */ + getDurationSec(): number; + + /** + * Returns live seekable range with start and end time in seconds. The values are media time based. + */ + getLiveSeekableRange(): LiveSeekableRange; + + /** + * Gets media information of current media. + */ + getMediaInformation(): MediaInformation; + + /** + * Returns playback configuration. + */ + getPlaybackConfig(): PlaybackConfig; + + /** + * Returns current playback rate. + */ + getPlaybackRate(): number; + + /** + * Gets player state. + */ + getPlayerState(): PlayerState; + + /** + * Get the preferred playback rate. (Can be used on shutdown event to save latest preferred playback rate to a persistent storage; so it can be used in next session in the cast options). + */ + getPreferredPlaybackRate(): number; + + /** + * Get the preferred text track language. + */ + getPreferredTextLanguage(): string; + + /** + * Obtain QueueManager API. + */ + getQueueManager(): QueueManager; + + /** + * + */ + getTextTracksManager(): TextTracksManager; + + /** + * Loads media. + */ + load(loadRequest: LoadRequestData): Promise; + + /** + * Pauses currently playing media. + */ + pause(): void; + + /** + * Plays currently paused media. + */ + play(): void; + + /** + * Requests a text string to be played back locally on the receiver device. + */ + playString(stringId: PlayStringId, args?: string[]): Promise; + + /** + * Request Google Assistant to refresh the credentials. Only works if the original credentials came from the assistant. + */ + refreshCredentials(): Promise; + + /** + * Removes the event listener added for given player event. If event listener is not added; it will be ignored. + */ + removeEventListener( + eventType: EventType | EventType[], + eventListener: EventHandler + ): void; + + /** + * Seeks in current media. + */ + seek(seekTime: number): void; + + /** + * Sends an error to a specific sender + */ + sendError( + senderId: string, + requestId: number, + type: ErrorType, + reason?: ErrorReason, + customData?: any + ): void; + + /** + * Send local media request. + */ + sendLocalMediaRequest(request: RequestData): void; + + /** + * Sends a media status message to a specific sender. + */ + sendStatus( + senderId: string, + requestId: number, + includeMedia?: boolean, + customData?: any, + includeQueueItems?: boolean + ): void; + + /** + * Sets the IDLE reason. This allows applications that want to force the IDLE state to indicate the reason that made the player going to IDLE state (a custom error; for example). The idle reason will be sent in the next status message. NOTE: Most applications do not need to set this value; it is only needed if they want to make the player go to IDLE in special circumstances and the default idleReason does not reflect their intended behavior. + */ + setIdleReason(idleReason: IdleReason): void; + + /** + * Sets MediaElement to use. If Promise of MediaElement is set; media begins playback after Promise is resolved. + */ + setMediaElement(mediaElement: HTMLMediaElement): void; + + /** + * Sets media information. + */ + setMediaInformation( + mediaInformation: MediaInformation, + opt_broadcast?: boolean + ): void; + + /** + * Sets a handler to return or modify PlaybackConfig; for a specific load request. The handler paramaters are the load request data and default playback config for the receiver (provided in the context options). The handler should returns a modified playback config; or null to prevent the media from playing. The return value can be a promise to allow waiting for data from the server. + */ + setMediaPlaybackInfoHandler( + handler: ( + loadRequestData: LoadRequestData, + playbackConfig: PlaybackConfig + ) => void + ): void; + + /** + * Sets a handler to return the media url for a load request. This handler can be used to avoid having the media content url published as part of the media status. By default the media contentId is used as the content url. + */ + setMediaUrlResolver( + resolver: (loadRequestData: LoadRequestData) => void + ): void; + + /** + * Provide an interceptor of incoming and outgoing messages. The interceptor can update the request data; and return updated data; a promise of updated data if need to get more data from the server; or null if the request should not be handled. Note that if load message interceptor is provided; and no interceptor is provided for preload - the load interceptor will be called for preload messages. + */ + setMessageInterceptor( + type: MessageType, + interceptor: (requestData: RequestData) => Promise + ): void; + + /** + * Sets playback configuration on the PlayerManager. + */ + setPlaybackConfig(playbackConfig: PlaybackConfig): void; + + /** + * Set the preferred playback rate for follow up load or media items. The preferred playback rate will be updated automatically to the latest playback rate that was provided by a load request or explicit set of playback rate. + */ + setPreferredPlaybackRate(preferredPlaybackRate: number): void; + + /** + * Set the preferred text track language. The preferred text track language will be updated automatically to the latest enabled language by a load request or explicit change to text tracks. (Should be called only in idle state; and Will only apply to next loaded media). + */ + setPreferredTextLanguage(preferredTextLanguage: string): void; + + /** + * Stops currently playing media. + */ + stop(): void; + } + + /** + * Configuration to customize playback behavior. + */ + export class PlaybackConfig { + /** + * Duration of buffered media in seconds to start buffering. + */ + autoPauseDuration?: number; + + /** + * Duration of buffered media in seconds to start/resume playback after auto-paused due to buffering. + */ + autoResumeDuration?: number; + + /** + * Minimum number of buffered segments to start/resume playback. + */ + autoResumeNumberOfSegments?: number; + + /** + * A function to customize request to get a caption segment. + */ + captionsRequestHandler?: RequestHandler; + + /** + * Initial bandwidth in bits in per second. + */ + initialBandwidth?: number; + + /** + * Custom license data. + */ + licenseCustomData?: string; + + /** + * Handler to process license data. The handler is passed the license data; and returns the modified license data. + */ + licenseHandler?: BinaryHandler; + + /** + * A function to customize request to get a license. + */ + licenseRequestHandler?: RequestHandler; + + /** + * Url for acquiring the license. + */ + licenseUrl?: string; + + /** + * Handler to process manifest data. The handler is passed the manifest; and returns the modified manifest. + */ + manifestHandler?: (manifest: string) => string; + + /** + * A function to customize request to get a manifest. + */ + manifestRequestHandler?: RequestHandler; + + /** + * Preferred protection system to use for decrypting content. + */ + protectionSystem: ContentProtection; + + /** + * Handler to process segment data. The handler is passed the segment data; and returns the modified segment data. + */ + segmentHandler?: BinaryHandler; + + /** + * A function to customize request information to get a media segment. + */ + segmentRequestHandler?: RequestHandler; + + /** + * Maximum number of times to retry a network request for a segment. + */ + segmentRequestRetryLimit?: number; + } + /** + * HTTP(s) Request/Response information. + */ + export class NetworkRequestInfo { + /** + * The content of the request. Can be used to modify license request body. + */ + content: Uint8Array; + + /** + * An object containing properties that you would like to send in the header. + */ + headers: any; + + /** + * The URL requested. + */ + url: string; + + /** + * Indicates whether CORS Access-Control requests should be made using credentials such as cookies or authorization headers. + */ + withCredentials: boolean; + } + /** Cast receiver context options. All options are optionals. */ + export class CastReceiverOptions { + /** + * Optional map of custom messages namespaces to initialize and their types. + * Custom messages namespaces need to be initiated before the application started; + * so it is best to provide the namespaces in the receiver options. + * (The default type of a message bus is JSON; if not provided here). + */ + customNamespaces?: any; + + /** + * Sender id used for local requests. Default value is 'local'. + */ + localSenderId?: string; + + /** + * Maximum time in seconds before closing an idle sender connection. + * Setting this value enables a heartbeat message to keep the connection alive. + * Used to detect unresponsive senders faster than typical TCP timeouts. + * The minimum value is 5 seconds; there is no upper bound enforced but practically it's minutes before platform TCP timeouts come into play. + * Default value is 10 seconds. + */ + maxInactivity?: number; + + /** + * Optional media element to play content with. Default behavior is to use the first found media element in the page. + */ + mediaElement?: HTMLMediaElement; + + /** + * Optional playback configuration. + */ + playbackConfig?: PlaybackConfig; + + /** + * If this is true; the watched client stitching break will also be played. + */ + playWatchedBreak?: boolean; + + /** + * Preferred value for player playback rate. It is used if playback rate value is not provided in the load request. + */ + preferredPlaybackRate?: number; + + /** + * Preferred text track language. It is used if no active track is provided in the load request. + */ + preferredTextLanguage?: string; + + /** + * Optional queue implementation. + */ + queue?: QueueBase; + + /** + * Text that represents the application status. + * It should meet internationalization rules as may be displayed by the sender application. + */ + statusText?: string; + + /** + * A bitmask of media commands supported by the application. + * LOAD; PLAY; STOP; GET_STATUS must always be supported. + * If this value is not provided; then PAUSE; SEEK; STREAM_VOLUME; STREAM_MUTE are assumed to be supported too. + */ + supportedCommands?: number; + + /** + * Indicate that MPL should be used for DASH content. + */ + useLegacyDashSupport?: boolean; + + /** + * An integer used as an internal version number. + * This number is used only to distinguish between receiver releases and higher numbers do not necessarily have to represent newer releases. + */ + versionCode?: number; + } + + /** Manages loading of underlying libraries and initializes underlying cast receiver SDK. */ + export class CastReceiverContext { + /** Returns the CastReceiverContext singleton instance. */ + static getInstance(): CastReceiverContext; + + constructor(params: any); + + /** + * Sets message listener on custom message channel. + */ + addCustomMessageListener(namespace: string, listener: EventHandler): void; + + /** + * Add listener to cast system events. + */ + addEventListener(type: EventType, handler: EventHandler): void; + + /** + * Checks if the given media params of video or audio streams are supported by the platform. + */ + canDisplayType( + mimeType: string, + codecs?: string, + width?: number, + height?: number, + framerate?: number + ): boolean; + + /** + * Provides application information once the system is ready; otherwise it will be null. + */ + getApplicationData(): ApplicationData; + + /** + * Provides device capabilities information once the system is ready; otherwise it will be null. + * If an empty object is returned; the device does not expose any capabilities information. + */ + getDeviceCapabilities(): any; + + /** + * Get Player instance that can control and monitor media playback. + */ + getPlayerManager(): PlayerManager; + + /** + * Get a sender by sender id + */ + getSender(senderId: string): Sender; + + /** + * Gets a list of currently-connected senders. + */ + getSenders(): Sender[]; + + /** + * Reports if the cast application's HDMI input is in standby. + */ + getStandbyState(): StandbyState; + + /** + * Provides application information about the system state. + */ + getSystemState(): SystemState; + + /** + * Reports if the cast application is the HDMI active input. + */ + getVisibilityState(): VisibilityState; + + /** + * When the application calls start; the system will send the ready event to indicate + * that the application information is ready and the application can send messages as soon as there is one sender connected. + */ + isSystemReady(): boolean; + + /** + * Start loading player js. This can be used to start loading the players js code in early stage of starting the receiver before calling start. + * This function is a no-op if players were already loaded (start was called). + */ + loadPlayerLibraries(useLegacyDashSupport?: boolean): void; + + /** + * Remove a message listener on custom message channel. + */ + removeCustomMessageListener( + namespace: string, + listener: EventHandler + ): void; + + /** + * Remove listener to cast system events. + */ + removeEventListener(type: EventType, handler: EventHandler): void; + + /** + * Sends a message to a specific sender. + */ + sendCustomMessage(namespace: string, senderId: string, message: any): void; + + /** + * This function should be called in response to the feedbackstarted event if the application + * add debug state information to log in the feedback report. + * It takes in a parameter ‘message’ that is a string that represents the debug information that the application wants to log. + */ + sendFeedbackMessage(feedbackMessage: string): void; + + /** + * Sets the application state. The application should call this when its state changes. + * If undefined or set to an empty string; the value of the Application Name established during application + * registration is used for the application state by default. + */ + setApplicationState(statusText: string): void; + + /** + * Sets the receiver inactivity timeout. + * It is recommended to set the maximum inactivity value when calling Start and not changing it. + * This API is just provided for development/debugging purposes. + */ + setInactivityTimeout(maxInactivity: number): void; + + /** + * Sets the log verbosity level. + */ + setLoggerLevel(level: LoggerLevel): void; + + /** + * Initializes system manager and media manager; so that receiver app can receive requests from senders. + */ + start(options?: CastReceiverOptions): CastReceiverContext; + + /** + * Shutdown receiver application. + */ + stop(): void; + } + + /** Manages audio tracks. */ + export class AudioTracksManager { + constructor(params: any); + getActiveId(): number; + getActiveTrack(): Track; + getTrackById(id: number): Track; + getTracks(): Track[]; + getTracksByLanguage(language: string): Track[]; + setActiveById(id: number): void; + setActiveByLanguage(language: string): void; + } +} diff --git a/types/chromecast-caf-receiver/cast.framework.events.d.ts b/types/chromecast-caf-receiver/cast.framework.events.d.ts new file mode 100644 index 0000000000..c5e2e71771 --- /dev/null +++ b/types/chromecast-caf-receiver/cast.framework.events.d.ts @@ -0,0 +1,421 @@ +// Type definitions for chromecast-caf-receiver 3.x +// Project: https://developers.google.com/cast/docs/reference/caf_receiver/ +// Definitions by: Craig Bruce https://github.com/craigrbruce +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// +/// +/// +/// +/// +/// + +import { + RequestData, + MediaInformation, + Track, + MediaStatus, +} from './cast.framework.messages'; +export = cast.framework.events; + +declare namespace cast.framework.events { + export type EventType = + | 'ALL' + | 'ABORT' + | 'CAN_PLAY' + | 'CAN_PLAY_THROUGH' + | 'DURATION_CHANGE' + | 'EMPTIED' + | 'ENDED' + | 'LOADED_DATA' + | 'LOADED_METADATA' + | 'LOAD_START' + | 'PAUSE' + | 'PLAY' + | 'PLAYING' + | 'PROGRESS' + | 'RATE_CHANGE' + | 'SEEKED' + | 'SEEKING' + | 'STALLED' + | 'TIME_UPDATE' + | 'SUSPEND' + | 'WAITING' + | 'BITRATE_CHANGED' + | 'BREAK_STARTED' + | 'BREAK_ENDED' + | 'BREAK_CLIP_LOADING' + | 'BREAK_CLIP_STARTED' + | 'BREAK_CLIP_ENDED' + | 'BUFFERING' + | 'CACHE_LOADED' + | 'CACHE_HIT' + | 'CACHE_INSERTED' + | 'CLIP_STARTED' + | 'CLIP_ENDED' + | 'EMSG' + | 'ERROR' + | 'ID3' + | 'MEDIA_STATUS' + | 'MEDIA_FINISHED' + | 'PLAYER_PRELOADING' + | 'PLAYER_PRELOADING_CANCELLED' + | 'PLAYER_LOAD_COMPLETE' + | 'PLAYER_LOADING' + | 'SEGMENT_DOWNLOADED' + | 'REQUEST_SEEK' + | 'REQUEST_LOAD' + | 'REQUEST_STOP' + | 'REQUEST_PAUSE' + | 'REQUEST_PLAY' + | 'REQUEST_PLAY_AGAIN' + | 'REQUEST_PLAYBACK_RATE_CHANGE' + | 'REQUEST_SKIP_AD' + | 'REQUEST_VOLUME_CHANGE' + | 'REQUEST_EDIT_TRACKS_INFO' + | 'REQUEST_EDIT_AUDIO_TRACKS' + | 'REQUEST_SET_CREDENTIALS' + | 'REQUEST_LOAD_BY_ENTITY' + | 'REQUEST_USER_ACTION' + | 'REQUEST_DISPLAY_STATUS' + | 'REQUEST_CUSTOM_COMMAND' + | 'REQUEST_FOCUS_STATE' + | 'REQUEST_QUEUE_LOAD' + | 'REQUEST_QUEUE_INSERT' + | 'REQUEST_QUEUE_UPDATE' + | 'REQUEST_QUEUE_REMOVE' + | 'REQUEST_QUEUE_REORDER' + | 'REQUEST_QUEUE_GET_ITEM_RANGE' + | 'REQUEST_QUEUE_GET_ITEMS' + | 'REQUEST_QUEUE_GET_ITEM_IDS' + | 'REQUEST_PRECACHE'; + + export type DetailedErrorCode = + | 'MEDIA_UNKNOWN' + | 'MEDIA_ABORTED' + | 'MEDIA_DECODE' + | 'MEDIA_NETWORK' + | 'MEDIA_SRC_NOT_SUPPORTED' + | 'SOURCE_BUFFER_FAILURE' + | 'MEDIAKEYS_UNKNOWN' + | 'MEDIAKEYS_NETWORK' + | 'MEDIAKEYS_UNSUPPORTED' + | 'MEDIAKEYS_WEBCRYPTO' + | 'NETWORK_UNKNOWN' + | 'SEGMENT_NETWORK' + | 'HLS_NETWORK_MASTER_PLAYLIST' + | 'HLS_NETWORK_PLAYLIST' + | 'HLS_NETWORK_NO_KEY_RESPONSE' + | 'HLS_NETWORK_KEY_LOAD' + | 'HLS_NETWORK_INVALID_SEGMENT' + | 'HLS_SEGMENT_PARSING' + | 'DASH_NETWORK' + | 'DASH_NO_INIT' + | 'SMOOTH_NETWORK' + | 'SMOOTH_NO_MEDIA_DATA' + | 'MANIFEST_UNKNOWN' + | 'HLS_MANIFEST_MASTER' + | 'HLS_MANIFEST_PLAYLIST' + | 'DASH_MANIFEST_UNKNOWN' + | 'DASH_MANIFEST_NO_PERIODS' + | 'DASH_MANIFEST_NO_MIMETYPE' + | 'DASH_INVALID_SEGMENT_INFO' + | 'SMOOTH_MANIFEST' + | 'SEGMENT_UNKNOWN' + | 'TEXT_UNKNOWN' + | 'APP' + | 'BREAK_CLIP_LOADING_ERROR' + | 'BREAK_SEEK_INTERCEPTOR_ERROR' + | 'IMAGE_ERROR' + | 'LOAD_INTERRUPTED' + | 'GENERIC'; + + export type EndedReason = + | 'END_OF_STREAM' + | 'ERROR' + | 'STOPPED' + | 'INTERRUPTED' + | 'SKIPPED' + | 'BREAK_SWITCH'; + + /** + * Event data for @see{@link EventType.SEGMENT_DOWNLOADED} event. + */ + export class SegmentDownloadedEvent { + constructor(downloadTime?: number, size?: number); + + /** + * The time it took to download the segment; in milliseconds. + */ + downloadTime?: number; + + /** + * The number of bytes in the segment. + */ + size?: number; + } + + /** + * Event data for all events that represent requests made to the receiver. + */ + export class RequestEvent { + constructor(type: EventType, requestData?: RequestData, senderId?: string); + + /** + * The data that was sent with the request. + */ + requestData?: RequestData; + + /** + * The sender id the request came from. + */ + senderId?: string; + } + + /** + * Event data for @see{@link EventType.MEDIA_STATUS} event. + */ + export class MediaStatusEvent { + constructor(mediaStatus?: MediaStatus); + + /** + * The media status that was sent. + */ + mediaStatus?: MediaStatus; + } + /** + * Event data for pause events forwarded from the MediaElement. + */ + export class MediaPauseEvent { + constructor(currentMediaTime?: number, ended?: boolean); + + /** + * Indicate if the media ended (indicates the pause was fired due to stream reached the end). + */ + ended?: boolean; + } + /** + * Event data for @see{@link EventType.MEDIA_FINISHED} event. + */ + export class MediaFinishedEvent { + constructor(currentMediaTime?: number, endedReason?: EndedReason); + + /** + * The time when the media finished (in seconds). For an item in a queue; this value represents the time in the currently playing queue item ( where 0 means the queue item has just started). + */ + currentTime?: number; + + /** + * The reason the media finished. + */ + endedReason?: EndedReason; + } + /** + * Event data for all events forwarded from the MediaElement. + */ + export class MediaElementEvent { + constructor(type: EventType, currentMediaTime?: number); + + /** + * The time in the currently playing clip when the event was fired (in seconds). Undefined if playback has not started yet. + */ + currentMediaTime?: number; + } + /** + * Event data for all events pertaining to processing a load / preload request. made to the player. + */ + export class LoadEvent { + constructor(type: EventType, media?: MediaInformation); + + /** + * Information about the media being loaded. + */ + media: MediaInformation; + } + /** + * Event data for @see{@link EventType.INBAND_TRACK_ADDED} event. + */ + export class InbandTrackAddedEvent { + constructor(track: Track); + + /** + * Added track. + */ + track: Track; + } + + /** Event data for @see{@link EventType.ID3} event. */ + export class Id3Event { + constructor(segmentData: Uint8Array); + + /** + * The segment data. + */ + segmentData: Uint8Array; + } + /** + * Event data superclass for all events dispatched by @see{@link PlayerManager} + */ + export class Event { + constructor(type: EventType); + + /** + * Type of the event. + */ + type: EventType; + } + /** + * Event data for @see{@link EventType.EMSG} event. + */ + export class EmsgEvent { + constructor(emsgData: any); + + /** + * The time that the event ends (in presentation time). Undefined if using legacy Dash support. + */ + endTime: any; + + /** + * The duration of the event (in units of timescale). Undefined if using legacy Dash support. + */ + eventDuration: any; + + /** + * A field identifying this instance of the message. Undefined if using legacy Dash support. + */ + id: any; + + /** + * Body of the message. Undefined if using legacy Dash support. + */ + messageData: any; + + /** + * The offset that the event starts; relative to the start of the segment this is contained in (in units of timescale). Undefined if using legacy Dash support. + */ + presentationTimeDelta: any; + + /** + * Identifies the message scheme. Undefined if using legacy Dash support. + */ + schemeIdUri: any; + + /** + * The segment data. This is only defined if using legacy Dash support. + */ + segmentData: any; + + /** + * The time that the event starts (in presentation time). Undefined if using legacy Dash support. + */ + startTime: any; + + /** + * Provides the timescale; in ticks per second. Undefined if using legacy Dash support. + */ + timescale: any; + + /** + * Specifies the value for the event. Undefined if using legacy Dash support. + */ + value: any; + } + /** + * Event data for @see{@link EventType.CLIP_ENDED} event. + */ + export class ClipEndedEvent { + constructor(currentMediaTime: number, endedReason?: EndedReason); + + /** + * The time in media (in seconds) when clip ended. + */ + currentMediaTime: number; + + /** + * The reason the clip ended. + */ + endedReason?: EndedReason; + } + + /** + * Event data for @see{@link EventType.CACHE_LOADED} event. + */ + export class CacheLoadedEvent { + constructor(media?: MediaInformation); + + /** + * Information about the media being cached. + */ + media: MediaInformation; + } + + export class CacheItemEvent { + constructor(type: EventType, url: string); + + /** + * The URL of data fetched from cache + */ + url: string; + } + + export class BufferingEvent { + constructor(isBuffering: boolean); + + /** + * True if the player is entering a buffering state. + */ + isBuffering: boolean; + } + + export class BreaksEvent { + constructor( + type: EventType, + currentMediaTime?: number, + index?: number, + total?: number, + whenSkippable?: number, + endedReason?: EndedReason, + breakClipId?: string + ); + + /** + * The break clip's id. Refer to BreakClip.id + */ + breakClipId: string; + + /** + * The time in the currently playing media when the break event occurred. + */ + currentMediaTime: string; + + /** + * The reason the break clip ended. + */ + endedReason: EndedReason; + + /** + * Index of break clip; which starts from 1. + */ + index: number; + + /** + * Total number of break clips. + */ + total: number; + + /** + * When to skip current break clip in sec; after break clip begins to play. + */ + whenSkippable: number; + } + + /** + * Event data for @see {@link EventType.BITRATE_CHANGED} event. + */ + export class BitrateChangedEvent { + constructor(totalBitrate?: number); + + /** The bitrate of the media (audio and video) in bits per second. */ + totalBitrate: number; + } +} diff --git a/types/chromecast-caf-receiver/cast.framework.messages.d.ts b/types/chromecast-caf-receiver/cast.framework.messages.d.ts new file mode 100644 index 0000000000..dc5c1ac07b --- /dev/null +++ b/types/chromecast-caf-receiver/cast.framework.messages.d.ts @@ -0,0 +1,1777 @@ +// Type definitions for chromecast-caf-receiver 3.x +// Project: https://developers.google.com/cast/docs/reference/caf_receiver/ +// Definitions by: Craig Bruce https://github.com/craigrbruce +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// +/// +/// +/// +/// +/// + +import { DetailedErrorCode } from './cast.framework.events'; +export = cast.framework.messages; + +declare namespace cast.framework.messages { + export type UserAction = + | 'LIKE' + | 'DISLIKE' + | 'FOLLOW' + | 'UNFOLLOW' + | 'FLAG' + | 'SKIP_AD'; + + export type UserActionContext = + | 'UNKNOWN_CONTEXT' + | 'ALBUM' + | 'ARTIST' + | 'PLAYLIST' + | 'EPISODE' + | 'SERIES' + | 'MOVIE' + | 'CHANNEL' + | 'TEAM' + | 'PLAYER' + | 'COACH'; + + export type TextTrackType = + | 'SUBTITLES' + | 'CAPTIONS' + | 'DESCRIPTIONS' + | 'CHAPTERS' + | 'METADATA'; + + export type TextTrackWindowType = 'NONE' | 'NORMAL' | 'ROUNDED_CORNERS'; + + export type TrackType = 'TEXT' | 'AUDIO' | 'VIDEO'; + + export type TextTrackFontGenericFamily = + | 'SANS_SERIF' + | 'MONOSPACED_SANS_SERIF' + | 'SERIF' + | 'MONOSPACED_SERIF' + | 'CASUAL' + | 'CURSIVE' + | 'SMALL_CAPITALS'; + + export type TextTrackFontStyle = 'NORMAL' | 'BOLD' | 'BOLD_ITALIC' | 'ITALIC'; + + export type TextTrackEdgeType = + | 'NONE' + | 'OUTLINE' + | 'DROP_SHADOW' + | 'RAISED' + | 'DEPRESSED'; + + export type Command = + | 'PAUSE' + | 'SEEK' + | 'STREAM_VOLUME' + | 'STREAM_MUTE' + | 'ALL_BASIC_MEDIA' + | 'QUEUE_NEXT' + | 'QUEUE_PREV' + | 'QUEUE_SHUFFLE' + | 'SKIP_AD'; + + export type SeekResumeState = 'PLAYBACK_START' | 'PLAYBACK_PAUSE'; + + export type StreamingProtocolType = + | 'UNKNOWN' + | 'MPEG_DASH' + | 'HLS' + | 'SMOOTH_STREAMING'; + + export type StreamType = 'BUFFERED' | 'LIVE' | 'NONE'; + + export type FocusState = 'IN_FOCUS' | 'NOT_IN_FOCUS'; + + export type ExtendedPlayerState = 'LOADING'; + + export type ErrorType = + | 'INVALID_PLAYER_STATE' + | 'LOAD_FAILED' + | 'LOAD_CANCELLED' + | 'INVALID_REQUEST' + | 'ERROR'; + + export type ErrorReason = + | 'INVALID_COMMAND' + | 'INVALID_PARAMS' + | 'INVALID_MEDIA_SESSION_ID' + | 'SKIP_LIMIT_REACHED' + | 'NOT_SUPPORTED' + | 'LANGUAGE_NOT_SUPPORTED' + | 'END_OF_QUEUE' + | 'APP_ERROR' + | 'AUTHENTICATION_EXPIRED' + | 'PREMIUM_ACCOUNT_REQUIRED' + | 'CONCURRENT_STREAM_LIMIT' + | 'PARENTAL_CONTROL_RESTRICTED' + | 'NOT_AVAILABLE_IN_REGION' + | 'CONTENT_ALREADY_PLAYING' + | 'INVALID_REQUEST' + | 'GENERIC_LOAD_ERROR'; + + export type RepeatMode = + | 'REPEAT_OFF' + | 'REPEAT_ALL' + | 'REPEAT_SINGLE' + | 'REPEAT_ALL_AND_SHUFFLE'; + + export type IdleReason = 'CANCELLED' | 'INTERRUPTED' | 'FINISHED' | 'ERROR'; + + export type HlsSegmentFormat = 'AAC' | 'AC3' | 'MP3' | 'TS' | 'TS_AAC'; + + export type HdrType = 'SDR' | 'HDR' | 'DV'; + + export type PlayStringId = + | 'FREE_TRIAL_ABOUT_TO_EXPIRE' + | 'SUBSCRIPTION_ABOUT_TO_EXPIRE' + | 'STREAM_HIJACKED'; + + export type GetStatusOptions = 'NO_METADATA' | 'NO_QUEUE_ITEMS'; + + export type MessageType = + | 'MEDIA_STATUS' + | 'CLOUD_STATUS' + | 'QUEUE_CHANGE' + | 'QUEUE_ITEMS' + | 'QUEUE_ITEM_IDS' + | 'GET_STATUS' + | 'LOAD' + | 'PAUSE' + | 'STOP' + | 'PLAY' + | 'SKIP_AD' + | 'PLAY_AGAIN' + | 'SEEK' + | 'SET_PLAYBACK_RATE' + | 'SET_VOLUME' + | 'EDIT_TRACKS_INFO' + | 'EDIT_AUDIO_TRACKS' + | 'PRECACHE' + | 'PRELOAD' + | 'QUEUE_LOAD' + | 'QUEUE_INSERT' + | 'QUEUE_UPDATE' + | 'QUEUE_REMOVE' + | 'QUEUE_REORDER' + | 'QUEUE_NEXT' + | 'QUEUE_PREV' + | 'QUEUE_GET_ITEM_RANGE' + | 'QUEUE_GET_ITEMS' + | 'QUEUE_GET_ITEM_IDS' + | 'QUEUE_SHUFFLE' + | 'SET_CREDENTIALS' + | 'LOAD_BY_ENTITY' + | 'USER_ACTION' + | 'DISPLAY_STATUS' + | 'FOCUS_STATE' + | 'CUSTOM_COMMAND'; + + export type PlayerState = 'IDLE' | 'PLAYING' | 'PAUSED' | 'BUFFERING'; + + export type QueueChangeType = + | 'INSERT' + | 'REMOVE' + | 'ITEMS_CHANGE' + | 'UPDATE' + | 'NO_CHANGE'; + + export type QueueType = + | 'ALBUM' + | 'PLAYLIST' + | 'AUDIOBOOK' + | 'RADIO_STATION' + | 'PODCAST_SERIES' + | 'TV_SERIES' + | 'VIDEO_PLAYLIST' + | 'LIVE_TV' + | 'MOVIE'; + + export type MetadataType = + | 'GENERIC' + | 'MOVIE' + | 'TV_SHOW' + | 'MUSIC_TRACK' + | 'PHOTO'; + + /** + * RefreshCredentials request data. + */ + export interface RefreshCredentialsRequestData { } + + /** + * Media event SET_VOLUME request data. + */ + export interface VolumeRequestData extends RequestData { + /** + * The media stream volume + */ + volume?: Volume; + } + + /** + * Represents the volume of a media session stream. + */ + export interface Volume { + /** + * Value from 0 to 1 that represents the current stream volume level. + */ + level?: number; + + /** + * Whether the stream is muted. + */ + muted?: boolean; + } + + /** + * Video information such as video resolution and High Dynamic Range (HDR). + */ + export class VideoInformation { + constructor(width: number, height: number, hdrType: HdrType); + + /** + * + */ + width: number; + + /** + * + */ + height: number; + + /** + * + */ + hdrType: HdrType; + } + + /** + * VAST ad request configuration. + */ + export interface VastAdsRequest { + /** + * Specifies a VAST document to be used as the ads response instead of making a request via an ad tag url. This can be useful for debugging and other situations where a VAST response is already available. + */ + adsResponse?: string; + + /** + * URL for VAST file. + */ + adTagUrl?: string; + } + + /** + * UserAction request data. + */ + export interface UserActionRequestData { + /** + * Optional request source. It contain the assistent query that initiate the request. + */ + source?: string; + + /** + * User action to be handled by the application. + */ + userAction?: UserAction; + + /** + * Optional context information for the user action. + */ + userActionContext?: UserActionContext; + } + + /** + * A TV episode media description. + */ + export interface TvShowMediaMetadata { + /** + * TV episode number. A positive integer. + */ + episode?: number; + + /** + * @deprecated use episode instead + */ + episodeNumber?: number; + + /** + * @deprecated use episode instead + */ + episodeTitle?: string; + + /** + * Content images. Examples would include cover art or a thumbnail of the currently playing media. + */ + images?: Image[]; + + /** + * ISO 8601 date when the episode originally aired; e.g. 2014-02-10. + */ + originalAirdate?: string; + + /** + * @deprecated use originalAirdate instead. + */ + releaseYear?: number; + + /** + * TV episode season. A positive integer. + */ + season?: number; + + /** + * @deprecated use season instead. + */ + seasonNumber?: number; + + /** + * TV series title. + */ + seriesTitle?: string; + + /** + * TV episode title. + */ + title?: string; + } + /** + * Describes track metadata information. + */ + export class Track { + constructor(trackId: number, trackType: TrackType); + + /** + * Custom data set by the receiver application. + */ + customData?: string; + + /** + * Language tag as per RFC 5646 (If subtype is “SUBTITLES” it is mandatory). + */ + language?: string; + + /** + * A descriptive; human readable name for the track. For example "Spanish". + */ + name?: string; + + /** + * For text tracks; the type of text track. + */ + subtype?: string; + + /** + * It can be the url of the track or any other identifier that allows the receiver to find the content (when the track is not inband or included in the manifest). For example it can be the url of a vtt file. + */ + trackContentId?: string; + + /** + * It represents the MIME type of the track content. For example if the track is a vtt file it will be ‘text/vtt’. This field is needed for out of band tracks; so it is usually provided if a trackContentId has also been provided. It is not mandatory if the receiver has a way to identify the content from the trackContentId; but recommended. The track content type; if provided; must be consistent with the track type. + */ + trackContentType?: string; + + /** + * Unique identifier of the track within the context of a MediaInformation object. + */ + trackId?: number; + + /** + * The type of track. + */ + type: TrackType; + } + /** + * Describes style information for a text track. + */ + export interface TextTrackStyle { + /** + * The background 32 bit RGBA color. The alpha channel should be used for transparent backgrounds. + */ + backgroundColor?: string; + + /** + * Custom data set by the receiver application. + */ + customData?: any; + + /** + * RGBA color for the edge; this value will be ignored if edgeType is NONE. + */ + edgeColor?: string; + + /** + * + */ + edgeType?: TextTrackEdgeType; + + /** + * If the font is not available in the receiver the fontGenericFamily will be used. + */ + fontFamily?: string; + + /** + * The text track generic family. + */ + fontGenericFamily?: TextTrackFontGenericFamily; + + /** + * The font scaling factor for the text track (the default is 1). + */ + fontScale?: number; + + /** + * The text track font style. + */ + fontStyle?: TextTrackFontStyle; + + /** + * The foreground 32 bit RGBA color. + */ + foregroundColor?: string; + + /** + * 32 bit RGBA color for the window. This value will be ignored if windowType is NONE. + */ + windowColor?: string; + + /** + * Rounded corner radius absolute value in pixels (px). This value will be ignored if windowType is not ROUNDED_CORNERS. + */ + windowRoundedCornerRadius?: number; + + /** + * The window concept is defined in CEA-608 and CEA-708. In WebVTT is called a region. + */ + windowType?: TextTrackWindowType; + } + + /** + * Media event playback rate request data. + */ + export interface SetPlaybackRateRequestData extends RequestData { + /** + * New playback rate (>0). + */ + playbackRate?: number; + + /** + * New playback rate relative to current playback rate. New rate will be the result of multiplying the current rate with the value. For example a value of 1.1 will increase rate by 10%. (Only used if the playbackRate value is not provided). + */ + relativePlaybackRate?: number; + } + + /** + * SetCredentials request data. + */ + export interface SetCredentialsRequestData { + /** + * Credentials to use by receiver. + */ + credentials?: string; + + /** + * If it is a response for refresh credentials; it will indicate the request id of the refresh credentials request. + */ + forRequestId?: number; + + /** + * Optional request source. It contain the assistent query that initiate the request. + */ + source?: string; + } + + /** + * Media event SEEK request data. + */ + export interface SeekRequestData extends RequestData { + /** + * Seconds since beginning of content. + */ + currentTime?: number; + + /** + * Seconds relative to the current playback position. If this field is defined; the currentTime field will be ignored. + */ + relativeTime?: number; + + /** + * The playback state after a SEEK request. + */ + resumeState?: SeekResumeState; + } + + /** + * Provides seekable range in seconds. + */ + export class SeekableRange { + constructor(start?: number, end?: number); + + /** + * End of the seekable range in seconds. + */ + end?: number; + + /** + * Start of the seekable range in seconds. + */ + start?: number; + } + + /** + * Media event request data. + */ + export class RequestData { + constructor(type: MessageType); + + /** + * Application-specific data for this request. It enables the sender and receiver to easily extend the media protocol without having to use a new namespace with custom messages. + */ + customData?: any; + + /** + * Id of the media session that the request applies to. + */ + mediaSessionId?: number; + + /** + * Id of the request; used to correlate request/response. + */ + requestId: number; + } + + /** + * Media event UPDATE queue request data. + */ + export interface QueueUpdateRequestData { + /** + * ID of the current media Item after the deletion (if not provided; the currentItem value will be the same as before the deletion; if it does not exist because it has been deleted; the currentItem will point to the next logical item in the list). + */ + currentItemId?: number; + + /** + * Seconds since the beginning of content to start playback of the current item. If provided; this value will take precedence over the startTime value provided at the QueueItem level but only the first time the item is played. This is to cover the common case where the user jumps to the middle of an item so the currentTime does not apply to the item permanently like the QueueItem startTime does. It avoids having to reset the startTime dynamically (that may not be possible if the phone has gone to sleep). + */ + currentTime?: number; + + /** + * List of queue items to be updated. No reordering will happen; the items will retain the existing order. + */ + items?: QueueItem[]; + + /** + * Skip/Go back number of items with respect to the position of currentItem (it can be negative). If it is out of boundaries; the currentItem will be the next logical item in the queue wrapping around the boundaries. The new currentItem position will follow the rules of the queue repeat behavior. + */ + jump?: number; + + /** + * Behavior of the queue when all items have been played. + */ + repeatMode?: RepeatMode; + + /** + * Shuffle the queue items when the update is processed. After the queue items are shuffled; the item at the currentItem position will be loaded. + */ + shuffle?: boolean; + } + + /** + * Media event queue REORDER request data. + */ + export class QueueReorderRequestData extends RequestData { + constructor(itemIds: number[]); + + /** + * ID of the current media Item after the deletion (if not provided; the currentItem value will be the same as before the deletion; if it does not exist because it has been deleted; the currentItem will point to the next logical item in the list). + */ + currentItemId?: number; + + /** + * Seconds since the beginning of content to start playback of the current item. If provided; this value will take precedence over the startTime value provided at the QueueItem level but only the first time the item is played. This is to cover the common case where the user jumps to the middle of an item so the currentTime does not apply to the item permanently like the QueueItem startTime does. It avoids having to reset the startTime dynamically (that may not be possible if the phone has gone to sleep). + */ + currentTime?: number; + + /** + * ID of the item that will be located immediately after the reordered list. If the ID is not found or it is not provided; the reordered list will be appended at the end of the existing list. + */ + insertBefore?: number; + + /** + * IDs of the items to be reordered; in the new order. Items not provided will keep their existing order. The provided list will be inserted at the position determined by insertBefore. For example: + + If insertBefore is not specified Existing queue: “A”;”D”;”G”;”H”;”B”;”E” itemIds: “D”;”H”;”B” New Order: “A”;”G”;”E”;“D”;”H”;”B” + + If insertBefore is “A” Existing queue: “A”;”D”;”G”;”H”;”B” itemIds: “D”;”H”;”B” New Order: “D”;”H”;”B”;“A”;”G”;”E” + + If insertBefore is “G” Existing queue: “A”;”D”;”G”;”H”;”B” itemIds: “D”;”H”;”B” New Order: “A”;“D”;”H”;”B”;”G”;”E” + */ + itemIds: number[]; + } + + /** + * Media event queue REMOVE request data. + */ + export class QueueRemoveRequestData extends RequestData { + constructor(itemIds: number[]); + + /** + * ID of the current media Item after the deletion (if not provided; the currentItem value will be the same as before the deletion; if it does not exist because it has been deleted; the currentItem will point to the next logical item in the list). + */ + currentItemId?: number; + + /** + * Seconds since the beginning of content to start playback of the current item. If provided; this value will take precedence over the startTime value provided at the QueueItem level but only the first time the item is played. This is to cover the common case where the user jumps to the middle of an item so the currentTime does not apply to the item permanently like the QueueItem startTime does. It avoids having to reset the startTime dynamically (that may not be possible if the phone has gone to sleep). + */ + currentTime?: number; + + /** + * IDs of queue items to be deleted. + */ + itemIds?: number[]; + } + /** + * Media event queue LOAD request data. + */ + export interface QueueLoadRequestData extends RequestData { + constructor(items: QueueItem[]): QueueLoadRequestData; + + /** + * Seconds (since the beginning of content) to start playback of the first item to be played. If provided; this value will take precedence over the startTime value provided at the QueueItem level but only the first time the item is played. This is to cover the common case where the user casts the item that was playing locally so the currentTime does not apply to the item permanently like the QueueItem startTime does. It avoids having to reset the startTime dynamically (that may not be possible if the phone has gone to sleep). + */ + currentTime?: number; + + /** + * Behavior of the queue when all items have been played. + */ + items: QueueItem[]; + + /** + * Id of the request; used to correlate request/response. + */ + repeatMode?: RepeatMode; + + /** + * The index of the item in the items array that must be the first currentItem (the item that will be played first). Note this is the index of the array (starts at 0) and not the itemId (as it is not known until the queue is created). If repeatMode is REPEAT_OFF playback will end when the last item in the array is played (elements before the startIndex will not be played). This may be useful for continuation scenarios where the user was already using the sender app and in the middle decides to cast. In this way the sender app does not need to map between the local and remote queue positions or saves one extra QUEUE_UPDATE request. + */ + startIndex?: number; + } + + /** + * Queue item information. Application developers may need to create a QueueItem to insert a queue element using InsertQueueItems. In this case they should not provide an itemId (as the actual itemId will be assigned when the item is inserted in the queue). This prevents ID collisions with items added from a sender app. + */ + export class QueueItem { + constructor(opt_itemId?: number); + + /** + * Array of Track trackIds that are active. If the array is not provided; the default tracks will be active. + */ + activeTrackIds?: number[]; + + /** + * If the autoplay parameter is not specified or is true; the media player will begin playing the element in the queue when the item becomes the currentItem. + */ + autoplay?: boolean; + + /** + * The application can define any extra queue item information needed. + */ + customData?: any; + + /** + * Unique identifier of the item in the queue. The attribute is optional because for LOAD or INSERT should not be provided (as it will be assigned by the receiver when an item is first created/inserted). + */ + itemId?: number; + + /** + * Metadata (including contentId) of the playlist element. + */ + media?: MediaInformation; + + /** + * Playback duration of the item; if it is larger than the actual duration - startTime it will be ignored (default behavior). It can be negative; in such case the duration will be the actual asset duration minus the duration provided. It can be used for photo slideshows to control the duration the item should be presented or for live events to control the duration that the program should be played. It may be useful for autoplay scenarios to avoid displaying all the credits after an episode has ended. + */ + playbackDuration?: number; + + /** + * This parameter is a hint for the receiver to preload this media item before it is played. It allows for a smooth transition between items played from the queue. The time is expressed in seconds; relative to the beginning of this item playback (usually the end of the previous item playback). Only positive values are valid. For example; if the value is 10 seconds; this item will be preloaded 10 seconds before the previous item has finished. The receiver will try to honor this value but will not guarantee it; for example if the value is larger than the previous item duration the receiver may just preload this item shortly after the previous item has started playing (there will never be two items being preloaded in parallel). Also; if an item is inserted in the queue just after the currentItem and the time to preload is higher than the time left on the currentItem; the preload will just happen as soon as possible. + */ + preloadTime?: number; + + /** + * Seconds since beginning of content. If the content is live content; and startTime is not specified; the stream will start at the live position. + */ + startTime?: number; + } + + /** + * Media event queue INSERT request data. + */ + export class QueueInsertRequestData extends RequestData { + constructor(items: QueueItem[]); + + /** + * ID of the current media Item after the insertion (if not provided; the currentItem value will be the same as before the insertion). + */ + currentItemId?: number; + + /** + * Index (relative to the items array; starting with 0) of the new current media Item. For inserted items we use the index (similar to startIndex in QUEUE_LOAD) and not currentItemId; because the itemId is unknown until the items are inserted. If not provided; the currentItem value will be the same as before the insertion (unless currentItemId is provided). This param allows to make atomic the common use case of insert and play an item. + */ + currentItemIndex?: number; + + /** + * Seconds since the beginning of content to start playback of the current item. If provided; this value will take precedence over the startTime value provided at the QueueItem level but only the first time the item is played. This is to cover the common case where the user jumps to the middle of an item so the currentTime does not apply to the item permanently like the QueueItem startTime does. It avoids having to reset the startTime dynamically (that may not be possible if the phone has gone to sleep). + */ + currentTime?: number; + + /** + * ID of the item that will be located immediately after the inserted list. If the ID is not found or it is not provided; the list will be appended at the end of the existing list. + */ + insertBefore?: number; + + /** + * List of queue items. The itemId field of the items should be empty. It is sorted (first element will be played first). + */ + items: QueueItem[]; + } + + /** + * Represents a data message containing the full list of queue ids. + */ + export interface QueueIds { + /** + * List of queue item ids. + */ + itemIds?: number[]; + + /** + * The corresponding request id. + */ + requestId?: number; + + /** + * + */ + type: MessageType; + } + + /** + * Queue data as part of the LOAD request. + */ + export class QueueData { + constructor( + id?: string, + name?: string, + description?: string, + repeatMode?: RepeatMode, + items?: QueueItem[], + startIndex?: number, + startTime?: number + ); + + /** + * Description of the queue. + */ + description?: string; + + /** + * Optional Queue entity id; provide Google Assistant deep link. + */ + entity?: string; + + /** + * Id of the queue. + */ + id?: string; + + /** + * Array of queue items. It is sorted (first element will be played first). + */ + items?: QueueItem[]; + + /** + * Name of the queue. + */ + name?: string; + + /** + * Queue type; e.g. album; playlist; radio station; tv series; etc. + */ + queueType?: QueueType; + + /** + * Continuous playback behavior of the queue. + */ + repeatMode?: RepeatMode; + + /** + * The index of the item in the queue that should be used to start playback first. + */ + startIndex?: number; + + /** + * Seconds (since the beginning of content) to start playback of the first item. + */ + startTime?: number; + } + + /** + * Represents a queue change message; such as insert; remove; and update. + */ + export interface QueueChange { + /** + * The actual queue change type. + */ + changeType?: QueueChangeType; + + /** + * The id to insert the list of itemIds before. + */ + insertBefore?: number; + + /** + * List of changed itemIds. + */ + itemIds?: number[]; + + /** + * The corresponding request id. + */ + requestId?: number; + + /** + * The queue change sequence ID. Used to coordinate state sync between various senders and the receiver. + */ + sequenceNumber?: number; + + /** + * + */ + type: MessageType; + } + + /** + * Media event PRELOAD request data. + */ + export class PreloadRequestData implements LoadRequestData { + /** + * Array of trackIds that are active. If the array is not provided; the default tracks will be active. + */ + activeTrackIds: number[]; + /** + * If the autoplay parameter is specified; the media player will begin playing the content when it is loaded. Even if autoplay is not specified;the media player implementation may choose to begin playback immediately. + */ + autoplay?: boolean; + /** + * Optional user credentials. + */ + credentials?: string; + /** + * Optional credentials type. The type 'cloud' is a reserved type used by load requests that were originated by voice assistant commands. + */ + credentialsType?: string; + /** + * Seconds since beginning of content. If the content is live content; and currentTime is not specified; the stream will start at the live position. + */ + currentTime?: number; + /** + * If the autoplay parameter is specified; the media player will begin playing the content when it is loaded. Even if autoplay is not specified; the media player implementation may choose to begin playback immediately. + */ + media: MediaInformation; + /** + * The media playback rate. + */ + playbackRate?: number; + /** + * Queue data. + */ + queueData: QueueData; + /** + * Application-specific data for this request. It enables the sender and receiver to easily extend the media protocol without having to use a new namespace with custom messages. + */ + customData?: any; + /** + * Id of the media session that the request applies to. + */ + mediaSessionId?: number; + /** + * Id of the request; used to correlate request/response. + */ + requestId: number; + constructor(itemId: number); + + /** + * The ID of the queue item. + */ + itemId: number; + } + + /** + * Media event PRECACHE request data. (Some fields of the load request; like autoplay and queueData; are ignored). + */ + export class PrecacheRequestData implements LoadRequestData { + /** + * Array of trackIds that are active. If the array is not provided; the default tracks will be active. + */ + activeTrackIds: number[]; + /** + * If the autoplay parameter is specified; the media player will begin playing the content when it is loaded. Even if autoplay is not specified;the media player implementation may choose to begin playback immediately. + */ + autoplay?: boolean; + /** + * Optional user credentials. + */ + credentials?: string; + /** + * Optional credentials type. The type 'cloud' is a reserved type used by load requests that were originated by voice assistant commands. + */ + credentialsType?: string; + /** + * Seconds since beginning of content. If the content is live content; and currentTime is not specified; the stream will start at the live position. + */ + currentTime?: number; + /** + * If the autoplay parameter is specified; the media player will begin playing the content when it is loaded. Even if autoplay is not specified; the media player implementation may choose to begin playback immediately. + */ + media: MediaInformation; + /** + * The media playback rate. + */ + playbackRate?: number; + /** + * Queue data. + */ + queueData: QueueData; + /** + * Application-specific data for this request. It enables the sender and receiver to easily extend the media protocol without having to use a new namespace with custom messages. + */ + customData?: any; + /** + * Id of the media session that the request applies to. + */ + mediaSessionId?: number; + /** + * Id of the request; used to correlate request/response. + */ + requestId: number; + constructor(data?: string); + + /** + * Application precache data. + */ + precacheData?: string; + } + + /** + * PlayString request data. + */ + export class PlayStringRequestData { + constructor(stringId: PlayStringId, opt_arguments?: string[]); + + /** + * An optional array of string values to be filled into the text. + */ + arguments?: string[]; + + /** + * An identifier for the text to be played back. + */ + stringId: PlayStringId; + } + + /** + * A photo media description. + */ + export interface PhotoMediaMetadata { + /** + * Name of the photographer. + */ + artist?: string; + + /** + * ISO 8601 date and time the photo was taken; e.g. 2014-02-10T15:47:00Z. + */ + creationDateTime?: string; + + /** + * Photo height; in pixels. + */ + height?: number; + + /** + * Images associated with the content. Examples would include a photo thumbnail. + */ + images: Image[]; + + /** + * Latitude. + */ + latitude?: number; + + /** + * Location where the photo was taken. For example; "Seattle; Washington; USA". + */ + location?: string; + + /** + * Longitude. + */ + longitude?: number; + + /** + * Photo title. + */ + title?: string; + + /** + * Photo width; in pixels. + */ + width?: number; + } + + /** + * A music track media description. + */ + export interface MusicTrackMediaMetadata { + /** + * Album artist name. + */ + albumArtist?: string; + + /** + * Album name. + */ + albumName?: string; + + /** + * Track artist name. + */ + artist?: string; + + /** + * @deprecated: use @see{@link artist} instead + */ + artistName: string; + + /** + * Track composer name. + */ + composer?: string; + + /** + * Disc number. A positive integer. + */ + discNumber?: number; + + /** + * Content images. Examples would include cover art or a thumbnail of the currently playing media. + */ + images: Image[]; + + /** + * ISO 8601 date when the track was released; e.g. 2014-02-10. + */ + releaseDate?: string; + + /** + * @deprecated: Use @see{@link releaseDate} instead + */ + releaseYear?: string; + + /** + * Track name. + */ + songName?: string; + + /** + * Track title. + */ + title?: string; + + /** + * Track number in album. A positive integer. + */ + trackNumber?: number; + } + + /** + * A movie media description. + */ + export interface MovieMediaMetadata { + /** + * Content images. Examples would include cover art or a thumbnail of the currently playing media. + */ + images: Image[]; + + /** + * ISO 8601 date when the movie was released; e.g. 2014-02-10. + */ + releaseDate?: string; + + /** + * @deprecated: use @see{@link releaseDate} instead + */ + releaseYear?: number; + + /** + * Movie studio. + */ + studio?: string; + + /** + * Movie subtitle. + */ + subtitle?: string; + + /** + * Movie title. + */ + title?: string; + } + /** + * Represents the status of a media session. + */ + export interface MediaStatus { + /** + * List of IDs corresponding to the active tracks. + */ + activeTrackIds: number[]; + + /** + * Status of break; if receiver is playing break. This field will be defined only when receiver is playing break. + */ + breakStatus: BreakStatus; + + /** + * ID of this media item (the item that originated the status change). + */ + currentItemId?: number; + + /** + * The current playback position. + */ + currentTime: number; + + /** + * Application-specific media status. + */ + customData?: any; + + /** + * Extended media status information. + */ + extendedStatus: ExtendedMediaStatus; + + /** + * If the state is IDLE; the reason the player went to IDLE state. + */ + idleReason: IdleReason; + + /** + * List of media queue items. + */ + items: QueueItem[]; + + /** + * Seekable range of a live or event stream. It uses relative media time in seconds. It will be undefined for VOD streams. + */ + liveSeekableRange: LiveSeekableRange; + + /** + * ID of the media Item currently loading. If there is no item being loaded; it will be undefined. + */ + loadingItemId?: number; + + /** + * The media information. + */ + media: MediaInformation; + + /** + * Unique id for the session. + */ + mediaSessionId: number; + + /** + * The playback rate. + */ + playbackRate: number; + + /** + * The playback state. + */ + playerState: PlayerState; + + /** + * ID of the next Item; only available if it has been preloaded. Media items can be preloaded and cached temporarily in memory; so when they are loaded later on; the process is faster (as the media does not have to be fetched from the network). + */ + preloadedItemId?: number; + + /** + * Queue data. + */ + queueData: QueueData; + + /** + * The behavior of the queue when all items have been played. + */ + repeatMode: RepeatMode; + + /** + * The commands supported by this player. + */ + supportedMediaCommands: number; + + /** + * + */ + type: MessageType; + + /** + * The video information. + */ + videoInfo: VideoInformation; + + /** + * The current stream volume. + */ + volume: Volume; + } + /** + * Common media metadata used as part of MediaInformation + */ + export class MediaMetadata { + constructor(type: MetadataType); + + /** + * The type of metadata + */ + metadataType: MetadataType; + } + + /** + * Represents the media information. + */ + export interface MediaInformation { + /** + * Partial list of break clips that includes current break clip that receiver is playing or ones that receiver will play shortly after; instead of sending whole list of clips. This is to avoid overflow of MediaStatus message. + */ + breakClips: BreakClip[]; + + /** + * List of breaks. + */ + breaks: Break[]; + + /** + * Typically the url of the media. + */ + contentId: string; + + /** + * The content MIME type. + */ + contentType: string; + + /** + * Optional media url; to allow using contentId for real id. If contentUrl is provided; it will be used as media url; otherwise the contentId will be used as the media url. + */ + contentUrl?: string; + + /** + * Application-specific media information. + */ + customData?: any; + + /** + * The media duration. + */ + duration?: number; + + /** + * Optional Media entity; provide Google Assistant deep link. + */ + entity?: string; + + /** + * The format of the HLS media segment. + */ + hlsSegmentFormat: HlsSegmentFormat; + + /** + * The media metadata. + */ + metadata: MediaMetadata; + + /** + * The stream type. + */ + streamType: StreamType; + + /** + * The style of text track. + */ + textTrackStyle: TextTrackStyle; + + /** + * The media tracks. + */ + tracks: Track[]; + } + + /** + * Media event LOAD request data. + */ + export interface LoadRequestData extends RequestData { + /** + * Array of trackIds that are active. If the array is not provided; the default tracks will be active. + */ + activeTrackIds: number[]; + + /** + * If the autoplay parameter is specified; the media player will begin playing the content when it is loaded. Even if autoplay is not specified;the media player implementation may choose to begin playback immediately. + */ + autoplay?: boolean; + + /** + * Optional user credentials. + */ + credentials?: string; + + /** + * Optional credentials type. The type 'cloud' is a reserved type used by load requests that were originated by voice assistant commands. + */ + credentialsType?: string; + + /** + * Seconds since beginning of content. If the content is live content; and currentTime is not specified; the stream will start at the live position. + */ + currentTime?: number; + + /** + * If the autoplay parameter is specified; the media player will begin playing the content when it is loaded. Even if autoplay is not specified; the media player implementation may choose to begin playback immediately. + */ + media: MediaInformation; + + /** + * The media playback rate. + */ + playbackRate?: number; + + /** + * Queue data. + */ + queueData: QueueData; + } + + /** + * LoadByEntity request data. + */ + export interface LoadByEntityRequestData { + /** + * Content entity information; typically represented by a stringified JSON object + */ + entity: string; + + /** + * Shuffle the items to play. + */ + shuffle?: boolean; + + /** + * Optional request source. It contain the assistent query that initiate the request. + */ + source?: string; + } + + /** + * Provides live seekable range with start and end time in seconds and two more attributes. + */ + export class LiveSeekableRange { + constructor( + start?: number, + end?: number, + isMovingWindow?: boolean, + isLiveDone?: boolean + ); + + /** + * A boolean value indicates whether a live stream is ended. If it is done; the end of live seekable range should stop updating. + */ + isLiveDone?: boolean; + + /** + * A boolean value indicates whether the live seekable range is a moving window. If false; it will be either a expanding range or a fixed range meaning live has ended. + */ + isMovingWindow?: boolean; + } + + /** + * Represents a data message containing item information for each requested ids. + */ + export interface ItemsInfo { + /** + * List of changed itemIds. + */ + items: QueueItem[]; + + /** + * The corresponding request id. + */ + requestId?: number; + + /** + * + */ + type: MessageType; + } + + /** + * An image that describes a receiver application or media item. + * This could be an application icon; cover art; or a thumbnail. + */ + export class Image { + constructor(url: string); + + /** + * The height of the image. + */ + height?: number; + + /** + * the URL to the image + */ + url: string; + + /** + * The width of the image + */ + width?: number; + } + /** Media event GET_STATUS request data. */ + export interface GetStatusRequestData extends RequestData { + /** + * The options of a GET_STATUS request. + */ + options: GetStatusOptions; + } + + /** + * Get items info request data. + */ + export interface GetItemsInfoRequestData extends RequestData { + constructor(itemIds: number[]): GetItemsInfoRequestData; + + /** + * List of item ids to be requested. + */ + itemIds: number[]; + } + /** + * A generic media description. + */ + export interface GenericMediaMetadata { + /** + * Content images. Examples would include cover art or a thumbnail of the currently playing media. + */ + images: Image[]; + + /** + * ISO 8601 date and/or time when the content was released; e.g. 2014-02-10. + */ + releaseDate?: string; + + /** + *@deprecated - use @see{@link releaseDate} instead + */ + releaseYear?: number; + + /** + * Content subtitle. + */ + subtitle?: string; + + /** + * Content title. + */ + title?: string; + } + + /** + * Focus state change message. + */ + export interface FocusStateRequestData { + /** + * The focus state of the app. + */ + state: FocusState; + } + + /** Fetch items request data. */ + export class FetchItemsRequestData extends RequestData { + constructor(itemId: number, nextCount: number, prevCount: number); + + /** + * ID of the reference media item for fetching more items. + */ + itemId: number; + + /** + * Number of items after the reference item to be fetched. + */ + nextCount: number; + + /** + * Number of items before the reference item to be fetched. + */ + prevCount: number; + } + + /** + * Extended media status information + */ + export class ExtendedMediaStatus { + constructor(playerState: MediaInformation, opt_media?: MediaInformation); + + /** + * + */ + media: MediaInformation; + + /** + * + */ + playerState: ExtendedPlayerState; + } + + /** Event data for @see{@link EventType.ERROR} event. */ + export class ErrorEvent { + constructor(detailedErrorCode?: DetailedErrorCode, error?: any); + /** + * An error code representing the cause of the error. + */ + detailedErrorCode?: DetailedErrorCode; + + /** + * The error object. + * This could be an Error object (e.g.; if an Error was thrown in an event handler) + * or an object with error information (e.g.; if the receiver received an invalid command). + */ + error?: any; + } + + export class ErrorData { + constructor(type: ErrorType); + + /** + * Application-specific data for this request. + * It enables the sender and receiver to easily extend the media protocol without having to use a new namespace with custom messages. + */ + customData?: any; + + /** + Id of the request; used to correlate request/response. + */ + requestId?: number; + } + + /** Media event EDIT_TRACKS_INFO request data. */ + export interface EditTracksInfoRequestData extends RequestData { + /** + * Array of the Track trackIds that should be active. + * If it is not provided; the active tracks will not change. + * If the array is empty; no track will be active. + */ + activeTrackIds?: number[]; + + /** + * Flag to enable or disable text tracks. + * If false it will disable all text tracks; + * if true it will enable the first text track; or the previous active text tracks. + * This flag is ignored if activeTrackIds or language is provided. + */ + enableTextTracks?: boolean; + + /** + * Indicates that the provided language was not explicit user request; but rather inferred from used language in voice query. + * It allows receiver apps to use user saved preference instead of spoken language. + */ + isSuggestedLanguage?: boolean; + + /** + * Language for the tracks that should be active. The language field will take precedence over activeTrackIds if both are specified. + */ + language?: string; + + /** + * + */ + textTrackStyle?: TextTrackStyle; + } + + /** + * Media event EDIT_AUDIO_TRACKS request data. If language is not provided; the default audio track for the media will be enabled. + */ + export interface EditAudioTracksRequestData extends RequestData { + /** + * Indicates that the provided language was not explicit user request; but rather inferred from used language in voice query. + * It allows receiver apps to use user saved preference instead of spoken language. + */ + isSuggestedLanguage?: boolean; + + /** + * + */ + language?: string; + } + + /** DisplayStatus request data. */ + export interface DisplayStatusRequestData { + /** + * Optional request source. It contain the assistent query that initiate the request. + */ + source: string; + } + + /** CustomCommand request data. */ + export interface CustomCommandRequestData { + /** + * Custom Data; typically represented by a stringified JSON object. + */ + data: string; + + /** + * Optional request source. It contain the assistent query that initiate the request. + */ + source: string; + } + /** Cloud media status. Media status that is only sent to the cloud sender. */ + export class CloudMediaStatus { + constructor(); + } + + export class BreakStatus { + constructor(currentBreakTime: number, currentBreakClipTime: number); + + /** + * Id of current break clip. + */ + breakClipId: string; + + /** + * Id of current break. + */ + breakId: string; + + /** + * Time in sec elapsed after current break clip starts. + */ + currentBreakClipTime: number; + + /** + * Time in sec elapsed after current break starts. + */ + currentBreakTime: number; + + /** + * The time in sec when this break clip becomes skippable. + * 5 means that end user can skip this break clip after 5 seconds. + * If this field is not defined; it means that current break clip is not skippable. + */ + whenSkippable: number; + } + + /** + * Represents break clip (e.g. a clip of ad during ad break) + */ + export class BreakClip { + constructor(id: string); + + /** + * Url of page that sender will display; when end user clicks link on sender UI; while receiver is playing this clip. + */ + clickThroughUrl?: string; + /** + * Typically the url of the break media (playing on the receiver). + */ + contentId?: string; + /** + * The content MIME type. + */ + contentType?: string; + /** + * Optional break media url; to allow using contentId for real id. + * If contentUrl is provided; it will be used as media url; otherwise the contentId will be used as the media url. + */ + contentUrl?: string; + /** + * Application-specific break clip data. + */ + customData?: any; + /** + * Duration of break clip in sec. + */ + duration?: number; + /** + * The format of the HLS media segment. + */ + hlsSegmentFormat: HlsSegmentFormat; + /** + * Unique id of break clip. + */ + id: string; + /** + * Url of content that sender will display while receiver is playing this clip. + */ + posterUrl?: string; + /** + * Title of break clip. Sender might display this on its screen; if provided. + */ + title?: string; + /** + * VAST ad request configuration. Used if contentId or contentUrl is not provided. + */ + vastAdsRequest: VastAdsRequest; + /** + * The time in sec when this break clip becomes skippable. + * 5 means that end user can skip this break clip after 5 seconds. + * If this field is not defined; it means that current break clip is not skippable. + */ + whenSkippable?: number; + } + + /** Represents break (e.g. ad break) included in main video. */ + export class Break { + constructor(id: string, breakClipIds: string[], position: number); + /** + * List of ids of break clip that this break includes. + */ + breakClipIds: string[]; + /** + * Duration of break in sec. + */ + duration?: number; + /** + * Unique id of break. + */ + id: string; + /** + * If true; indicates this is embedded break in main stream. + */ + isEmbedded?: boolean; + /** + * Whether break is watched. + * Sender can change color of progress bar marker corresponding to this break once this field changes from false to true; + * denoting that the end-user already watched this break. + */ + isWatched: boolean; + /** + * Where the break is located inside main video. -1 represents the end of main video. + */ + position: number; + } +} diff --git a/types/chromecast-caf-receiver/cast.framework.system.d.ts b/types/chromecast-caf-receiver/cast.framework.system.d.ts new file mode 100644 index 0000000000..1f465761b0 --- /dev/null +++ b/types/chromecast-caf-receiver/cast.framework.system.d.ts @@ -0,0 +1,177 @@ +// Type definitions for chromecast-caf-receiver 3.x +// Project: https://developers.google.com/cast/docs/reference/caf_receiver/ +// Definitions by: Craig Bruce https://github.com/craigrbruce +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// +/// +/// +/// +/// +/// + +import { EventType } from './cast.framework.events'; +export = cast.framework.system; + +declare namespace cast.framework.system { + export type SystemState = + | 'NOT_STARTED' + | 'STARTING_IN_BACKGROUND' + | 'STARTING' + | 'READY' + | 'STOPPING_IN_BACKGROUND' + | 'STOPPING'; + + export type StandbyState = 'STANDBY' | 'NOT_STANDBY' | 'UNKNOWN'; + + export type DisconnectReason = 'REQUESTED_BY_SENDER' | 'ERROR' | 'UNKNOWN'; + + /** + * Event dispatched by @see{@link CastReceiverManager} when the visibility of the application changes (HDMI input change; TV is turned off). + */ + export class VisibilityChangedEvent { + constructor(isVisible: boolean); + + /** + * Whether the Cast device is the active input or not. + */ + isVisible: boolean; + } + + /** + * Represents the system volume data. + */ + export interface SystemVolumeData { + /** + * The level (from 0.0 to 1.0) of the system volume. + */ + level: number; + + /** + * Whether the system volume is muted or not. + */ + muted: boolean; + } + /** + * Event dispatched by @see{CastReceiverManager} when the system volume changes. + */ + export class SystemVolumeChangedEvent extends Event { + constructor(volume: SystemVolumeData); + + /** + * The system volume data + */ + data: SystemVolumeData; + } + /** + * Event dispatched by @see{@link CastReceiverManager} when the TV enters/leaves the standby state. + */ + export class StandbyChangedEvent { + constructor(isStandby: boolean); + + /** + * + */ + isStandby: boolean; + } + /** + * Whether the TV is in standby or not. + */ + export interface ShutdownEvent extends Event {} + + /** + * Event dispatched by @see{@link CastReceiverManager} when a sender is disconnected. + */ + export class SenderDisconnectedEvent extends Event { + constructor(senderId: string, userAgent: string); + /** + * The ID of the sender connected. + */ + senderId: string; + + /** + * The user agent of the sender. + */ + userAgent: string; + + /** + * The reason the sender was disconnected. + */ + reason?: DisconnectReason; + } + + /** + * Event dispatched by @see{@link CastReceiverManager} when a sender is connected. + */ + export class SenderConnectedEvent extends Event { + constructor(senderId: string, userAgent: string); + /** + * The ID of the sender connected. + */ + senderId: string; + + /** + * The user agent of the sender. + */ + userAgent: string; + } + + /** + * Represents the data of a connected sender device. + */ + export interface Sender { + /** + * The sender Id. + */ + id: string; + + /** + * Indicate the sender supports large messages (>64KB). + */ + largeMessageSupported?: boolean; + + /** + * The userAgent of the sender. + */ + userAgent?: string; + } + + /** + * Event dispatched by CastReceiverManager when the system is ready. + */ + export class ReadyEvent { + constructor(applicationData: ApplicationData); + + /** + * The application data + */ + data: ApplicationData; + } + + /** + * Event dispatched by @see{@link CastReceiverManager} when the system needs to update the restriction on maximum video resolution. + */ + export class MaxVideoResolutionChangedEvent extends Event { + constructor(height: number); + + /** + * Maximum video resolution requested by the system. The value of 0 means there is no restriction. + */ + height: number; + } + /** Event dispatched by @see{@link CastReceiverManager} when the systems starts to create feedback report. */ + export interface FeedbackStartedEvent extends Event {} + /** Event dispatched by @see{@link CastReceiverContext} which contains system information. */ + export class Event { + constructor(type: EventType, data?: any); + } + + /** Represents the data of the launched application. */ + export interface ApplicationData { + id(): string; + launchingSenderId(): string; + name(): string; + namespaces(): string[]; + sessionId(): number; + } +} diff --git a/types/chromecast-caf-receiver/cast.framework.ui.d.ts b/types/chromecast-caf-receiver/cast.framework.ui.d.ts new file mode 100644 index 0000000000..fbc61f56d0 --- /dev/null +++ b/types/chromecast-caf-receiver/cast.framework.ui.d.ts @@ -0,0 +1,194 @@ +// Type definitions for chromecast-caf-receiver 3.x +// Project: https://developers.google.com/cast/docs/reference/caf_receiver/ +// Definitions by: Craig Bruce https://github.com/craigrbruce +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// +/// +/// +/// +/// +/// + +import { PlayerDataEventType } from './cast.framework.ui'; +import { MediaMetadata } from './cast.framework.messages'; + +export = cast.framework.ui; + +declare namespace cast.framework.ui { + export type ContentType = 'VIDEO' | 'AUDIO' | 'IMAGE'; + + export type State = + | 'LAUNCHING' + | 'IDLE' + | 'LOADING' + | 'BUFFERING' + | 'PAUSED' + | 'PLAYING'; + + export type PlayerDataEventType = + | 'ANY_CHANGE' + | 'STATE_CHANGED' + | 'IS_SEEKING_CHANGED' + | 'DURATION_CHANGED' + | 'CURRENT_TIME_CHANGED' + | 'METADATA_CHANGED' + | 'TITLE_CHANGED' + | 'SUBTITLE_CHANGED' + | 'THUMBNAIL_URL_CHANGED' + | 'NEXT_TITLE_CHANGED' + | 'NEXT_SUBTITLE_CHANGED' + | 'NEXT_THUMBNAIL_URL_CHANGED' + | 'PRELOADING_NEXT_CHANGED' + | 'CONTENT_TYPE_CHANGED' + | 'IS_LIVE_CHANGED' + | 'BREAK_PERCENTAGE_POSITIONS_CHANGED' + | 'IS_PLAYING_BREAK_CHANGED' + | 'IS_BREAK_SKIPPABLE_CHANGED' + | 'WHEN_SKIPPABLE_CHANGED' + | 'NUMBER_BREAK_CLIPS_CHANGED' + | 'CURRENT_BREAK_CLIP_NUMBER_CHANGED' + | 'DISPLAY_STATUS_CHANGED'; + + /** + * Player data changed event. Provides the changed field (type); and new value. + */ + export class PlayerDataChangedEvent { + constructor(type: PlayerDataEventType, field: string, value: any); + + /** + * The field name that was changed. + */ + field: string; + + /** + * + */ + type: PlayerDataEventType; + + /** + * The new field value. + */ + value: any; + } + /** + * Player data binder. Bind a player data object to the player state. The player data will be updated to reflect correctly the current player state without firing any change event. + */ + export class PlayerDataBinder { + constructor(playerData: PlayerData | any); + + /** + * Add listener to player data changes. + */ + // addEventListener: (type: PlayerDataEventType; listener: PlayerDataChangedEventHandler); + + /** + * Remove listener to player data changes. + */ + // removeEventListener: (type: PlayerDataEventType; listener: PlayerDataChangedEventHandler); + } + /** + * Player data. Provide the player media and break state. + */ + export interface PlayerData { + /** + * Array of breaks positions in percentage. + */ + breakPercentagePositions: number[]; + + /** + * Content Type. + */ + contentType: ContentType; + + /** + * The number of the current playing break clip in the break. + */ + currentBreakClipNumber: number; + + /** + * Media current position in seconds; or break current position if playing break. + */ + currentTime: number; + + /** + * Whether the player metadata (ie: title; currentTime) should be displayed. This will be true if at least one field in the metadata should be displayed. In some cases; displayStatus will be true; but parts of the metadata should be hidden (ie: the media title while media is seeking). In these cases; additional css can be applied to hide those elements. For cases where the media is audio-only; this will almost always be true. In cases where the media is video; this will be true when: (1) the video is loading; buffering; or seeking (2) a play request was made in the last five seconds while media is already playing; (3) there is a request made to show the status in the last five seconds; or (4) the media was paused in the last five seconds. + */ + displayStatus: boolean; + + /** + * Media duration in seconds; Or break duration if playing break. + */ + duration: number; + + /** + * Indicate break clip can be skipped. + */ + isBreakSkippable: boolean; + + /** + * Indicate if the content is a live stream. + */ + isLive: boolean; + + /** + * Indicate that the receiver is playing a break. + */ + isPlayingBreak: boolean; + + /** + * Indicate the player is seeking (can be either during playing or pausing). + */ + isSeeking: boolean; + + /** + * Media metadata. + */ + metadata: MediaMetadata | any; + + /** + * Next Item subtitle. + */ + nextSubtitle: string; + + /** + * Next Item thumbnail url. + */ + nextThumbnailUrl: string; + + /** + * Next Item title. + */ + nextTitle: string; + + /** + * Number of break clips in current break. + */ + numberBreakClips: number; + + /** + * Flag to show/hide next item metadata. + */ + preloadingNext: boolean; + + /** + * Current player state. + */ + state: State; + + /** + * Content thumbnail url. + */ + thumbnailUrl: string; + + /** + * Content title. + */ + title: string; + + /** + * Provide the time a break is skipable - relative to current playback time. Undefined if not skippable. + */ + whenSkippable?: number; + } +} diff --git a/types/chromecast-caf-receiver/chromecast-caf-receiver-tests.ts b/types/chromecast-caf-receiver/chromecast-caf-receiver-tests.ts new file mode 100644 index 0000000000..a4f59bd985 --- /dev/null +++ b/types/chromecast-caf-receiver/chromecast-caf-receiver-tests.ts @@ -0,0 +1,66 @@ +// Type definitions for chromecast-caf-receiver 3.x +// Project: https://developers.google.com/cast/docs/reference/caf_receiver/ +// Definitions by: Craig Bruce https://github.com/craigrbruce +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// +/// +/// +/// +/// +/// +/// + +import { TextTracksManager } from "cast.framework"; +import { StandbyChangedEvent } from "cast.framework.system"; +import { PlayerData, ContentType } from "cast.framework.ui"; +import { BreakManager } from "cast.framework.breaks"; +import { MediaStatusEvent } from "cast.framework.events"; +import { Track, Break, MediaStatus, QueueData } from "cast.framework.messages"; + +const ct = ContentType.VIDEO; +// framework tests +const track = new Track(123, {}); +const ttm = new TextTracksManager({}); +ttm.addTracks(track); + +// $ExpectError +ttm.addTracks("should fail"); + +// system tests +const sce = new StandbyChangedEvent(true); +// $ExpectError +const wrongSce = new StandbyChangedEvent("error"); + +const result: boolean = sce.isStandby; +// $ExpectError +const failure: string = sce.isStandby; + +// ui tests +const pd = new PlayerData(); + +const cn: number = pd.currentBreakClipNumber; +// $ExpectError +const wrongCn: boolean = pd.currentBreakClipNumber; + +// breaks tests +const bm: BreakManager = new BreakManager(); +const brk1: Break = bm.getBreakById("123"); +// $ExpectError +const brk2: string = bm.getBreakById("123"); +// $ExpectError +const brk3: Break = bm.getBreakById(123); +// events tests + +const evt: MediaStatusEvent = new MediaStatusEvent(); +const ms: MediaStatus = evt.mediaStatus; +// $ExpectError +const ms: string = evt.mediaStatus; + +// messages tests +const qd = new QueueData("id", "name", "description", "mode"); +// $ExpectError +const wrongQd = new QueueData({}); +const name: string = qd.name; +// $ExpectError +const wrongName: number = qd.name; diff --git a/types/chromecast-caf-receiver/index.d.ts b/types/chromecast-caf-receiver/index.d.ts new file mode 100644 index 0000000000..5dc89456e6 --- /dev/null +++ b/types/chromecast-caf-receiver/index.d.ts @@ -0,0 +1,25 @@ +// Type definitions for chromecast-caf-receiver 3.x +// Project: https://developers.google.com/cast/docs/reference/caf_receiver/ +// Definitions by: Craig Bruce https://github.com/craigrbruce +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// +/// +/// +/// +/// +/// + +import { PlayerDataChangedEvent } from './cast.framework.ui'; +import { NetworkRequestInfo } from './cast.framework'; +import { Event } from './cast.framework.events'; + +export = cast; +declare namespace cast { + export type EventHandler = (event: Event) => void; + export type PlayerDataChangedEventHandler = ( + event: PlayerDataChangedEvent + ) => void; + export type RequestHandler = (request: NetworkRequestInfo) => void; + export type BinaryHandler = (data: Uint8Array) => Uint8Array; +} diff --git a/types/chromecast-caf-receiver/tsconfig.json b/types/chromecast-caf-receiver/tsconfig.json new file mode 100644 index 0000000000..5c13aa8765 --- /dev/null +++ b/types/chromecast-caf-receiver/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "chromecast-caf-receiver-tests.ts" + ] +} diff --git a/types/chromecast-caf-receiver/tslint.json b/types/chromecast-caf-receiver/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/chromecast-caf-receiver/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From c64fec9022880267c4f47a5494b705b0c4226275 Mon Sep 17 00:00:00 2001 From: Craig Bruce Date: Thu, 31 May 2018 11:43:28 +1000 Subject: [PATCH 2/5] Fix all TSLint errors and begin first test --- .../cast.framework.breaks.d.ts | 20 +- .../cast.framework.d.ts | 89 ++-- .../cast.framework.events.d.ts | 325 ++++++------ .../cast.framework.messages.d.ts | 465 +++++++++--------- .../cast.framework.system.d.ts | 302 ++++++------ .../cast.framework.ui.d.ts | 99 ++-- .../chromecast-caf-receiver-tests.ts | 67 +-- types/chromecast-caf-receiver/index.d.ts | 21 +- types/chromecast-caf-receiver/tsconfig.json | 20 +- types/chromecast-caf-receiver/tslint.json | 9 +- 10 files changed, 673 insertions(+), 744 deletions(-) diff --git a/types/chromecast-caf-receiver/cast.framework.breaks.d.ts b/types/chromecast-caf-receiver/cast.framework.breaks.d.ts index 4fed094a12..309d87fd74 100644 --- a/types/chromecast-caf-receiver/cast.framework.breaks.d.ts +++ b/types/chromecast-caf-receiver/cast.framework.breaks.d.ts @@ -1,21 +1,9 @@ -// Type definitions for chromecast-caf-receiver 3.x -// Project: https://developers.google.com/cast/docs/reference/caf_receiver/ -// Definitions by: Craig Bruce https://github.com/craigrbruce -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// -/// -/// -/// -/// -/// - -import { Break, BreakClip } from './cast.framework.messages'; +import { Break, BreakClip } from "./cast.framework.messages"; export = cast.framework.breaks; declare namespace cast.framework.breaks { - export class BreakSeekData { + class BreakSeekData { constructor(seekFrom: number, seekTo: number, breaks: Break[]); /** @@ -35,7 +23,7 @@ declare namespace cast.framework.breaks { } /** Provide context information for break clip load interceptor. */ - export class BreakClipLoadInterceptorContext { + class BreakClipLoadInterceptorContext { constructor(brk: Break); /** @@ -45,7 +33,7 @@ declare namespace cast.framework.breaks { } /** Interface to manage breaks */ - export interface BreakManager { + interface BreakManager { /** * Get current media break by id. * @param {*} id diff --git a/types/chromecast-caf-receiver/cast.framework.d.ts b/types/chromecast-caf-receiver/cast.framework.d.ts index a22e9a24b9..1435859859 100644 --- a/types/chromecast-caf-receiver/cast.framework.d.ts +++ b/types/chromecast-caf-receiver/cast.framework.d.ts @@ -1,16 +1,4 @@ -// Type definitions for chromecast-caf-receiver 3.x -// Project: https://developers.google.com/cast/docs/reference/caf_receiver/ -// Definitions by: Craig Bruce https://github.com/craigrbruce -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// -/// -/// -/// -/// -/// - -import { EventType } from './cast.framework.events'; +import { EventType } from "./cast.framework.events"; import { PlayerState, PlayStringId, @@ -27,38 +15,35 @@ import { LiveSeekableRange, MediaInformation, ErrorData, - RequestData, -} from './cast.framework.messages'; -import { BreakManager } from './cast.framework.breaks'; -import { EventHandler, RequestHandler, BinaryHandler } from './cast'; + RequestData +} from "./cast.framework.messages"; +import { BreakManager } from "./cast.framework.breaks"; +import { EventHandler, RequestHandler, BinaryHandler } from "./index"; import { + EventType as SystemEventType, ApplicationData, Sender, StandbyState, - SystemState, -} from './cast.framework.system'; + SystemState +} from "./cast.framework.system"; export = cast.framework; - +type HTMLMediaElement = any; declare namespace cast.framework { - export type LoggerLevel = - | 'DEBUG' - | 'VERBOSE' - | 'INFO' - | 'WARNING' - | 'ERROR' - | 'NONE'; + type LoggerLevel = + | "DEBUG" + | "VERBOSE" + | "INFO" + | "WARNING" + | "ERROR" + | "NONE"; - export type ContentProtection = - | 'NONE' - | 'CLEARKEY' - | 'PLAYREADY' - | 'WIDEVINE'; + type ContentProtection = "NONE" | "CLEARKEY" | "PLAYREADY" | "WIDEVINE"; /** * Manages text tracks. */ - export class TextTracksManager { + class TextTracksManager { constructor(params: any); /** @@ -120,7 +105,7 @@ declare namespace cast.framework { /** * QueueManager exposes several queue manipulation APIs to developers. */ - export class QueueManager { + class QueueManager { constructor(params: any); /** @@ -162,7 +147,7 @@ declare namespace cast.framework { /** * Base implementation of a queue. */ - export class QueueBase { + class QueueBase { /** * Fetches a window of items using the specified item id as reference; called by the receiver MediaManager when it needs more queue items; often as a request from senders. If only one of nextCount and prevCount is non-zero; fetchItems should only return items after or before the reference item; if both nextCount and prevCount are non-zero; a window of items including the reference item should be returned. */ @@ -175,7 +160,9 @@ declare namespace cast.framework { /** * Initializes the queue with the requestData. This is called when a new LOAD request comes in to the receiver. If this returns or resolves to null; our default queueing implementation will create a queue based on queueData.items or the single media in the load request data. */ - initialize(requestData: LoadRequestData): QueueData | Promise; + initialize( + requestData: LoadRequestData + ): QueueData | Promise; /** * Returns next items after the reference item; often the end of the current queue; called by the receiver MediaManager. @@ -211,7 +198,7 @@ declare namespace cast.framework { /** * Controls and monitors media playback. */ - export class PlayerManager { + class PlayerManager { constructor(params: any); /** @@ -444,7 +431,7 @@ declare namespace cast.framework { /** * Configuration to customize playback behavior. */ - export class PlaybackConfig { + class PlaybackConfig { /** * Duration of buffered media in seconds to start buffering. */ @@ -523,7 +510,7 @@ declare namespace cast.framework { /** * HTTP(s) Request/Response information. */ - export class NetworkRequestInfo { + class NetworkRequestInfo { /** * The content of the request. Can be used to modify license request body. */ @@ -545,7 +532,7 @@ declare namespace cast.framework { withCredentials: boolean; } /** Cast receiver context options. All options are optionals. */ - export class CastReceiverOptions { + class CastReceiverOptions { /** * Optional map of custom messages namespaces to initialize and their types. * Custom messages namespaces need to be initiated before the application started; @@ -624,7 +611,7 @@ declare namespace cast.framework { } /** Manages loading of underlying libraries and initializes underlying cast receiver SDK. */ - export class CastReceiverContext { + class CastReceiverContext { /** Returns the CastReceiverContext singleton instance. */ static getInstance(): CastReceiverContext; @@ -633,12 +620,18 @@ declare namespace cast.framework { /** * Sets message listener on custom message channel. */ - addCustomMessageListener(namespace: string, listener: EventHandler): void; + addCustomMessageListener( + namespace: string, + listener: EventHandler + ): void; /** * Add listener to cast system events. */ - addEventListener(type: EventType, handler: EventHandler): void; + addEventListener( + type: SystemEventType | SystemEventType[], + handler: EventHandler + ): void; /** * Checks if the given media params of video or audio streams are supported by the platform. @@ -690,7 +683,7 @@ declare namespace cast.framework { /** * Reports if the cast application is the HDMI active input. */ - getVisibilityState(): VisibilityState; + getVisibilityState(): any; /** * When the application calls start; the system will send the ready event to indicate @@ -720,7 +713,11 @@ declare namespace cast.framework { /** * Sends a message to a specific sender. */ - sendCustomMessage(namespace: string, senderId: string, message: any): void; + sendCustomMessage( + namespace: string, + senderId: string, + message: any + ): void; /** * This function should be called in response to the feedbackstarted event if the application @@ -760,7 +757,7 @@ declare namespace cast.framework { } /** Manages audio tracks. */ - export class AudioTracksManager { + class AudioTracksManager { constructor(params: any); getActiveId(): number; getActiveTrack(): Track; diff --git a/types/chromecast-caf-receiver/cast.framework.events.d.ts b/types/chromecast-caf-receiver/cast.framework.events.d.ts index c5e2e71771..0ad1bfee8c 100644 --- a/types/chromecast-caf-receiver/cast.framework.events.d.ts +++ b/types/chromecast-caf-receiver/cast.framework.events.d.ts @@ -1,147 +1,135 @@ -// Type definitions for chromecast-caf-receiver 3.x -// Project: https://developers.google.com/cast/docs/reference/caf_receiver/ -// Definitions by: Craig Bruce https://github.com/craigrbruce -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// -/// -/// -/// -/// -/// - import { RequestData, MediaInformation, Track, - MediaStatus, -} from './cast.framework.messages'; + MediaStatus +} from "./cast.framework.messages"; export = cast.framework.events; declare namespace cast.framework.events { - export type EventType = - | 'ALL' - | 'ABORT' - | 'CAN_PLAY' - | 'CAN_PLAY_THROUGH' - | 'DURATION_CHANGE' - | 'EMPTIED' - | 'ENDED' - | 'LOADED_DATA' - | 'LOADED_METADATA' - | 'LOAD_START' - | 'PAUSE' - | 'PLAY' - | 'PLAYING' - | 'PROGRESS' - | 'RATE_CHANGE' - | 'SEEKED' - | 'SEEKING' - | 'STALLED' - | 'TIME_UPDATE' - | 'SUSPEND' - | 'WAITING' - | 'BITRATE_CHANGED' - | 'BREAK_STARTED' - | 'BREAK_ENDED' - | 'BREAK_CLIP_LOADING' - | 'BREAK_CLIP_STARTED' - | 'BREAK_CLIP_ENDED' - | 'BUFFERING' - | 'CACHE_LOADED' - | 'CACHE_HIT' - | 'CACHE_INSERTED' - | 'CLIP_STARTED' - | 'CLIP_ENDED' - | 'EMSG' - | 'ERROR' - | 'ID3' - | 'MEDIA_STATUS' - | 'MEDIA_FINISHED' - | 'PLAYER_PRELOADING' - | 'PLAYER_PRELOADING_CANCELLED' - | 'PLAYER_LOAD_COMPLETE' - | 'PLAYER_LOADING' - | 'SEGMENT_DOWNLOADED' - | 'REQUEST_SEEK' - | 'REQUEST_LOAD' - | 'REQUEST_STOP' - | 'REQUEST_PAUSE' - | 'REQUEST_PLAY' - | 'REQUEST_PLAY_AGAIN' - | 'REQUEST_PLAYBACK_RATE_CHANGE' - | 'REQUEST_SKIP_AD' - | 'REQUEST_VOLUME_CHANGE' - | 'REQUEST_EDIT_TRACKS_INFO' - | 'REQUEST_EDIT_AUDIO_TRACKS' - | 'REQUEST_SET_CREDENTIALS' - | 'REQUEST_LOAD_BY_ENTITY' - | 'REQUEST_USER_ACTION' - | 'REQUEST_DISPLAY_STATUS' - | 'REQUEST_CUSTOM_COMMAND' - | 'REQUEST_FOCUS_STATE' - | 'REQUEST_QUEUE_LOAD' - | 'REQUEST_QUEUE_INSERT' - | 'REQUEST_QUEUE_UPDATE' - | 'REQUEST_QUEUE_REMOVE' - | 'REQUEST_QUEUE_REORDER' - | 'REQUEST_QUEUE_GET_ITEM_RANGE' - | 'REQUEST_QUEUE_GET_ITEMS' - | 'REQUEST_QUEUE_GET_ITEM_IDS' - | 'REQUEST_PRECACHE'; + type EventType = + | "ALL" + | "ABORT" + | "CAN_PLAY" + | "CAN_PLAY_THROUGH" + | "DURATION_CHANGE" + | "EMPTIED" + | "ENDED" + | "LOADED_DATA" + | "LOADED_METADATA" + | "LOAD_START" + | "PAUSE" + | "PLAY" + | "PLAYING" + | "PROGRESS" + | "RATE_CHANGE" + | "SEEKED" + | "SEEKING" + | "STALLED" + | "TIME_UPDATE" + | "SUSPEND" + | "WAITING" + | "BITRATE_CHANGED" + | "BREAK_STARTED" + | "BREAK_ENDED" + | "BREAK_CLIP_LOADING" + | "BREAK_CLIP_STARTED" + | "BREAK_CLIP_ENDED" + | "BUFFERING" + | "CACHE_LOADED" + | "CACHE_HIT" + | "CACHE_INSERTED" + | "CLIP_STARTED" + | "CLIP_ENDED" + | "EMSG" + | "ERROR" + | "ID3" + | "MEDIA_STATUS" + | "MEDIA_FINISHED" + | "PLAYER_PRELOADING" + | "PLAYER_PRELOADING_CANCELLED" + | "PLAYER_LOAD_COMPLETE" + | "PLAYER_LOADING" + | "SEGMENT_DOWNLOADED" + | "REQUEST_SEEK" + | "REQUEST_LOAD" + | "REQUEST_STOP" + | "REQUEST_PAUSE" + | "REQUEST_PLAY" + | "REQUEST_PLAY_AGAIN" + | "REQUEST_PLAYBACK_RATE_CHANGE" + | "REQUEST_SKIP_AD" + | "REQUEST_VOLUME_CHANGE" + | "REQUEST_EDIT_TRACKS_INFO" + | "REQUEST_EDIT_AUDIO_TRACKS" + | "REQUEST_SET_CREDENTIALS" + | "REQUEST_LOAD_BY_ENTITY" + | "REQUEST_USER_ACTION" + | "REQUEST_DISPLAY_STATUS" + | "REQUEST_CUSTOM_COMMAND" + | "REQUEST_FOCUS_STATE" + | "REQUEST_QUEUE_LOAD" + | "REQUEST_QUEUE_INSERT" + | "REQUEST_QUEUE_UPDATE" + | "REQUEST_QUEUE_REMOVE" + | "REQUEST_QUEUE_REORDER" + | "REQUEST_QUEUE_GET_ITEM_RANGE" + | "REQUEST_QUEUE_GET_ITEMS" + | "REQUEST_QUEUE_GET_ITEM_IDS" + | "REQUEST_PRECACHE"; - export type DetailedErrorCode = - | 'MEDIA_UNKNOWN' - | 'MEDIA_ABORTED' - | 'MEDIA_DECODE' - | 'MEDIA_NETWORK' - | 'MEDIA_SRC_NOT_SUPPORTED' - | 'SOURCE_BUFFER_FAILURE' - | 'MEDIAKEYS_UNKNOWN' - | 'MEDIAKEYS_NETWORK' - | 'MEDIAKEYS_UNSUPPORTED' - | 'MEDIAKEYS_WEBCRYPTO' - | 'NETWORK_UNKNOWN' - | 'SEGMENT_NETWORK' - | 'HLS_NETWORK_MASTER_PLAYLIST' - | 'HLS_NETWORK_PLAYLIST' - | 'HLS_NETWORK_NO_KEY_RESPONSE' - | 'HLS_NETWORK_KEY_LOAD' - | 'HLS_NETWORK_INVALID_SEGMENT' - | 'HLS_SEGMENT_PARSING' - | 'DASH_NETWORK' - | 'DASH_NO_INIT' - | 'SMOOTH_NETWORK' - | 'SMOOTH_NO_MEDIA_DATA' - | 'MANIFEST_UNKNOWN' - | 'HLS_MANIFEST_MASTER' - | 'HLS_MANIFEST_PLAYLIST' - | 'DASH_MANIFEST_UNKNOWN' - | 'DASH_MANIFEST_NO_PERIODS' - | 'DASH_MANIFEST_NO_MIMETYPE' - | 'DASH_INVALID_SEGMENT_INFO' - | 'SMOOTH_MANIFEST' - | 'SEGMENT_UNKNOWN' - | 'TEXT_UNKNOWN' - | 'APP' - | 'BREAK_CLIP_LOADING_ERROR' - | 'BREAK_SEEK_INTERCEPTOR_ERROR' - | 'IMAGE_ERROR' - | 'LOAD_INTERRUPTED' - | 'GENERIC'; + type DetailedErrorCode = + | "MEDIA_UNKNOWN" + | "MEDIA_ABORTED" + | "MEDIA_DECODE" + | "MEDIA_NETWORK" + | "MEDIA_SRC_NOT_SUPPORTED" + | "SOURCE_BUFFER_FAILURE" + | "MEDIAKEYS_UNKNOWN" + | "MEDIAKEYS_NETWORK" + | "MEDIAKEYS_UNSUPPORTED" + | "MEDIAKEYS_WEBCRYPTO" + | "NETWORK_UNKNOWN" + | "SEGMENT_NETWORK" + | "HLS_NETWORK_MASTER_PLAYLIST" + | "HLS_NETWORK_PLAYLIST" + | "HLS_NETWORK_NO_KEY_RESPONSE" + | "HLS_NETWORK_KEY_LOAD" + | "HLS_NETWORK_INVALID_SEGMENT" + | "HLS_SEGMENT_PARSING" + | "DASH_NETWORK" + | "DASH_NO_INIT" + | "SMOOTH_NETWORK" + | "SMOOTH_NO_MEDIA_DATA" + | "MANIFEST_UNKNOWN" + | "HLS_MANIFEST_MASTER" + | "HLS_MANIFEST_PLAYLIST" + | "DASH_MANIFEST_UNKNOWN" + | "DASH_MANIFEST_NO_PERIODS" + | "DASH_MANIFEST_NO_MIMETYPE" + | "DASH_INVALID_SEGMENT_INFO" + | "SMOOTH_MANIFEST" + | "SEGMENT_UNKNOWN" + | "TEXT_UNKNOWN" + | "APP" + | "BREAK_CLIP_LOADING_ERROR" + | "BREAK_SEEK_INTERCEPTOR_ERROR" + | "IMAGE_ERROR" + | "LOAD_INTERRUPTED" + | "GENERIC"; - export type EndedReason = - | 'END_OF_STREAM' - | 'ERROR' - | 'STOPPED' - | 'INTERRUPTED' - | 'SKIPPED' - | 'BREAK_SWITCH'; + type EndedReason = + | "END_OF_STREAM" + | "ERROR" + | "STOPPED" + | "INTERRUPTED" + | "SKIPPED" + | "BREAK_SWITCH"; /** * Event data for @see{@link EventType.SEGMENT_DOWNLOADED} event. */ - export class SegmentDownloadedEvent { + class SegmentDownloadedEvent extends Event { constructor(downloadTime?: number, size?: number); /** @@ -158,8 +146,12 @@ declare namespace cast.framework.events { /** * Event data for all events that represent requests made to the receiver. */ - export class RequestEvent { - constructor(type: EventType, requestData?: RequestData, senderId?: string); + class RequestEvent extends Event { + constructor( + type: EventType, + requestData?: RequestData, + senderId?: string + ); /** * The data that was sent with the request. @@ -172,11 +164,22 @@ declare namespace cast.framework.events { senderId?: string; } + /** + * Event data superclass for all events dispatched by @see{@link PlayerManager} + */ + class Event { + constructor(type: EventType); + + /** + * Type of the event. + */ + type: EventType; + } /** * Event data for @see{@link EventType.MEDIA_STATUS} event. */ - export class MediaStatusEvent { - constructor(mediaStatus?: MediaStatus); + class MediaStatusEvent extends Event { + constructor(type: EventType, mediaStatus?: MediaStatus); /** * The media status that was sent. @@ -186,7 +189,7 @@ declare namespace cast.framework.events { /** * Event data for pause events forwarded from the MediaElement. */ - export class MediaPauseEvent { + class MediaPauseEvent extends Event { constructor(currentMediaTime?: number, ended?: boolean); /** @@ -197,7 +200,7 @@ declare namespace cast.framework.events { /** * Event data for @see{@link EventType.MEDIA_FINISHED} event. */ - export class MediaFinishedEvent { + class MediaFinishedEvent extends Event { constructor(currentMediaTime?: number, endedReason?: EndedReason); /** @@ -213,7 +216,7 @@ declare namespace cast.framework.events { /** * Event data for all events forwarded from the MediaElement. */ - export class MediaElementEvent { + class MediaElementEvent extends Event { constructor(type: EventType, currentMediaTime?: number); /** @@ -224,7 +227,7 @@ declare namespace cast.framework.events { /** * Event data for all events pertaining to processing a load / preload request. made to the player. */ - export class LoadEvent { + class LoadEvent extends Event { constructor(type: EventType, media?: MediaInformation); /** @@ -235,7 +238,7 @@ declare namespace cast.framework.events { /** * Event data for @see{@link EventType.INBAND_TRACK_ADDED} event. */ - export class InbandTrackAddedEvent { + class InbandTrackAddedEvent { constructor(track: Track); /** @@ -245,7 +248,7 @@ declare namespace cast.framework.events { } /** Event data for @see{@link EventType.ID3} event. */ - export class Id3Event { + class Id3Event extends Event { constructor(segmentData: Uint8Array); /** @@ -253,21 +256,10 @@ declare namespace cast.framework.events { */ segmentData: Uint8Array; } - /** - * Event data superclass for all events dispatched by @see{@link PlayerManager} - */ - export class Event { - constructor(type: EventType); - - /** - * Type of the event. - */ - type: EventType; - } /** * Event data for @see{@link EventType.EMSG} event. */ - export class EmsgEvent { + class EmsgEvent extends Event { constructor(emsgData: any); /** @@ -323,7 +315,7 @@ declare namespace cast.framework.events { /** * Event data for @see{@link EventType.CLIP_ENDED} event. */ - export class ClipEndedEvent { + class ClipEndedEvent extends Event { constructor(currentMediaTime: number, endedReason?: EndedReason); /** @@ -340,7 +332,7 @@ declare namespace cast.framework.events { /** * Event data for @see{@link EventType.CACHE_LOADED} event. */ - export class CacheLoadedEvent { + class CacheLoadedEvent extends Event { constructor(media?: MediaInformation); /** @@ -349,7 +341,7 @@ declare namespace cast.framework.events { media: MediaInformation; } - export class CacheItemEvent { + class CacheItemEvent extends Event { constructor(type: EventType, url: string); /** @@ -358,7 +350,7 @@ declare namespace cast.framework.events { url: string; } - export class BufferingEvent { + class BufferingEvent extends Event { constructor(isBuffering: boolean); /** @@ -367,7 +359,7 @@ declare namespace cast.framework.events { isBuffering: boolean; } - export class BreaksEvent { + class BreaksEvent extends Event { constructor( type: EventType, currentMediaTime?: number, @@ -381,17 +373,17 @@ declare namespace cast.framework.events { /** * The break clip's id. Refer to BreakClip.id */ - breakClipId: string; + breakClipId?: string; /** * The time in the currently playing media when the break event occurred. */ - currentMediaTime: string; + currentMediaTime?: string; /** * The reason the break clip ended. */ - endedReason: EndedReason; + endedReason?: EndedReason; /** * Index of break clip; which starts from 1. @@ -406,16 +398,23 @@ declare namespace cast.framework.events { /** * When to skip current break clip in sec; after break clip begins to play. */ - whenSkippable: number; + whenSkippable?: number; } /** * Event data for @see {@link EventType.BITRATE_CHANGED} event. */ - export class BitrateChangedEvent { + class BitrateChangedEvent { constructor(totalBitrate?: number); /** The bitrate of the media (audio and video) in bits per second. */ totalBitrate: number; } + + class ErrorEvent extends Event { + constructor(detailedErrorCode: DetailedErrorCode, error?: any); + + detailedErrorCode: DetailedErrorCode; + error?: any; + } } diff --git a/types/chromecast-caf-receiver/cast.framework.messages.d.ts b/types/chromecast-caf-receiver/cast.framework.messages.d.ts index dc5c1ac07b..311232e5e0 100644 --- a/types/chromecast-caf-receiver/cast.framework.messages.d.ts +++ b/types/chromecast-caf-receiver/cast.framework.messages.d.ts @@ -1,212 +1,202 @@ -// Type definitions for chromecast-caf-receiver 3.x -// Project: https://developers.google.com/cast/docs/reference/caf_receiver/ -// Definitions by: Craig Bruce https://github.com/craigrbruce -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// -/// -/// -/// -/// -/// - -import { DetailedErrorCode } from './cast.framework.events'; +import { Event, DetailedErrorCode } from "./cast.framework.events"; export = cast.framework.messages; declare namespace cast.framework.messages { - export type UserAction = - | 'LIKE' - | 'DISLIKE' - | 'FOLLOW' - | 'UNFOLLOW' - | 'FLAG' - | 'SKIP_AD'; + type UserAction = + | "LIKE" + | "DISLIKE" + | "FOLLOW" + | "UNFOLLOW" + | "FLAG" + | "SKIP_AD"; - export type UserActionContext = - | 'UNKNOWN_CONTEXT' - | 'ALBUM' - | 'ARTIST' - | 'PLAYLIST' - | 'EPISODE' - | 'SERIES' - | 'MOVIE' - | 'CHANNEL' - | 'TEAM' - | 'PLAYER' - | 'COACH'; + type UserActionContext = + | "UNKNOWN_CONTEXT" + | "ALBUM" + | "ARTIST" + | "PLAYLIST" + | "EPISODE" + | "SERIES" + | "MOVIE" + | "CHANNEL" + | "TEAM" + | "PLAYER" + | "COACH"; - export type TextTrackType = - | 'SUBTITLES' - | 'CAPTIONS' - | 'DESCRIPTIONS' - | 'CHAPTERS' - | 'METADATA'; + type TextTrackType = + | "SUBTITLES" + | "CAPTIONS" + | "DESCRIPTIONS" + | "CHAPTERS" + | "METADATA"; - export type TextTrackWindowType = 'NONE' | 'NORMAL' | 'ROUNDED_CORNERS'; + type TextTrackWindowType = "NONE" | "NORMAL" | "ROUNDED_CORNERS"; - export type TrackType = 'TEXT' | 'AUDIO' | 'VIDEO'; + type TrackType = "TEXT" | "AUDIO" | "VIDEO"; - export type TextTrackFontGenericFamily = - | 'SANS_SERIF' - | 'MONOSPACED_SANS_SERIF' - | 'SERIF' - | 'MONOSPACED_SERIF' - | 'CASUAL' - | 'CURSIVE' - | 'SMALL_CAPITALS'; + type TextTrackFontGenericFamily = + | "SANS_SERIF" + | "MONOSPACED_SANS_SERIF" + | "SERIF" + | "MONOSPACED_SERIF" + | "CASUAL" + | "CURSIVE" + | "SMALL_CAPITALS"; - export type TextTrackFontStyle = 'NORMAL' | 'BOLD' | 'BOLD_ITALIC' | 'ITALIC'; + type TextTrackFontStyle = "NORMAL" | "BOLD" | "BOLD_ITALIC" | "ITALIC"; - export type TextTrackEdgeType = - | 'NONE' - | 'OUTLINE' - | 'DROP_SHADOW' - | 'RAISED' - | 'DEPRESSED'; + type TextTrackEdgeType = + | "NONE" + | "OUTLINE" + | "DROP_SHADOW" + | "RAISED" + | "DEPRESSED"; - export type Command = - | 'PAUSE' - | 'SEEK' - | 'STREAM_VOLUME' - | 'STREAM_MUTE' - | 'ALL_BASIC_MEDIA' - | 'QUEUE_NEXT' - | 'QUEUE_PREV' - | 'QUEUE_SHUFFLE' - | 'SKIP_AD'; + type Command = + | "PAUSE" + | "SEEK" + | "STREAM_VOLUME" + | "STREAM_MUTE" + | "ALL_BASIC_MEDIA" + | "QUEUE_NEXT" + | "QUEUE_PREV" + | "QUEUE_SHUFFLE" + | "SKIP_AD"; - export type SeekResumeState = 'PLAYBACK_START' | 'PLAYBACK_PAUSE'; + type SeekResumeState = "PLAYBACK_START" | "PLAYBACK_PAUSE"; - export type StreamingProtocolType = - | 'UNKNOWN' - | 'MPEG_DASH' - | 'HLS' - | 'SMOOTH_STREAMING'; + type StreamingProtocolType = + | "UNKNOWN" + | "MPEG_DASH" + | "HLS" + | "SMOOTH_STREAMING"; - export type StreamType = 'BUFFERED' | 'LIVE' | 'NONE'; + type StreamType = "BUFFERED" | "LIVE" | "NONE"; - export type FocusState = 'IN_FOCUS' | 'NOT_IN_FOCUS'; + type FocusState = "IN_FOCUS" | "NOT_IN_FOCUS"; - export type ExtendedPlayerState = 'LOADING'; + type ExtendedPlayerState = "LOADING"; - export type ErrorType = - | 'INVALID_PLAYER_STATE' - | 'LOAD_FAILED' - | 'LOAD_CANCELLED' - | 'INVALID_REQUEST' - | 'ERROR'; + type ErrorType = + | "INVALID_PLAYER_STATE" + | "LOAD_FAILED" + | "LOAD_CANCELLED" + | "INVALID_REQUEST" + | "ERROR"; - export type ErrorReason = - | 'INVALID_COMMAND' - | 'INVALID_PARAMS' - | 'INVALID_MEDIA_SESSION_ID' - | 'SKIP_LIMIT_REACHED' - | 'NOT_SUPPORTED' - | 'LANGUAGE_NOT_SUPPORTED' - | 'END_OF_QUEUE' - | 'APP_ERROR' - | 'AUTHENTICATION_EXPIRED' - | 'PREMIUM_ACCOUNT_REQUIRED' - | 'CONCURRENT_STREAM_LIMIT' - | 'PARENTAL_CONTROL_RESTRICTED' - | 'NOT_AVAILABLE_IN_REGION' - | 'CONTENT_ALREADY_PLAYING' - | 'INVALID_REQUEST' - | 'GENERIC_LOAD_ERROR'; + type ErrorReason = + | "INVALID_COMMAND" + | "INVALID_PARAMS" + | "INVALID_MEDIA_SESSION_ID" + | "SKIP_LIMIT_REACHED" + | "NOT_SUPPORTED" + | "LANGUAGE_NOT_SUPPORTED" + | "END_OF_QUEUE" + | "APP_ERROR" + | "AUTHENTICATION_EXPIRED" + | "PREMIUM_ACCOUNT_REQUIRED" + | "CONCURRENT_STREAM_LIMIT" + | "PARENTAL_CONTROL_RESTRICTED" + | "NOT_AVAILABLE_IN_REGION" + | "CONTENT_ALREADY_PLAYING" + | "INVALID_REQUEST" + | "GENERIC_LOAD_ERROR"; - export type RepeatMode = - | 'REPEAT_OFF' - | 'REPEAT_ALL' - | 'REPEAT_SINGLE' - | 'REPEAT_ALL_AND_SHUFFLE'; + type RepeatMode = + | "REPEAT_OFF" + | "REPEAT_ALL" + | "REPEAT_SINGLE" + | "REPEAT_ALL_AND_SHUFFLE"; - export type IdleReason = 'CANCELLED' | 'INTERRUPTED' | 'FINISHED' | 'ERROR'; + type IdleReason = "CANCELLED" | "INTERRUPTED" | "FINISHED" | "ERROR"; - export type HlsSegmentFormat = 'AAC' | 'AC3' | 'MP3' | 'TS' | 'TS_AAC'; + type HlsSegmentFormat = "AAC" | "AC3" | "MP3" | "TS" | "TS_AAC"; - export type HdrType = 'SDR' | 'HDR' | 'DV'; + type HdrType = "SDR" | "HDR" | "DV"; - export type PlayStringId = - | 'FREE_TRIAL_ABOUT_TO_EXPIRE' - | 'SUBSCRIPTION_ABOUT_TO_EXPIRE' - | 'STREAM_HIJACKED'; + type PlayStringId = + | "FREE_TRIAL_ABOUT_TO_EXPIRE" + | "SUBSCRIPTION_ABOUT_TO_EXPIRE" + | "STREAM_HIJACKED"; - export type GetStatusOptions = 'NO_METADATA' | 'NO_QUEUE_ITEMS'; + type GetStatusOptions = "NO_METADATA" | "NO_QUEUE_ITEMS"; - export type MessageType = - | 'MEDIA_STATUS' - | 'CLOUD_STATUS' - | 'QUEUE_CHANGE' - | 'QUEUE_ITEMS' - | 'QUEUE_ITEM_IDS' - | 'GET_STATUS' - | 'LOAD' - | 'PAUSE' - | 'STOP' - | 'PLAY' - | 'SKIP_AD' - | 'PLAY_AGAIN' - | 'SEEK' - | 'SET_PLAYBACK_RATE' - | 'SET_VOLUME' - | 'EDIT_TRACKS_INFO' - | 'EDIT_AUDIO_TRACKS' - | 'PRECACHE' - | 'PRELOAD' - | 'QUEUE_LOAD' - | 'QUEUE_INSERT' - | 'QUEUE_UPDATE' - | 'QUEUE_REMOVE' - | 'QUEUE_REORDER' - | 'QUEUE_NEXT' - | 'QUEUE_PREV' - | 'QUEUE_GET_ITEM_RANGE' - | 'QUEUE_GET_ITEMS' - | 'QUEUE_GET_ITEM_IDS' - | 'QUEUE_SHUFFLE' - | 'SET_CREDENTIALS' - | 'LOAD_BY_ENTITY' - | 'USER_ACTION' - | 'DISPLAY_STATUS' - | 'FOCUS_STATE' - | 'CUSTOM_COMMAND'; + type MessageType = + | "MEDIA_STATUS" + | "CLOUD_STATUS" + | "QUEUE_CHANGE" + | "QUEUE_ITEMS" + | "QUEUE_ITEM_IDS" + | "GET_STATUS" + | "LOAD" + | "PAUSE" + | "STOP" + | "PLAY" + | "SKIP_AD" + | "PLAY_AGAIN" + | "SEEK" + | "SET_PLAYBACK_RATE" + | "SET_VOLUME" + | "EDIT_TRACKS_INFO" + | "EDIT_AUDIO_TRACKS" + | "PRECACHE" + | "PRELOAD" + | "QUEUE_LOAD" + | "QUEUE_INSERT" + | "QUEUE_UPDATE" + | "QUEUE_REMOVE" + | "QUEUE_REORDER" + | "QUEUE_NEXT" + | "QUEUE_PREV" + | "QUEUE_GET_ITEM_RANGE" + | "QUEUE_GET_ITEMS" + | "QUEUE_GET_ITEM_IDS" + | "QUEUE_SHUFFLE" + | "SET_CREDENTIALS" + | "LOAD_BY_ENTITY" + | "USER_ACTION" + | "DISPLAY_STATUS" + | "FOCUS_STATE" + | "CUSTOM_COMMAND"; - export type PlayerState = 'IDLE' | 'PLAYING' | 'PAUSED' | 'BUFFERING'; + type PlayerState = "IDLE" | "PLAYING" | "PAUSED" | "BUFFERING"; - export type QueueChangeType = - | 'INSERT' - | 'REMOVE' - | 'ITEMS_CHANGE' - | 'UPDATE' - | 'NO_CHANGE'; + type QueueChangeType = + | "INSERT" + | "REMOVE" + | "ITEMS_CHANGE" + | "UPDATE" + | "NO_CHANGE"; - export type QueueType = - | 'ALBUM' - | 'PLAYLIST' - | 'AUDIOBOOK' - | 'RADIO_STATION' - | 'PODCAST_SERIES' - | 'TV_SERIES' - | 'VIDEO_PLAYLIST' - | 'LIVE_TV' - | 'MOVIE'; + type QueueType = + | "ALBUM" + | "PLAYLIST" + | "AUDIOBOOK" + | "RADIO_STATION" + | "PODCAST_SERIES" + | "TV_SERIES" + | "VIDEO_PLAYLIST" + | "LIVE_TV" + | "MOVIE"; - export type MetadataType = - | 'GENERIC' - | 'MOVIE' - | 'TV_SHOW' - | 'MUSIC_TRACK' - | 'PHOTO'; + type MetadataType = + | "GENERIC" + | "MOVIE" + | "TV_SHOW" + | "MUSIC_TRACK" + | "PHOTO"; /** * RefreshCredentials request data. */ - export interface RefreshCredentialsRequestData { } + interface RefreshCredentialsRequestData { + [key: string]: any; + } /** * Media event SET_VOLUME request data. */ - export interface VolumeRequestData extends RequestData { + interface VolumeRequestData extends RequestData { /** * The media stream volume */ @@ -216,7 +206,7 @@ declare namespace cast.framework.messages { /** * Represents the volume of a media session stream. */ - export interface Volume { + interface Volume { /** * Value from 0 to 1 that represents the current stream volume level. */ @@ -231,7 +221,7 @@ declare namespace cast.framework.messages { /** * Video information such as video resolution and High Dynamic Range (HDR). */ - export class VideoInformation { + class VideoInformation { constructor(width: number, height: number, hdrType: HdrType); /** @@ -253,7 +243,7 @@ declare namespace cast.framework.messages { /** * VAST ad request configuration. */ - export interface VastAdsRequest { + interface VastAdsRequest { /** * Specifies a VAST document to be used as the ads response instead of making a request via an ad tag url. This can be useful for debugging and other situations where a VAST response is already available. */ @@ -268,7 +258,7 @@ declare namespace cast.framework.messages { /** * UserAction request data. */ - export interface UserActionRequestData { + interface UserActionRequestData { /** * Optional request source. It contain the assistent query that initiate the request. */ @@ -288,7 +278,7 @@ declare namespace cast.framework.messages { /** * A TV episode media description. */ - export interface TvShowMediaMetadata { + interface TvShowMediaMetadata { /** * TV episode number. A positive integer. */ @@ -342,7 +332,7 @@ declare namespace cast.framework.messages { /** * Describes track metadata information. */ - export class Track { + class Track { constructor(trackId: number, trackType: TrackType); /** @@ -388,7 +378,7 @@ declare namespace cast.framework.messages { /** * Describes style information for a text track. */ - export interface TextTrackStyle { + interface TextTrackStyle { /** * The background 32 bit RGBA color. The alpha channel should be used for transparent backgrounds. */ @@ -453,7 +443,7 @@ declare namespace cast.framework.messages { /** * Media event playback rate request data. */ - export interface SetPlaybackRateRequestData extends RequestData { + interface SetPlaybackRateRequestData extends RequestData { /** * New playback rate (>0). */ @@ -468,7 +458,7 @@ declare namespace cast.framework.messages { /** * SetCredentials request data. */ - export interface SetCredentialsRequestData { + interface SetCredentialsRequestData { /** * Credentials to use by receiver. */ @@ -488,7 +478,7 @@ declare namespace cast.framework.messages { /** * Media event SEEK request data. */ - export interface SeekRequestData extends RequestData { + interface SeekRequestData extends RequestData { /** * Seconds since beginning of content. */ @@ -508,7 +498,7 @@ declare namespace cast.framework.messages { /** * Provides seekable range in seconds. */ - export class SeekableRange { + class SeekableRange { constructor(start?: number, end?: number); /** @@ -525,7 +515,7 @@ declare namespace cast.framework.messages { /** * Media event request data. */ - export class RequestData { + class RequestData { constructor(type: MessageType); /** @@ -547,7 +537,7 @@ declare namespace cast.framework.messages { /** * Media event UPDATE queue request data. */ - export interface QueueUpdateRequestData { + interface QueueUpdateRequestData { /** * ID of the current media Item after the deletion (if not provided; the currentItem value will be the same as before the deletion; if it does not exist because it has been deleted; the currentItem will point to the next logical item in the list). */ @@ -582,7 +572,7 @@ declare namespace cast.framework.messages { /** * Media event queue REORDER request data. */ - export class QueueReorderRequestData extends RequestData { + class QueueReorderRequestData extends RequestData { constructor(itemIds: number[]); /** @@ -601,21 +591,21 @@ declare namespace cast.framework.messages { insertBefore?: number; /** - * IDs of the items to be reordered; in the new order. Items not provided will keep their existing order. The provided list will be inserted at the position determined by insertBefore. For example: + * IDs of the items to be reordered; in the new order. Items not provided will keep their existing order. The provided list will be inserted at the position determined by insertBefore. For example: - If insertBefore is not specified Existing queue: “A”;”D”;”G”;”H”;”B”;”E” itemIds: “D”;”H”;”B” New Order: “A”;”G”;”E”;“D”;”H”;”B” + If insertBefore is not specified Existing queue: “A”;”D”;”G”;”H”;”B”;”E” itemIds: “D”;”H”;”B” New Order: “A”;”G”;”E”;“D”;”H”;”B” - If insertBefore is “A” Existing queue: “A”;”D”;”G”;”H”;”B” itemIds: “D”;”H”;”B” New Order: “D”;”H”;”B”;“A”;”G”;”E” + If insertBefore is “A” Existing queue: “A”;”D”;”G”;”H”;”B” itemIds: “D”;”H”;”B” New Order: “D”;”H”;”B”;“A”;”G”;”E” - If insertBefore is “G” Existing queue: “A”;”D”;”G”;”H”;”B” itemIds: “D”;”H”;”B” New Order: “A”;“D”;”H”;”B”;”G”;”E” - */ + If insertBefore is “G” Existing queue: “A”;”D”;”G”;”H”;”B” itemIds: “D”;”H”;”B” New Order: “A”;“D”;”H”;”B”;”G”;”E” + */ itemIds: number[]; } /** * Media event queue REMOVE request data. */ - export class QueueRemoveRequestData extends RequestData { + class QueueRemoveRequestData extends RequestData { constructor(itemIds: number[]); /** @@ -636,8 +626,8 @@ declare namespace cast.framework.messages { /** * Media event queue LOAD request data. */ - export interface QueueLoadRequestData extends RequestData { - constructor(items: QueueItem[]): QueueLoadRequestData; + class QueueLoadRequestData extends RequestData { + constructor(items: QueueItem[]); /** * Seconds (since the beginning of content) to start playback of the first item to be played. If provided; this value will take precedence over the startTime value provided at the QueueItem level but only the first time the item is played. This is to cover the common case where the user casts the item that was playing locally so the currentTime does not apply to the item permanently like the QueueItem startTime does. It avoids having to reset the startTime dynamically (that may not be possible if the phone has gone to sleep). @@ -663,7 +653,7 @@ declare namespace cast.framework.messages { /** * Queue item information. Application developers may need to create a QueueItem to insert a queue element using InsertQueueItems. In this case they should not provide an itemId (as the actual itemId will be assigned when the item is inserted in the queue). This prevents ID collisions with items added from a sender app. */ - export class QueueItem { + class QueueItem { constructor(opt_itemId?: number); /** @@ -710,7 +700,7 @@ declare namespace cast.framework.messages { /** * Media event queue INSERT request data. */ - export class QueueInsertRequestData extends RequestData { + class QueueInsertRequestData extends RequestData { constructor(items: QueueItem[]); /** @@ -742,7 +732,7 @@ declare namespace cast.framework.messages { /** * Represents a data message containing the full list of queue ids. */ - export interface QueueIds { + interface QueueIds { /** * List of queue item ids. */ @@ -762,7 +752,7 @@ declare namespace cast.framework.messages { /** * Queue data as part of the LOAD request. */ - export class QueueData { + class QueueData { constructor( id?: string, name?: string, @@ -822,7 +812,7 @@ declare namespace cast.framework.messages { /** * Represents a queue change message; such as insert; remove; and update. */ - export interface QueueChange { + interface QueueChange { /** * The actual queue change type. */ @@ -857,7 +847,7 @@ declare namespace cast.framework.messages { /** * Media event PRELOAD request data. */ - export class PreloadRequestData implements LoadRequestData { + class PreloadRequestData implements LoadRequestData { /** * Array of trackIds that are active. If the array is not provided; the default tracks will be active. */ @@ -913,7 +903,7 @@ declare namespace cast.framework.messages { /** * Media event PRECACHE request data. (Some fields of the load request; like autoplay and queueData; are ignored). */ - export class PrecacheRequestData implements LoadRequestData { + class PrecacheRequestData implements LoadRequestData { /** * Array of trackIds that are active. If the array is not provided; the default tracks will be active. */ @@ -969,7 +959,7 @@ declare namespace cast.framework.messages { /** * PlayString request data. */ - export class PlayStringRequestData { + class PlayStringRequestData { constructor(stringId: PlayStringId, opt_arguments?: string[]); /** @@ -986,7 +976,7 @@ declare namespace cast.framework.messages { /** * A photo media description. */ - export interface PhotoMediaMetadata { + interface PhotoMediaMetadata { /** * Name of the photographer. */ @@ -1036,7 +1026,7 @@ declare namespace cast.framework.messages { /** * A music track media description. */ - export interface MusicTrackMediaMetadata { + interface MusicTrackMediaMetadata { /** * Album artist name. */ @@ -1101,7 +1091,7 @@ declare namespace cast.framework.messages { /** * A movie media description. */ - export interface MovieMediaMetadata { + interface MovieMediaMetadata { /** * Content images. Examples would include cover art or a thumbnail of the currently playing media. */ @@ -1135,7 +1125,7 @@ declare namespace cast.framework.messages { /** * Represents the status of a media session. */ - export interface MediaStatus { + interface MediaStatus { /** * List of IDs corresponding to the active tracks. */ @@ -1244,7 +1234,7 @@ declare namespace cast.framework.messages { /** * Common media metadata used as part of MediaInformation */ - export class MediaMetadata { + class MediaMetadata { constructor(type: MetadataType); /** @@ -1256,7 +1246,7 @@ declare namespace cast.framework.messages { /** * Represents the media information. */ - export interface MediaInformation { + interface MediaInformation { /** * Partial list of break clips that includes current break clip that receiver is playing or ones that receiver will play shortly after; instead of sending whole list of clips. This is to avoid overflow of MediaStatus message. */ @@ -1326,7 +1316,7 @@ declare namespace cast.framework.messages { /** * Media event LOAD request data. */ - export interface LoadRequestData extends RequestData { + interface LoadRequestData extends RequestData { /** * Array of trackIds that are active. If the array is not provided; the default tracks will be active. */ @@ -1371,7 +1361,7 @@ declare namespace cast.framework.messages { /** * LoadByEntity request data. */ - export interface LoadByEntityRequestData { + interface LoadByEntityRequestData { /** * Content entity information; typically represented by a stringified JSON object */ @@ -1391,7 +1381,7 @@ declare namespace cast.framework.messages { /** * Provides live seekable range with start and end time in seconds and two more attributes. */ - export class LiveSeekableRange { + class LiveSeekableRange { constructor( start?: number, end?: number, @@ -1413,7 +1403,7 @@ declare namespace cast.framework.messages { /** * Represents a data message containing item information for each requested ids. */ - export interface ItemsInfo { + interface ItemsInfo { /** * List of changed itemIds. */ @@ -1434,7 +1424,7 @@ declare namespace cast.framework.messages { * An image that describes a receiver application or media item. * This could be an application icon; cover art; or a thumbnail. */ - export class Image { + class Image { constructor(url: string); /** @@ -1453,7 +1443,7 @@ declare namespace cast.framework.messages { width?: number; } /** Media event GET_STATUS request data. */ - export interface GetStatusRequestData extends RequestData { + interface GetStatusRequestData extends RequestData { /** * The options of a GET_STATUS request. */ @@ -1463,8 +1453,8 @@ declare namespace cast.framework.messages { /** * Get items info request data. */ - export interface GetItemsInfoRequestData extends RequestData { - constructor(itemIds: number[]): GetItemsInfoRequestData; + class GetItemsInfoRequestData extends RequestData { + constructor(itemIds: number[]); /** * List of item ids to be requested. @@ -1474,7 +1464,7 @@ declare namespace cast.framework.messages { /** * A generic media description. */ - export interface GenericMediaMetadata { + interface GenericMediaMetadata extends MediaMetadata { /** * Content images. Examples would include cover art or a thumbnail of the currently playing media. */ @@ -1504,7 +1494,7 @@ declare namespace cast.framework.messages { /** * Focus state change message. */ - export interface FocusStateRequestData { + interface FocusStateRequestData { /** * The focus state of the app. */ @@ -1512,7 +1502,7 @@ declare namespace cast.framework.messages { } /** Fetch items request data. */ - export class FetchItemsRequestData extends RequestData { + class FetchItemsRequestData extends RequestData { constructor(itemId: number, nextCount: number, prevCount: number); /** @@ -1534,8 +1524,11 @@ declare namespace cast.framework.messages { /** * Extended media status information */ - export class ExtendedMediaStatus { - constructor(playerState: MediaInformation, opt_media?: MediaInformation); + class ExtendedMediaStatus { + constructor( + playerState: MediaInformation, + opt_media?: MediaInformation + ); /** * @@ -1549,7 +1542,7 @@ declare namespace cast.framework.messages { } /** Event data for @see{@link EventType.ERROR} event. */ - export class ErrorEvent { + class ErrorEvent extends Event { constructor(detailedErrorCode?: DetailedErrorCode, error?: any); /** * An error code representing the cause of the error. @@ -1564,7 +1557,7 @@ declare namespace cast.framework.messages { error?: any; } - export class ErrorData { + class ErrorData { constructor(type: ErrorType); /** @@ -1574,13 +1567,13 @@ declare namespace cast.framework.messages { customData?: any; /** - Id of the request; used to correlate request/response. - */ + Id of the request; used to correlate request/response. + */ requestId?: number; } /** Media event EDIT_TRACKS_INFO request data. */ - export interface EditTracksInfoRequestData extends RequestData { + interface EditTracksInfoRequestData extends RequestData { /** * Array of the Track trackIds that should be active. * If it is not provided; the active tracks will not change. @@ -1616,7 +1609,7 @@ declare namespace cast.framework.messages { /** * Media event EDIT_AUDIO_TRACKS request data. If language is not provided; the default audio track for the media will be enabled. */ - export interface EditAudioTracksRequestData extends RequestData { + interface EditAudioTracksRequestData extends RequestData { /** * Indicates that the provided language was not explicit user request; but rather inferred from used language in voice query. * It allows receiver apps to use user saved preference instead of spoken language. @@ -1630,7 +1623,7 @@ declare namespace cast.framework.messages { } /** DisplayStatus request data. */ - export interface DisplayStatusRequestData { + interface DisplayStatusRequestData { /** * Optional request source. It contain the assistent query that initiate the request. */ @@ -1638,7 +1631,7 @@ declare namespace cast.framework.messages { } /** CustomCommand request data. */ - export interface CustomCommandRequestData { + interface CustomCommandRequestData { /** * Custom Data; typically represented by a stringified JSON object. */ @@ -1649,12 +1642,8 @@ declare namespace cast.framework.messages { */ source: string; } - /** Cloud media status. Media status that is only sent to the cloud sender. */ - export class CloudMediaStatus { - constructor(); - } - export class BreakStatus { + class BreakStatus { constructor(currentBreakTime: number, currentBreakClipTime: number); /** @@ -1688,7 +1677,7 @@ declare namespace cast.framework.messages { /** * Represents break clip (e.g. a clip of ad during ad break) */ - export class BreakClip { + class BreakClip { constructor(id: string); /** @@ -1719,7 +1708,7 @@ declare namespace cast.framework.messages { /** * The format of the HLS media segment. */ - hlsSegmentFormat: HlsSegmentFormat; + hlsSegmentFormat?: HlsSegmentFormat; /** * Unique id of break clip. */ @@ -1735,7 +1724,7 @@ declare namespace cast.framework.messages { /** * VAST ad request configuration. Used if contentId or contentUrl is not provided. */ - vastAdsRequest: VastAdsRequest; + vastAdsRequest?: VastAdsRequest; /** * The time in sec when this break clip becomes skippable. * 5 means that end user can skip this break clip after 5 seconds. @@ -1745,7 +1734,7 @@ declare namespace cast.framework.messages { } /** Represents break (e.g. ad break) included in main video. */ - export class Break { + class Break { constructor(id: string, breakClipIds: string[], position: number); /** * List of ids of break clip that this break includes. diff --git a/types/chromecast-caf-receiver/cast.framework.system.d.ts b/types/chromecast-caf-receiver/cast.framework.system.d.ts index 1f465761b0..92e7732f7f 100644 --- a/types/chromecast-caf-receiver/cast.framework.system.d.ts +++ b/types/chromecast-caf-receiver/cast.framework.system.d.ts @@ -1,177 +1,191 @@ -// Type definitions for chromecast-caf-receiver 3.x -// Project: https://developers.google.com/cast/docs/reference/caf_receiver/ -// Definitions by: Craig Bruce https://github.com/craigrbruce -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// -/// -/// -/// -/// -/// - -import { EventType } from './cast.framework.events'; +import { EventType } from "./cast.framework.events"; export = cast.framework.system; declare namespace cast.framework.system { - export type SystemState = - | 'NOT_STARTED' - | 'STARTING_IN_BACKGROUND' - | 'STARTING' - | 'READY' - | 'STOPPING_IN_BACKGROUND' - | 'STOPPING'; + type EventType = + // Fired when the system is ready. + | "READY" + // Fired when the application is terminated. + | "SHUTDOWN" + // Fired when a new sender has connected. + | "SENDER_CONNECTED" + // Fired when a sender has disconnected. + | "SENDER_DISCONNECTED" + // Fired when there is a system error. + | "ERROR" + // Fired when the system volume has changed. + | "SYSTEM_VOLUME_CHANGED" + // Fired when the visibility of the application has changed (for example after a HDMI Input change or when the TV is turned off/on and the cast device is externally powered). Note that this API has the same effect as the webkitvisibilitychange event raised by your document, we provided it as CastReceiverManager API for convenience and to avoid a dependency on a webkit-prefixed event. + | "VISIBILITY_CHANGED" + // Fired when the standby state of the TV has changed. This event is related to the visibility chnaged event, as if the TV is in standby the visibility will be false, the visibility is more granular (as it also detects that the TV has selected a different channel) but it is not reliably detected in all TVs, standby can be used in those cases as most TVs implement it. + | "STANDBY_CHANGED" + | "MAX_VIDEO_RESOLUTION_CHANGED" + | "FEEDBACK_STARTED"; - export type StandbyState = 'STANDBY' | 'NOT_STANDBY' | 'UNKNOWN'; + type SystemState = + | "NOT_STARTED" + | "STARTING_IN_BACKGROUND" + | "STARTING" + | "READY" + | "STOPPING_IN_BACKGROUND" + | "STOPPING"; - export type DisconnectReason = 'REQUESTED_BY_SENDER' | 'ERROR' | 'UNKNOWN'; + type StandbyState = "STANDBY" | "NOT_STANDBY" | "UNKNOWN"; - /** - * Event dispatched by @see{@link CastReceiverManager} when the visibility of the application changes (HDMI input change; TV is turned off). - */ - export class VisibilityChangedEvent { - constructor(isVisible: boolean); + type DisconnectReason = "REQUESTED_BY_SENDER" | "ERROR" | "UNKNOWN"; /** - * Whether the Cast device is the active input or not. + * Event dispatched by @see{@link CastReceiverManager} when the visibility of the application changes (HDMI input change; TV is turned off). */ - isVisible: boolean; - } + class VisibilityChangedEvent { + constructor(isVisible: boolean); - /** - * Represents the system volume data. - */ - export interface SystemVolumeData { - /** - * The level (from 0.0 to 1.0) of the system volume. - */ - level: number; + /** + * Whether the Cast device is the active input or not. + */ + isVisible: boolean; + } /** - * Whether the system volume is muted or not. + * Represents the system volume data. */ - muted: boolean; - } - /** - * Event dispatched by @see{CastReceiverManager} when the system volume changes. - */ - export class SystemVolumeChangedEvent extends Event { - constructor(volume: SystemVolumeData); + interface SystemVolumeData { + /** + * The level (from 0.0 to 1.0) of the system volume. + */ + level: number; + + /** + * Whether the system volume is muted or not. + */ + muted: boolean; + } + /** + * Event dispatched by @see{CastReceiverManager} when the system volume changes. + */ + class SystemVolumeChangedEvent extends Event { + constructor(volume: SystemVolumeData); + + /** + * The system volume data + */ + data: SystemVolumeData; + } + /** + * Event dispatched by @see{@link CastReceiverManager} when the TV enters/leaves the standby state. + */ + class StandbyChangedEvent { + constructor(isStandby: boolean); + + /** + * + */ + isStandby: boolean; + } + /** + * Whether the TV is in standby or not. + */ + interface ShutdownEvent extends Event { + [key: string]: any; + } /** - * The system volume data + * Event dispatched by @see{@link CastReceiverManager} when a sender is disconnected. */ - data: SystemVolumeData; - } - /** - * Event dispatched by @see{@link CastReceiverManager} when the TV enters/leaves the standby state. - */ - export class StandbyChangedEvent { - constructor(isStandby: boolean); + class SenderDisconnectedEvent extends Event { + constructor(senderId: string, userAgent: string); + /** + * The ID of the sender connected. + */ + senderId: string; + + /** + * The user agent of the sender. + */ + userAgent: string; + + /** + * The reason the sender was disconnected. + */ + reason?: DisconnectReason; + } /** - * + * Event dispatched by @see{@link CastReceiverManager} when a sender is connected. */ - isStandby: boolean; - } - /** - * Whether the TV is in standby or not. - */ - export interface ShutdownEvent extends Event {} + class SenderConnectedEvent extends Event { + constructor(senderId: string, userAgent: string); + /** + * The ID of the sender connected. + */ + senderId: string; - /** - * Event dispatched by @see{@link CastReceiverManager} when a sender is disconnected. - */ - export class SenderDisconnectedEvent extends Event { - constructor(senderId: string, userAgent: string); - /** - * The ID of the sender connected. - */ - senderId: string; + /** + * The user agent of the sender. + */ + userAgent: string; + } /** - * The user agent of the sender. + * Represents the data of a connected sender device. */ - userAgent: string; + interface Sender { + /** + * The sender Id. + */ + id: string; + + /** + * Indicate the sender supports large messages (>64KB). + */ + largeMessageSupported?: boolean; + + /** + * The userAgent of the sender. + */ + userAgent?: string; + } /** - * The reason the sender was disconnected. + * Event dispatched by CastReceiverManager when the system is ready. */ - reason?: DisconnectReason; - } + class ReadyEvent { + constructor(applicationData: ApplicationData); - /** - * Event dispatched by @see{@link CastReceiverManager} when a sender is connected. - */ - export class SenderConnectedEvent extends Event { - constructor(senderId: string, userAgent: string); - /** - * The ID of the sender connected. - */ - senderId: string; + /** + * The application data + */ + data: ApplicationData; + } /** - * The user agent of the sender. + * Event dispatched by @see{@link CastReceiverManager} when the system needs to update the restriction on maximum video resolution. */ - userAgent: string; - } + class MaxVideoResolutionChangedEvent extends Event { + constructor(height: number); - /** - * Represents the data of a connected sender device. - */ - export interface Sender { - /** - * The sender Id. - */ - id: string; + /** + * Maximum video resolution requested by the system. The value of 0 means there is no restriction. + */ + height: number; + } + /** Event dispatched by @see{@link CastReceiverManager} when the systems starts to create feedback report. */ + interface FeedbackStartedEvent extends Event { + [key: string]: any; + } + /** Event dispatched by @see{@link CastReceiverContext} which contains system information. */ + class Event { + constructor(type: EventType, data?: any); + type: EventType; + data?: any; + } - /** - * Indicate the sender supports large messages (>64KB). - */ - largeMessageSupported?: boolean; - - /** - * The userAgent of the sender. - */ - userAgent?: string; - } - - /** - * Event dispatched by CastReceiverManager when the system is ready. - */ - export class ReadyEvent { - constructor(applicationData: ApplicationData); - - /** - * The application data - */ - data: ApplicationData; - } - - /** - * Event dispatched by @see{@link CastReceiverManager} when the system needs to update the restriction on maximum video resolution. - */ - export class MaxVideoResolutionChangedEvent extends Event { - constructor(height: number); - - /** - * Maximum video resolution requested by the system. The value of 0 means there is no restriction. - */ - height: number; - } - /** Event dispatched by @see{@link CastReceiverManager} when the systems starts to create feedback report. */ - export interface FeedbackStartedEvent extends Event {} - /** Event dispatched by @see{@link CastReceiverContext} which contains system information. */ - export class Event { - constructor(type: EventType, data?: any); - } - - /** Represents the data of the launched application. */ - export interface ApplicationData { - id(): string; - launchingSenderId(): string; - name(): string; - namespaces(): string[]; - sessionId(): number; - } + /** Represents the data of the launched application. */ + interface ApplicationData { + id(): string; + launchingSenderId(): string; + name(): string; + namespaces(): string[]; + sessionId(): number; + } } diff --git a/types/chromecast-caf-receiver/cast.framework.ui.d.ts b/types/chromecast-caf-receiver/cast.framework.ui.d.ts index fbc61f56d0..b13f036be2 100644 --- a/types/chromecast-caf-receiver/cast.framework.ui.d.ts +++ b/types/chromecast-caf-receiver/cast.framework.ui.d.ts @@ -1,59 +1,48 @@ -// Type definitions for chromecast-caf-receiver 3.x -// Project: https://developers.google.com/cast/docs/reference/caf_receiver/ -// Definitions by: Craig Bruce https://github.com/craigrbruce -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// -/// -/// -/// -/// -/// - -import { PlayerDataEventType } from './cast.framework.ui'; -import { MediaMetadata } from './cast.framework.messages'; +import { PlayerDataEventType } from "./cast.framework.ui"; +import { MediaMetadata } from "./cast.framework.messages"; +import { PlayerDataChangedEventHandler } from "./index"; export = cast.framework.ui; declare namespace cast.framework.ui { - export type ContentType = 'VIDEO' | 'AUDIO' | 'IMAGE'; + type ContentType = "video" | "audio" | "image"; - export type State = - | 'LAUNCHING' - | 'IDLE' - | 'LOADING' - | 'BUFFERING' - | 'PAUSED' - | 'PLAYING'; + type State = + | "launching" + | "idle" + | "loading" + | "buffering" + | "paused" + | "playing"; - export type PlayerDataEventType = - | 'ANY_CHANGE' - | 'STATE_CHANGED' - | 'IS_SEEKING_CHANGED' - | 'DURATION_CHANGED' - | 'CURRENT_TIME_CHANGED' - | 'METADATA_CHANGED' - | 'TITLE_CHANGED' - | 'SUBTITLE_CHANGED' - | 'THUMBNAIL_URL_CHANGED' - | 'NEXT_TITLE_CHANGED' - | 'NEXT_SUBTITLE_CHANGED' - | 'NEXT_THUMBNAIL_URL_CHANGED' - | 'PRELOADING_NEXT_CHANGED' - | 'CONTENT_TYPE_CHANGED' - | 'IS_LIVE_CHANGED' - | 'BREAK_PERCENTAGE_POSITIONS_CHANGED' - | 'IS_PLAYING_BREAK_CHANGED' - | 'IS_BREAK_SKIPPABLE_CHANGED' - | 'WHEN_SKIPPABLE_CHANGED' - | 'NUMBER_BREAK_CLIPS_CHANGED' - | 'CURRENT_BREAK_CLIP_NUMBER_CHANGED' - | 'DISPLAY_STATUS_CHANGED'; + type PlayerDataEventType = + | "ANY_CHANGE" + | "STATE_CHANGED" + | "IS_SEEKING_CHANGED" + | "DURATION_CHANGED" + | "CURRENT_TIME_CHANGED" + | "METADATA_CHANGED" + | "TITLE_CHANGED" + | "SUBTITLE_CHANGED" + | "THUMBNAIL_URL_CHANGED" + | "NEXT_TITLE_CHANGED" + | "NEXT_SUBTITLE_CHANGED" + | "NEXT_THUMBNAIL_URL_CHANGED" + | "PRELOADING_NEXT_CHANGED" + | "CONTENT_TYPE_CHANGED" + | "IS_LIVE_CHANGED" + | "BREAK_PERCENTAGE_POSITIONS_CHANGED" + | "IS_PLAYING_BREAK_CHANGED" + | "IS_BREAK_SKIPPABLE_CHANGED" + | "WHEN_SKIPPABLE_CHANGED" + | "NUMBER_BREAK_CLIPS_CHANGED" + | "CURRENT_BREAK_CLIP_NUMBER_CHANGED" + | "DISPLAY_STATUS_CHANGED"; /** * Player data changed event. Provides the changed field (type); and new value. */ - export class PlayerDataChangedEvent { + class PlayerDataChangedEvent { constructor(type: PlayerDataEventType, field: string, value: any); /** @@ -74,23 +63,29 @@ declare namespace cast.framework.ui { /** * Player data binder. Bind a player data object to the player state. The player data will be updated to reflect correctly the current player state without firing any change event. */ - export class PlayerDataBinder { - constructor(playerData: PlayerData | any); + class PlayerDataBinder { + constructor(playerData: PlayerData); /** * Add listener to player data changes. */ - // addEventListener: (type: PlayerDataEventType; listener: PlayerDataChangedEventHandler); + addEventListener: ( + type: PlayerDataEventType, + listener: PlayerDataChangedEventHandler + ) => void; /** * Remove listener to player data changes. */ - // removeEventListener: (type: PlayerDataEventType; listener: PlayerDataChangedEventHandler); + removeEventListener: ( + type: PlayerDataEventType, + listener: PlayerDataChangedEventHandler + ) => void; } /** * Player data. Provide the player media and break state. */ - export interface PlayerData { + interface PlayerData { /** * Array of breaks positions in percentage. */ @@ -144,7 +139,7 @@ declare namespace cast.framework.ui { /** * Media metadata. */ - metadata: MediaMetadata | any; + metadata: MediaMetadata; /** * Next Item subtitle. diff --git a/types/chromecast-caf-receiver/chromecast-caf-receiver-tests.ts b/types/chromecast-caf-receiver/chromecast-caf-receiver-tests.ts index a4f59bd985..29d842b060 100644 --- a/types/chromecast-caf-receiver/chromecast-caf-receiver-tests.ts +++ b/types/chromecast-caf-receiver/chromecast-caf-receiver-tests.ts @@ -1,66 +1,3 @@ -// Type definitions for chromecast-caf-receiver 3.x -// Project: https://developers.google.com/cast/docs/reference/caf_receiver/ -// Definitions by: Craig Bruce https://github.com/craigrbruce -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +import { BreakSeekData } from "chromecast-caf-receiver/cast.framework.breaks"; -/// -/// -/// -/// -/// -/// -/// - -import { TextTracksManager } from "cast.framework"; -import { StandbyChangedEvent } from "cast.framework.system"; -import { PlayerData, ContentType } from "cast.framework.ui"; -import { BreakManager } from "cast.framework.breaks"; -import { MediaStatusEvent } from "cast.framework.events"; -import { Track, Break, MediaStatus, QueueData } from "cast.framework.messages"; - -const ct = ContentType.VIDEO; -// framework tests -const track = new Track(123, {}); -const ttm = new TextTracksManager({}); -ttm.addTracks(track); - -// $ExpectError -ttm.addTracks("should fail"); - -// system tests -const sce = new StandbyChangedEvent(true); -// $ExpectError -const wrongSce = new StandbyChangedEvent("error"); - -const result: boolean = sce.isStandby; -// $ExpectError -const failure: string = sce.isStandby; - -// ui tests -const pd = new PlayerData(); - -const cn: number = pd.currentBreakClipNumber; -// $ExpectError -const wrongCn: boolean = pd.currentBreakClipNumber; - -// breaks tests -const bm: BreakManager = new BreakManager(); -const brk1: Break = bm.getBreakById("123"); -// $ExpectError -const brk2: string = bm.getBreakById("123"); -// $ExpectError -const brk3: Break = bm.getBreakById(123); -// events tests - -const evt: MediaStatusEvent = new MediaStatusEvent(); -const ms: MediaStatus = evt.mediaStatus; -// $ExpectError -const ms: string = evt.mediaStatus; - -// messages tests -const qd = new QueueData("id", "name", "description", "mode"); -// $ExpectError -const wrongQd = new QueueData({}); -const name: string = qd.name; -// $ExpectError -const wrongName: number = qd.name; +const breakSeekData = new BreakSeekData(0, 100, []); diff --git a/types/chromecast-caf-receiver/index.d.ts b/types/chromecast-caf-receiver/index.d.ts index 5dc89456e6..73a13f53ca 100644 --- a/types/chromecast-caf-receiver/index.d.ts +++ b/types/chromecast-caf-receiver/index.d.ts @@ -1,7 +1,8 @@ // Type definitions for chromecast-caf-receiver 3.x -// Project: https://developers.google.com/cast/docs/reference/caf_receiver/ -// Definitions by: Craig Bruce https://github.com/craigrbruce +// Project: https://github.com/googlecast +// Definitions by: Craig Bruce // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// /// @@ -14,12 +15,10 @@ import { PlayerDataChangedEvent } from './cast.framework.ui'; import { NetworkRequestInfo } from './cast.framework'; import { Event } from './cast.framework.events'; -export = cast; -declare namespace cast { - export type EventHandler = (event: Event) => void; - export type PlayerDataChangedEventHandler = ( - event: PlayerDataChangedEvent - ) => void; - export type RequestHandler = (request: NetworkRequestInfo) => void; - export type BinaryHandler = (data: Uint8Array) => Uint8Array; -} +export as namespace cast; +export type EventHandler = (event: Event) => void; +export type PlayerDataChangedEventHandler = ( + event: PlayerDataChangedEvent +) => void; +export type RequestHandler = (request: NetworkRequestInfo) => void; +export type BinaryHandler = (data: Uint8Array) => Uint8Array; diff --git a/types/chromecast-caf-receiver/tsconfig.json b/types/chromecast-caf-receiver/tsconfig.json index 5c13aa8765..452dd41e91 100644 --- a/types/chromecast-caf-receiver/tsconfig.json +++ b/types/chromecast-caf-receiver/tsconfig.json @@ -1,22 +1,26 @@ { "compilerOptions": { "module": "commonjs", - "lib": [ - "es6" - ], + "lib": ["es6"], "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, "baseUrl": "../", - "typeRoots": [ - "../" - ], + "typeRoots": ["../"], "types": [], "noEmit": true, - "forceConsistentCasingInFileNames": true + "forceConsistentCasingInFileNames": true, + "strictFunctionTypes": false, + "esModuleInterop": true }, "files": [ "index.d.ts", - "chromecast-caf-receiver-tests.ts" + "chromecast-caf-receiver-tests.ts", + "cast.framework.d.ts", + "cast.framework.breaks.d.ts", + "cast.framework.events.d.ts", + "cast.framework.messages.d.ts", + "cast.framework.system.d.ts", + "cast.framework.ui.d.ts" ] } diff --git a/types/chromecast-caf-receiver/tslint.json b/types/chromecast-caf-receiver/tslint.json index 3db14f85ea..f85a173bd5 100644 --- a/types/chromecast-caf-receiver/tslint.json +++ b/types/chromecast-caf-receiver/tslint.json @@ -1 +1,8 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-redundant-jsdoc-2": false, + "jsdoc-format": false, + "max-line-length": false + } +} From 2534c15d9ede387030eca0be0566a9799c50f091 Mon Sep 17 00:00:00 2001 From: Craig Bruce Date: Thu, 31 May 2018 13:40:18 +1000 Subject: [PATCH 3/5] write a simple spread of tests for a few classes from each namespace --- .../cast.framework.d.ts | 6 +- .../chromecast-caf-receiver-tests.ts | 105 +++++++++++++++++- 2 files changed, 107 insertions(+), 4 deletions(-) diff --git a/types/chromecast-caf-receiver/cast.framework.d.ts b/types/chromecast-caf-receiver/cast.framework.d.ts index 1435859859..2ee078021a 100644 --- a/types/chromecast-caf-receiver/cast.framework.d.ts +++ b/types/chromecast-caf-receiver/cast.framework.d.ts @@ -44,7 +44,7 @@ declare namespace cast.framework { * Manages text tracks. */ class TextTracksManager { - constructor(params: any); + constructor(params?: any); /** * Adds text tracks to the list. @@ -106,7 +106,7 @@ declare namespace cast.framework { * QueueManager exposes several queue manipulation APIs to developers. */ class QueueManager { - constructor(params: any); + constructor(params?: any); /** * Returns the current queue item. @@ -199,7 +199,7 @@ declare namespace cast.framework { * Controls and monitors media playback. */ class PlayerManager { - constructor(params: any); + constructor(params?: any); /** * Adds an event listener for player event. diff --git a/types/chromecast-caf-receiver/chromecast-caf-receiver-tests.ts b/types/chromecast-caf-receiver/chromecast-caf-receiver-tests.ts index 29d842b060..a75834b0a8 100644 --- a/types/chromecast-caf-receiver/chromecast-caf-receiver-tests.ts +++ b/types/chromecast-caf-receiver/chromecast-caf-receiver-tests.ts @@ -1,3 +1,106 @@ -import { BreakSeekData } from "chromecast-caf-receiver/cast.framework.breaks"; +import { + PlayerData, + PlayerDataBinder +} from "chromecast-caf-receiver/cast.framework.ui"; +import { + ReadyEvent, + ApplicationData +} from "chromecast-caf-receiver/cast.framework.system"; +import { + RequestEvent, + Event +} from "chromecast-caf-receiver/cast.framework.events"; +import { + QueueBase, + TextTracksManager, + QueueManager, + PlayerManager +} from "chromecast-caf-receiver/cast.framework"; +import { + BreakSeekData, + BreakClipLoadInterceptorContext, + BreakManager +} from "chromecast-caf-receiver/cast.framework.breaks"; +import { + Break, + BreakClip, + LoadRequestData, + Track, + MediaMetadata +} from "chromecast-caf-receiver/cast.framework.messages"; +const track = new Track(1, "TEXT"); +const breakClip = new BreakClip("id"); +const adBreak = new Break("id", ["id"], 1); +const rEvent = new RequestEvent("BITRATE_CHANGED", { requestId: 2 }); +const pManager = new PlayerManager(); +pManager.addEventListener("STALLED", () => {}); +const ttManager = new TextTracksManager(); +const qManager = new QueueManager(); +const qBase = new QueueBase(); +const items = qBase.fetchItems(1, 3, 4); const breakSeekData = new BreakSeekData(0, 100, []); +const breakClipLoadContext = new BreakClipLoadInterceptorContext(adBreak); +const breakManager: BreakManager = { + getBreakById: () => adBreak, + getBreakClipById: () => breakClip, + getBreakClips: () => [breakClip], + getBreaks: () => [adBreak], + getPlayWatchedBreak: () => true, + setBreakClipLoadInterceptor: () => {}, + setBreakSeekInterceptor: () => {}, + setPlayWatchedBreak: () => {}, + setVastTrackingInterceptor: () => {} +}; + +const lrd: LoadRequestData = { + requestId: 1, + activeTrackIds: [1, 2], + media: { + tracks: [], + textTrackStyle: {}, + streamType: "BUFFERED", + metadata: { metadataType: "GENERIC" }, + hlsSegmentFormat: "AAC", + contentId: "id", + contentType: "type", + breakClips: [breakClip], + breaks: [adBreak] + }, + queueData: {} +}; + +const appData: ApplicationData = { + id: () => "id", + launchingSenderId: () => "launch-id", + name: () => "name", + namespaces: () => ["namespace"], + sessionId: () => 1 +}; + +const readyEvent = new ReadyEvent(appData); +const data = readyEvent.data; +const pData: PlayerData = { + breakPercentagePositions: [1], + contentType: "video", + currentBreakClipNumber: 2, + currentTime: 1234, + displayStatus: true, + duration: 222, + isBreakSkippable: false, + isLive: true, + isPlayingBreak: false, + isSeeking: true, + metadata: new MediaMetadata("GENERIC"), + nextSubtitle: "sub", + nextThumbnailUrl: "url", + nextTitle: "title", + numberBreakClips: 3, + preloadingNext: false, + state: "paused", + thumbnailUrl: "url", + title: "title", + whenSkippable: 321 +}; +const binder = new PlayerDataBinder(pData); +binder.addEventListener("ANY_CHANGE", e => {}); From caaaebc65f28a3d7808857b73ec56166638819fc Mon Sep 17 00:00:00 2001 From: Craig Bruce <“craigrbruce@gmail.com”> Date: Fri, 8 Jun 2018 10:45:02 +1000 Subject: [PATCH 4/5] Remove tslint rules and fix JSDoc formatting. Rewrite email address on previous commits. --- .../cast.framework.breaks.d.ts | 6 - .../cast.framework.d.ts | 47 ++- .../cast.framework.messages.d.ts | 374 ++++++++++++------ .../cast.framework.system.d.ts | 23 +- .../cast.framework.ui.d.ts | 18 +- types/chromecast-caf-receiver/tslint.json | 3 - 6 files changed, 312 insertions(+), 159 deletions(-) diff --git a/types/chromecast-caf-receiver/cast.framework.breaks.d.ts b/types/chromecast-caf-receiver/cast.framework.breaks.d.ts index 309d87fd74..21adf13fb0 100644 --- a/types/chromecast-caf-receiver/cast.framework.breaks.d.ts +++ b/types/chromecast-caf-receiver/cast.framework.breaks.d.ts @@ -36,13 +36,11 @@ declare namespace cast.framework.breaks { interface BreakManager { /** * Get current media break by id. - * @param {*} id */ getBreakById(id: string): Break; /** * Get current media break clip by id - * @param {*} id */ getBreakClipById(id: string): BreakClip; @@ -61,7 +59,6 @@ declare namespace cast.framework.breaks { * By default VAST fetching and parsing logic in default interceptor. * So if customized interceptor is set by developer; * the VAST logic will be overridden and developers should implement their own VAST fetching and parsing logic in the provided interceptor. - * @param {*} interceptor */ setBreakClipLoadInterceptor( interceptor: ( @@ -72,7 +69,6 @@ declare namespace cast.framework.breaks { /** * Provide an interceptor for developer to specify what breaks they want to play after seek. - * @param {*} seekInterceptor */ setBreakSeekInterceptor( seekInterceptor: (breakSeekData: BreakSeekData) => void @@ -80,7 +76,6 @@ declare namespace cast.framework.breaks { /** * Set a flag to control if the watched client stitching break should be played. - * @param {*} playWatchedBreak */ setPlayWatchedBreak(playWatchedBreak: boolean): void; @@ -89,7 +84,6 @@ declare namespace cast.framework.breaks { * The input of the interceptor is a string of the tracking URL. * The interceptor can either return a modified string of URL or a Promise of modified string of URL. * The interceptor can also return null if you want to send the tracking URL by your own code instead of by CAF. - * @param {*} interceptor */ setVastTrackingInterceptor( interceptor?: (trackingUrl: string) => void diff --git a/types/chromecast-caf-receiver/cast.framework.d.ts b/types/chromecast-caf-receiver/cast.framework.d.ts index 2ee078021a..28b0c69e2d 100644 --- a/types/chromecast-caf-receiver/cast.framework.d.ts +++ b/types/chromecast-caf-receiver/cast.framework.d.ts @@ -149,7 +149,9 @@ declare namespace cast.framework { */ class QueueBase { /** - * Fetches a window of items using the specified item id as reference; called by the receiver MediaManager when it needs more queue items; often as a request from senders. If only one of nextCount and prevCount is non-zero; fetchItems should only return items after or before the reference item; if both nextCount and prevCount are non-zero; a window of items including the reference item should be returned. + * Fetches a window of items using the specified item id as reference; called by the receiver MediaManager when it needs more queue items; + * often as a request from senders. If only one of nextCount and prevCount is non-zero; fetchItems should only return items after or before + * the reference item; if both nextCount and prevCount are non-zero; a window of items including the reference item should be returned. */ fetchItems( itemId: number, @@ -158,7 +160,9 @@ declare namespace cast.framework { ): QueueItem[] | Promise; /** - * Initializes the queue with the requestData. This is called when a new LOAD request comes in to the receiver. If this returns or resolves to null; our default queueing implementation will create a queue based on queueData.items or the single media in the load request data. + * Initializes the queue with the requestData. This is called when a new LOAD request comes in to the receiver. + * If this returns or resolves to null; our default queueing implementation will create a queue based on queueData.items or the single media + * in the load request data. */ initialize( requestData: LoadRequestData @@ -175,12 +179,14 @@ declare namespace cast.framework { onCurrentItemIdChanged(itemId: number): void; /** - * A callback for informing the following items have been inserted into the receiver queue in this session. A cloud based implementation can optionally choose to update its queue based on the new information. + * A callback for informing the following items have been inserted into the receiver queue in this session. + * A cloud based implementation can optionally choose to update its queue based on the new information. */ onItemsInserted(items: QueueItem[], insertBefore?: number): void; /** - * A callback for informing the following items have been removed from the receiver queue in this session. A cloud based implementation can optionally choose to update its queue based on the new information. + * A callback for informing the following items have been removed from the receiver queue in this session. + * A cloud based implementation can optionally choose to update its queue based on the new information. */ onItemsRemoved(itemIds: number[]): void; @@ -219,9 +225,6 @@ declare namespace cast.framework { includeQueueItems?: boolean ): void; - /** - * - */ getAudioTracksManager(): AudioTracksManager; /** @@ -280,7 +283,8 @@ declare namespace cast.framework { getPlayerState(): PlayerState; /** - * Get the preferred playback rate. (Can be used on shutdown event to save latest preferred playback rate to a persistent storage; so it can be used in next session in the cast options). + * Get the preferred playback rate. (Can be used on shutdown event to save latest preferred playback rate to a persistent storage; + * so it can be used in next session in the cast options). */ getPreferredPlaybackRate(): number; @@ -294,9 +298,6 @@ declare namespace cast.framework { */ getQueueManager(): QueueManager; - /** - * - */ getTextTracksManager(): TextTracksManager; /** @@ -365,7 +366,10 @@ declare namespace cast.framework { ): void; /** - * Sets the IDLE reason. This allows applications that want to force the IDLE state to indicate the reason that made the player going to IDLE state (a custom error; for example). The idle reason will be sent in the next status message. NOTE: Most applications do not need to set this value; it is only needed if they want to make the player go to IDLE in special circumstances and the default idleReason does not reflect their intended behavior. + * Sets the IDLE reason. This allows applications that want to force the IDLE state to indicate the reason that made the player going to IDLE state + * (a custom error; for example). The idle reason will be sent in the next status message. NOTE: Most applications do not need to set this value; + * it is only needed if they want to make the player go to IDLE in special circumstances and the default idleReason does not reflect their intended + * behavior. */ setIdleReason(idleReason: IdleReason): void; @@ -383,7 +387,9 @@ declare namespace cast.framework { ): void; /** - * Sets a handler to return or modify PlaybackConfig; for a specific load request. The handler paramaters are the load request data and default playback config for the receiver (provided in the context options). The handler should returns a modified playback config; or null to prevent the media from playing. The return value can be a promise to allow waiting for data from the server. + * Sets a handler to return or modify PlaybackConfig; for a specific load request. The handler paramaters are the load request data + * and default playback config for the receiver (provided in the context options). The handler should returns a modified playback config; + * or null to prevent the media from playing. The return value can be a promise to allow waiting for data from the server. */ setMediaPlaybackInfoHandler( handler: ( @@ -393,14 +399,19 @@ declare namespace cast.framework { ): void; /** - * Sets a handler to return the media url for a load request. This handler can be used to avoid having the media content url published as part of the media status. By default the media contentId is used as the content url. + * Sets a handler to return the media url for a load request. This handler can be used to avoid having the media content url published as part + * of the media status. By default the media contentId is used as the content url. */ setMediaUrlResolver( resolver: (loadRequestData: LoadRequestData) => void ): void; /** - * Provide an interceptor of incoming and outgoing messages. The interceptor can update the request data; and return updated data; a promise of updated data if need to get more data from the server; or null if the request should not be handled. Note that if load message interceptor is provided; and no interceptor is provided for preload - the load interceptor will be called for preload messages. + * Provide an interceptor of incoming and outgoing messages. + * The interceptor can update the request data; and return updated data; a promise of + * updated data if need to get more data from the server; or null if the request should not be handled. + * Note that if load message interceptor is provided; and no interceptor is provided for preload - + * the load interceptor will be called for preload messages. */ setMessageInterceptor( type: MessageType, @@ -413,12 +424,14 @@ declare namespace cast.framework { setPlaybackConfig(playbackConfig: PlaybackConfig): void; /** - * Set the preferred playback rate for follow up load or media items. The preferred playback rate will be updated automatically to the latest playback rate that was provided by a load request or explicit set of playback rate. + * Set the preferred playback rate for follow up load or media items. The preferred playback rate will be updated automatically to the latest + * playback rate that was provided by a load request or explicit set of playback rate. */ setPreferredPlaybackRate(preferredPlaybackRate: number): void; /** - * Set the preferred text track language. The preferred text track language will be updated automatically to the latest enabled language by a load request or explicit change to text tracks. (Should be called only in idle state; and Will only apply to next loaded media). + * Set the preferred text track language. The preferred text track language will be updated automatically to the latest enabled language + * by a load request or explicit change to text tracks. (Should be called only in idle state; and Will only apply to next loaded media). */ setPreferredTextLanguage(preferredTextLanguage: string): void; diff --git a/types/chromecast-caf-receiver/cast.framework.messages.d.ts b/types/chromecast-caf-receiver/cast.framework.messages.d.ts index 311232e5e0..d6dda6d145 100644 --- a/types/chromecast-caf-receiver/cast.framework.messages.d.ts +++ b/types/chromecast-caf-receiver/cast.framework.messages.d.ts @@ -224,19 +224,10 @@ declare namespace cast.framework.messages { class VideoInformation { constructor(width: number, height: number, hdrType: HdrType); - /** - * - */ width: number; - /** - * - */ height: number; - /** - * - */ hdrType: HdrType; } @@ -245,7 +236,10 @@ declare namespace cast.framework.messages { */ interface VastAdsRequest { /** - * Specifies a VAST document to be used as the ads response instead of making a request via an ad tag url. This can be useful for debugging and other situations where a VAST response is already available. + * Specifies a VAST document to be used as the ads response instead of making a + * request via an ad tag url. + * This can be useful for debugging and other situations where a VAST response is + * already available. */ adsResponse?: string; @@ -260,7 +254,8 @@ declare namespace cast.framework.messages { */ interface UserActionRequestData { /** - * Optional request source. It contain the assistent query that initiate the request. + * Optional request source. + * It contain the assistent query that initiate the request. */ source?: string; @@ -295,7 +290,8 @@ declare namespace cast.framework.messages { episodeTitle?: string; /** - * Content images. Examples would include cover art or a thumbnail of the currently playing media. + * Content images. Examples would include cover art or a thumbnail of + * the currently playing media. */ images?: Image[]; @@ -356,12 +352,19 @@ declare namespace cast.framework.messages { subtype?: string; /** - * It can be the url of the track or any other identifier that allows the receiver to find the content (when the track is not inband or included in the manifest). For example it can be the url of a vtt file. + * It can be the url of the track or any other identifier that allows the receiver + * to find the content (when the track is not inband or included in the manifest). + * For example it can be the url of a vtt file. */ trackContentId?: string; /** - * It represents the MIME type of the track content. For example if the track is a vtt file it will be ‘text/vtt’. This field is needed for out of band tracks; so it is usually provided if a trackContentId has also been provided. It is not mandatory if the receiver has a way to identify the content from the trackContentId; but recommended. The track content type; if provided; must be consistent with the track type. + * It represents the MIME type of the track content. For example if the track + * is a vtt file it will be ‘text/vtt’. This field is needed for out of band tracks; + * so it is usually provided if a trackContentId has also been provided. + * It is not mandatory if the receiver has a way to identify the content from + * the trackContentId; but recommended. + * The track content type; if provided; must be consistent with the track type. */ trackContentType?: string; @@ -394,9 +397,6 @@ declare namespace cast.framework.messages { */ edgeColor?: string; - /** - * - */ edgeType?: TextTrackEdgeType; /** @@ -430,7 +430,8 @@ declare namespace cast.framework.messages { windowColor?: string; /** - * Rounded corner radius absolute value in pixels (px). This value will be ignored if windowType is not ROUNDED_CORNERS. + * Rounded corner radius absolute value in pixels (px). This value will be ignored + * if windowType is not ROUNDED_CORNERS. */ windowRoundedCornerRadius?: number; @@ -450,7 +451,10 @@ declare namespace cast.framework.messages { playbackRate?: number; /** - * New playback rate relative to current playback rate. New rate will be the result of multiplying the current rate with the value. For example a value of 1.1 will increase rate by 10%. (Only used if the playbackRate value is not provided). + * New playback rate relative to current playback rate. + * New rate will be the result of multiplying the current rate with the value. + * For example a value of 1.1 will increase rate by 10%. + * (Only used if the playbackRate value is not provided). */ relativePlaybackRate?: number; } @@ -465,7 +469,8 @@ declare namespace cast.framework.messages { credentials?: string; /** - * If it is a response for refresh credentials; it will indicate the request id of the refresh credentials request. + * If it is a response for refresh credentials; it will indicate the request id + * of the refresh credentials request. */ forRequestId?: number; @@ -485,7 +490,8 @@ declare namespace cast.framework.messages { currentTime?: number; /** - * Seconds relative to the current playback position. If this field is defined; the currentTime field will be ignored. + * Seconds relative to the current playback position. If this field is defined; + * the currentTime field will be ignored. */ relativeTime?: number; @@ -519,7 +525,9 @@ declare namespace cast.framework.messages { constructor(type: MessageType); /** - * Application-specific data for this request. It enables the sender and receiver to easily extend the media protocol without having to use a new namespace with custom messages. + * Application-specific data for this request. + * It enables the sender and receiver to easily extend the media protocol + * without having to use a new namespace with custom messages. */ customData?: any; @@ -539,22 +547,35 @@ declare namespace cast.framework.messages { */ interface QueueUpdateRequestData { /** - * ID of the current media Item after the deletion (if not provided; the currentItem value will be the same as before the deletion; if it does not exist because it has been deleted; the currentItem will point to the next logical item in the list). + * ID of the current media Item after the deletion + * (if not provided; the currentItem value will be the same as before the deletion; + * if it does not exist because it has been deleted; the currentItem will point to + * the next logical item in the list). */ currentItemId?: number; /** - * Seconds since the beginning of content to start playback of the current item. If provided; this value will take precedence over the startTime value provided at the QueueItem level but only the first time the item is played. This is to cover the common case where the user jumps to the middle of an item so the currentTime does not apply to the item permanently like the QueueItem startTime does. It avoids having to reset the startTime dynamically (that may not be possible if the phone has gone to sleep). + * Seconds since the beginning of content to start playback of the current item. + * If provided; this value will take precedence over the startTime value provided + * at the QueueItem level but only the first time the item is played. + * This is to cover the common case where the user jumps to the middle of an + * item so the currentTime does not apply to the item permanently like the + * QueueItem startTime does. It avoids having to reset the startTime dynamically + * (that may not be possible if the phone has gone to sleep). */ currentTime?: number; /** - * List of queue items to be updated. No reordering will happen; the items will retain the existing order. + * List of queue items to be updated. No reordering will happen; the items will + * retain the existing order. */ items?: QueueItem[]; /** - * Skip/Go back number of items with respect to the position of currentItem (it can be negative). If it is out of boundaries; the currentItem will be the next logical item in the queue wrapping around the boundaries. The new currentItem position will follow the rules of the queue repeat behavior. + * Skip/Go back number of items with respect to the position of currentItem + * (it can be negative). If it is out of boundaries; the currentItem will be the + * next logical item in the queue wrapping around the boundaries. + * The new currentItem position will follow the rules of the queue repeat behavior. */ jump?: number; @@ -564,7 +585,9 @@ declare namespace cast.framework.messages { repeatMode?: RepeatMode; /** - * Shuffle the queue items when the update is processed. After the queue items are shuffled; the item at the currentItem position will be loaded. + * Shuffle the queue items when the update is processed. + * After the queue items are shuffled; the item at the currentItem position will + * be loaded. */ shuffle?: boolean; } @@ -576,29 +599,43 @@ declare namespace cast.framework.messages { constructor(itemIds: number[]); /** - * ID of the current media Item after the deletion (if not provided; the currentItem value will be the same as before the deletion; if it does not exist because it has been deleted; the currentItem will point to the next logical item in the list). + * ID of the current media Item after the deletion (if not provided; + * the currentItem value will be the same as before the deletion; + * if it does not exist because it has been deleted; + * the currentItem will point to the next logical item in the list). */ currentItemId?: number; /** - * Seconds since the beginning of content to start playback of the current item. If provided; this value will take precedence over the startTime value provided at the QueueItem level but only the first time the item is played. This is to cover the common case where the user jumps to the middle of an item so the currentTime does not apply to the item permanently like the QueueItem startTime does. It avoids having to reset the startTime dynamically (that may not be possible if the phone has gone to sleep). + * Seconds since the beginning of content to start playback of the current item. + * If provided; this value will take precedence over the startTime value provided + * at the QueueItem level but only the first time the item is played. + * This is to cover the common case where the user jumps to the middle of an + * item so the currentTime does not apply to the item permanently like + * the QueueItem startTime does. It avoids having to reset the startTime dynamically + * (that may not be possible if the phone has gone to sleep). */ currentTime?: number; /** - * ID of the item that will be located immediately after the reordered list. If the ID is not found or it is not provided; the reordered list will be appended at the end of the existing list. + * ID of the item that will be located immediately after the reordered list. + * If the ID is not found or it is not provided; + * the reordered list will be appended at the end of the existing list. */ insertBefore?: number; /** - * IDs of the items to be reordered; in the new order. Items not provided will keep their existing order. The provided list will be inserted at the position determined by insertBefore. For example: - - If insertBefore is not specified Existing queue: “A”;”D”;”G”;”H”;”B”;”E” itemIds: “D”;”H”;”B” New Order: “A”;”G”;”E”;“D”;”H”;”B” - - If insertBefore is “A” Existing queue: “A”;”D”;”G”;”H”;”B” itemIds: “D”;”H”;”B” New Order: “D”;”H”;”B”;“A”;”G”;”E” - - If insertBefore is “G” Existing queue: “A”;”D”;”G”;”H”;”B” itemIds: “D”;”H”;”B” New Order: “A”;“D”;”H”;”B”;”G”;”E” - */ + * IDs of the items to be reordered; in the new order. + * Items not provided will keep their existing order. + * The provided list will be inserted at the position determined by insertBefore. + * For example: + * If insertBefore is not specified Existing queue: “A”;”D”;”G”;”H”;”B”;”E” itemIds: + * “D”;”H”;”B” New Order: “A”;”G”;”E”;“D”;”H”;”B” + * If insertBefore is “A” Existing queue: “A”;”D”;”G”;”H”;”B” itemIds: + * “D”;”H”;”B” New Order: “D”;”H”;”B”;“A”;”G”;”E” + * If insertBefore is “G” Existing queue: “A”;”D”;”G”;”H”;”B” itemIds: + * “D”;”H”;”B” New Order: “A”;“D”;”H”;”B”;”G”;”E” + */ itemIds: number[]; } @@ -609,12 +646,21 @@ declare namespace cast.framework.messages { constructor(itemIds: number[]); /** - * ID of the current media Item after the deletion (if not provided; the currentItem value will be the same as before the deletion; if it does not exist because it has been deleted; the currentItem will point to the next logical item in the list). + * ID of the current media Item after the deletion + * (if not provided; the currentItem value will be the same as before the deletion; + * if it does not exist because it has been deleted; + * the currentItem will point to the next logical item in the list). */ currentItemId?: number; /** - * Seconds since the beginning of content to start playback of the current item. If provided; this value will take precedence over the startTime value provided at the QueueItem level but only the first time the item is played. This is to cover the common case where the user jumps to the middle of an item so the currentTime does not apply to the item permanently like the QueueItem startTime does. It avoids having to reset the startTime dynamically (that may not be possible if the phone has gone to sleep). + * Seconds since the beginning of content to start playback of the current item. + * If provided; this value will take precedence over the startTime value provided + * at the QueueItem level but only the first time the item is played. + * This is to cover the common case where the user jumps to the middle of an + * item so the currentTime does not apply to the item permanently like the + * QueueItem startTime does. It avoids having to reset the startTime dynamically + * (that may not be possible if the phone has gone to sleep). */ currentTime?: number; @@ -630,7 +676,14 @@ declare namespace cast.framework.messages { constructor(items: QueueItem[]); /** - * Seconds (since the beginning of content) to start playback of the first item to be played. If provided; this value will take precedence over the startTime value provided at the QueueItem level but only the first time the item is played. This is to cover the common case where the user casts the item that was playing locally so the currentTime does not apply to the item permanently like the QueueItem startTime does. It avoids having to reset the startTime dynamically (that may not be possible if the phone has gone to sleep). + * Seconds (since the beginning of content) to start playback of the first item to + * be played. If provided; this value will take precedence over the + * startTime value provided at the QueueItem level but only the first + * time the item is played. This is to cover the common case where the user + * casts the item that was playing locally so the currentTime does not apply + * to the item permanently like the QueueItem startTime does. + * It avoids having to reset the startTime dynamically + * (that may not be possible if the phone has gone to sleep). */ currentTime?: number; @@ -645,24 +698,37 @@ declare namespace cast.framework.messages { repeatMode?: RepeatMode; /** - * The index of the item in the items array that must be the first currentItem (the item that will be played first). Note this is the index of the array (starts at 0) and not the itemId (as it is not known until the queue is created). If repeatMode is REPEAT_OFF playback will end when the last item in the array is played (elements before the startIndex will not be played). This may be useful for continuation scenarios where the user was already using the sender app and in the middle decides to cast. In this way the sender app does not need to map between the local and remote queue positions or saves one extra QUEUE_UPDATE request. + * The index of the item in the items array that must be the first currentItem + * (the item that will be played first). Note this is the index of the array + * (starts at 0) and not the itemId (as it is not known until the queue is created). + * If repeatMode is REPEAT_OFF playback will end when the last item in the array is + * played (elements before the startIndex will not be played). + * This may be useful for continuation scenarios where the user was already + * using the sender app and in the middle decides to cast. + * In this way the sender app does not need to map between the local and remote queue + * positions or saves one extra QUEUE_UPDATE request. */ startIndex?: number; } /** - * Queue item information. Application developers may need to create a QueueItem to insert a queue element using InsertQueueItems. In this case they should not provide an itemId (as the actual itemId will be assigned when the item is inserted in the queue). This prevents ID collisions with items added from a sender app. + * Queue item information. Application developers may need to create a QueueItem to + * insert a queue element using InsertQueueItems. In this case they should not + * provide an itemId (as the actual itemId will be assigned when the item is inserted + * in the queue). This prevents ID collisions with items added from a sender app. */ class QueueItem { constructor(opt_itemId?: number); /** - * Array of Track trackIds that are active. If the array is not provided; the default tracks will be active. + * Array of Track trackIds that are active. If the array is not provided; + * the default tracks will be active. */ activeTrackIds?: number[]; /** - * If the autoplay parameter is not specified or is true; the media player will begin playing the element in the queue when the item becomes the currentItem. + * If the autoplay parameter is not specified or is true; the media player + * will begin playing the element in the queue when the item becomes the currentItem. */ autoplay?: boolean; @@ -672,7 +738,9 @@ declare namespace cast.framework.messages { customData?: any; /** - * Unique identifier of the item in the queue. The attribute is optional because for LOAD or INSERT should not be provided (as it will be assigned by the receiver when an item is first created/inserted). + * Unique identifier of the item in the queue. + * The attribute is optional because for LOAD or INSERT should not be provided + * (as it will be assigned by the receiver when an item is first created/inserted). */ itemId?: number; @@ -682,17 +750,36 @@ declare namespace cast.framework.messages { media?: MediaInformation; /** - * Playback duration of the item; if it is larger than the actual duration - startTime it will be ignored (default behavior). It can be negative; in such case the duration will be the actual asset duration minus the duration provided. It can be used for photo slideshows to control the duration the item should be presented or for live events to control the duration that the program should be played. It may be useful for autoplay scenarios to avoid displaying all the credits after an episode has ended. + * Playback duration of the item; if it is larger than the actual duration - + * startTime it will be ignored (default behavior). + * It can be negative; in such case the duration will be the actual asset + * duration minus the duration provided. + * It can be used for photo slideshows to control the duration the item should + * be presented or for live events to control the duration that the program + * should be played. It may be useful for autoplay scenarios to avoid displaying all + * the credits after an episode has ended. */ playbackDuration?: number; /** - * This parameter is a hint for the receiver to preload this media item before it is played. It allows for a smooth transition between items played from the queue. The time is expressed in seconds; relative to the beginning of this item playback (usually the end of the previous item playback). Only positive values are valid. For example; if the value is 10 seconds; this item will be preloaded 10 seconds before the previous item has finished. The receiver will try to honor this value but will not guarantee it; for example if the value is larger than the previous item duration the receiver may just preload this item shortly after the previous item has started playing (there will never be two items being preloaded in parallel). Also; if an item is inserted in the queue just after the currentItem and the time to preload is higher than the time left on the currentItem; the preload will just happen as soon as possible. + * This parameter is a hint for the receiver to preload this media + * item before it is played. It allows for a smooth transition between items + * played from the queue. The time is expressed in seconds; relative to + * the beginning of this item playback (usually the end of the previous item playback). + * Only positive values are valid. For example; if the value is 10 seconds; this item + * will be preloaded 10 seconds before the previous item has finished. + * The receiver will try to honor this value but will not guarantee it; + * for example if the value is larger than the previous item duration the + * receiver may just preload this item shortly after the previous item has started playing + * (there will never be two items being preloaded in parallel). + * Also; if an item is inserted in the queue just after the currentItem and the time to preload is higher than the + * time left on the currentItem; the preload will just happen as soon as possible. */ preloadTime?: number; /** - * Seconds since beginning of content. If the content is live content; and startTime is not specified; the stream will start at the live position. + * Seconds since beginning of content. If the content is live content; + * and startTime is not specified; the stream will start at the live position. */ startTime?: number; } @@ -704,27 +791,42 @@ declare namespace cast.framework.messages { constructor(items: QueueItem[]); /** - * ID of the current media Item after the insertion (if not provided; the currentItem value will be the same as before the insertion). + * ID of the current media Item after the insertion (if not provided; + * the currentItem value will be the same as before the insertion). */ currentItemId?: number; /** - * Index (relative to the items array; starting with 0) of the new current media Item. For inserted items we use the index (similar to startIndex in QUEUE_LOAD) and not currentItemId; because the itemId is unknown until the items are inserted. If not provided; the currentItem value will be the same as before the insertion (unless currentItemId is provided). This param allows to make atomic the common use case of insert and play an item. + * Index (relative to the items array; starting with 0) of the new current media Item. + * For inserted items we use the index (similar to startIndex in QUEUE_LOAD) and not + * currentItemId; because the itemId is unknown until the items are inserted. + * If not provided; the currentItem value will be the same as before the insertion + * (unless currentItemId is provided). This param allows to make atomic the common use + * case of insert and play an item. */ currentItemIndex?: number; /** - * Seconds since the beginning of content to start playback of the current item. If provided; this value will take precedence over the startTime value provided at the QueueItem level but only the first time the item is played. This is to cover the common case where the user jumps to the middle of an item so the currentTime does not apply to the item permanently like the QueueItem startTime does. It avoids having to reset the startTime dynamically (that may not be possible if the phone has gone to sleep). + * Seconds since the beginning of content to start playback of the current item. + * If provided; this value will take precedence over the startTime value provided + * at the QueueItem level but only the first time the item is played. + * This is to cover the common case where the user jumps to the middle of an + * item so the currentTime does not apply to the item permanently like the + * QueueItem startTime does. It avoids having to reset the startTime dynamically + * (that may not be possible if the phone has gone to sleep). */ currentTime?: number; /** - * ID of the item that will be located immediately after the inserted list. If the ID is not found or it is not provided; the list will be appended at the end of the existing list. + * ID of the item that will be located immediately after the inserted list. + * If the ID is not found or it is not provided; the list will be appended at + * the end of the existing list. */ insertBefore?: number; /** - * List of queue items. The itemId field of the items should be empty. It is sorted (first element will be played first). + * List of queue items. The itemId field of the items should be empty. + * It is sorted (first element will be played first). */ items: QueueItem[]; } @@ -743,9 +845,6 @@ declare namespace cast.framework.messages { */ requestId?: number; - /** - * - */ type: MessageType; } @@ -834,13 +933,11 @@ declare namespace cast.framework.messages { requestId?: number; /** - * The queue change sequence ID. Used to coordinate state sync between various senders and the receiver. + * The queue change sequence ID. Used to coordinate state sync between various + * senders and the receiver. */ sequenceNumber?: number; - /** - * - */ type: MessageType; } @@ -849,11 +946,14 @@ declare namespace cast.framework.messages { */ class PreloadRequestData implements LoadRequestData { /** - * Array of trackIds that are active. If the array is not provided; the default tracks will be active. + * Array of trackIds that are active. If the array is not provided; + * the default tracks will be active. */ activeTrackIds: number[]; /** - * If the autoplay parameter is specified; the media player will begin playing the content when it is loaded. Even if autoplay is not specified;the media player implementation may choose to begin playback immediately. + * If the autoplay parameter is specified; the media player will begin playing + * the content when it is loaded. Even if autoplay is not specified;the media player + * implementation may choose to begin playback immediately. */ autoplay?: boolean; /** @@ -861,15 +961,19 @@ declare namespace cast.framework.messages { */ credentials?: string; /** - * Optional credentials type. The type 'cloud' is a reserved type used by load requests that were originated by voice assistant commands. + * Optional credentials type. The type 'cloud' is a reserved type used by load + * requests that were originated by voice assistant commands. */ credentialsType?: string; /** - * Seconds since beginning of content. If the content is live content; and currentTime is not specified; the stream will start at the live position. + * Seconds since beginning of content. If the content is live content; + * and currentTime is not specified; the stream will start at the live position. */ currentTime?: number; /** - * If the autoplay parameter is specified; the media player will begin playing the content when it is loaded. Even if autoplay is not specified; the media player implementation may choose to begin playback immediately. + * If the autoplay parameter is specified; the media player will begin playing + * the content when it is loaded. Even if autoplay is not specified; the media + * player implementation may choose to begin playback immediately. */ media: MediaInformation; /** @@ -881,7 +985,9 @@ declare namespace cast.framework.messages { */ queueData: QueueData; /** - * Application-specific data for this request. It enables the sender and receiver to easily extend the media protocol without having to use a new namespace with custom messages. + * Application-specific data for this request. + * It enables the sender and receiver to easily extend the media protocol + * without having to use a new namespace with custom messages. */ customData?: any; /** @@ -901,15 +1007,19 @@ declare namespace cast.framework.messages { } /** - * Media event PRECACHE request data. (Some fields of the load request; like autoplay and queueData; are ignored). + * Media event PRECACHE request data. (Some fields of the load request; + * like autoplay and queueData; are ignored). */ class PrecacheRequestData implements LoadRequestData { /** - * Array of trackIds that are active. If the array is not provided; the default tracks will be active. + * Array of trackIds that are active. If the array is not provided; + * the default tracks will be active. */ activeTrackIds: number[]; /** - * If the autoplay parameter is specified; the media player will begin playing the content when it is loaded. Even if autoplay is not specified;the media player implementation may choose to begin playback immediately. + * If the autoplay parameter is specified; the media player will begin playing + * the content when it is loaded. Even if autoplay is not specified;the media player + * implementation may choose to begin playback immediately. */ autoplay?: boolean; /** @@ -917,15 +1027,19 @@ declare namespace cast.framework.messages { */ credentials?: string; /** - * Optional credentials type. The type 'cloud' is a reserved type used by load requests that were originated by voice assistant commands. + * Optional credentials type. The type 'cloud' is a reserved type used by load + * requests that were originated by voice assistant commands. */ credentialsType?: string; /** - * Seconds since beginning of content. If the content is live content; and currentTime is not specified; the stream will start at the live position. + * Seconds since beginning of content. If the content is live content; and + * currentTime is not specified; the stream will start at the live position. */ currentTime?: number; /** - * If the autoplay parameter is specified; the media player will begin playing the content when it is loaded. Even if autoplay is not specified; the media player implementation may choose to begin playback immediately. + * If the autoplay parameter is specified; the media player will begin playing + * the content when it is loaded. Even if autoplay is not specified; + * the media player implementation may choose to begin playback immediately. */ media: MediaInformation; /** @@ -937,7 +1051,9 @@ declare namespace cast.framework.messages { */ queueData: QueueData; /** - * Application-specific data for this request. It enables the sender and receiver to easily extend the media protocol without having to use a new namespace with custom messages. + * Application-specific data for this request. + * It enables the sender and receiver to easily extend the media protocol + * without having to use a new namespace with custom messages. */ customData?: any; /** @@ -1058,7 +1174,8 @@ declare namespace cast.framework.messages { discNumber?: number; /** - * Content images. Examples would include cover art or a thumbnail of the currently playing media. + * Content images. Examples would include cover art or a thumbnail of the + * currently playing media. */ images: Image[]; @@ -1093,7 +1210,8 @@ declare namespace cast.framework.messages { */ interface MovieMediaMetadata { /** - * Content images. Examples would include cover art or a thumbnail of the currently playing media. + * Content images. Examples would include cover art or a thumbnail of the + * currently playing media. */ images: Image[]; @@ -1132,7 +1250,8 @@ declare namespace cast.framework.messages { activeTrackIds: number[]; /** - * Status of break; if receiver is playing break. This field will be defined only when receiver is playing break. + * Status of break; if receiver is playing break. + * This field will be defined only when receiver is playing break. */ breakStatus: BreakStatus; @@ -1167,12 +1286,14 @@ declare namespace cast.framework.messages { items: QueueItem[]; /** - * Seekable range of a live or event stream. It uses relative media time in seconds. It will be undefined for VOD streams. + * Seekable range of a live or event stream. It uses relative media time in seconds. + * It will be undefined for VOD streams. */ liveSeekableRange: LiveSeekableRange; /** - * ID of the media Item currently loading. If there is no item being loaded; it will be undefined. + * ID of the media Item currently loading. If there is no item being loaded; + * it will be undefined. */ loadingItemId?: number; @@ -1197,7 +1318,10 @@ declare namespace cast.framework.messages { playerState: PlayerState; /** - * ID of the next Item; only available if it has been preloaded. Media items can be preloaded and cached temporarily in memory; so when they are loaded later on; the process is faster (as the media does not have to be fetched from the network). + * ID of the next Item; only available if it has been preloaded. + * Media items can be preloaded and cached temporarily in memory; + * so when they are loaded later on; the process is faster + * (as the media does not have to be fetched from the network). */ preloadedItemId?: number; @@ -1216,9 +1340,6 @@ declare namespace cast.framework.messages { */ supportedMediaCommands: number; - /** - * - */ type: MessageType; /** @@ -1248,7 +1369,9 @@ declare namespace cast.framework.messages { */ interface MediaInformation { /** - * Partial list of break clips that includes current break clip that receiver is playing or ones that receiver will play shortly after; instead of sending whole list of clips. This is to avoid overflow of MediaStatus message. + * Partial list of break clips that includes current break clip that receiver + * is playing or ones that receiver will play shortly after; instead of sending + * whole list of clips. This is to avoid overflow of MediaStatus message. */ breakClips: BreakClip[]; @@ -1268,7 +1391,9 @@ declare namespace cast.framework.messages { contentType: string; /** - * Optional media url; to allow using contentId for real id. If contentUrl is provided; it will be used as media url; otherwise the contentId will be used as the media url. + * Optional media url; to allow using contentId for real id. If contentUrl + * is provided; it will be used as media url; otherwise the contentId will + * be used as the media url. */ contentUrl?: string; @@ -1318,12 +1443,16 @@ declare namespace cast.framework.messages { */ interface LoadRequestData extends RequestData { /** - * Array of trackIds that are active. If the array is not provided; the default tracks will be active. + * Array of trackIds that are active. If the array is not provided; the + * default tracks will be active. */ activeTrackIds: number[]; /** - * If the autoplay parameter is specified; the media player will begin playing the content when it is loaded. Even if autoplay is not specified;the media player implementation may choose to begin playback immediately. + * If the autoplay parameter is specified; the media player will begin + * playing the content when it is loaded. Even if autoplay is not + * specified;the media player implementation may choose to begin playback + * immediately. */ autoplay?: boolean; @@ -1333,17 +1462,21 @@ declare namespace cast.framework.messages { credentials?: string; /** - * Optional credentials type. The type 'cloud' is a reserved type used by load requests that were originated by voice assistant commands. + * Optional credentials type. The type 'cloud' is a reserved type used by + * load requests that were originated by voice assistant commands. */ credentialsType?: string; /** - * Seconds since beginning of content. If the content is live content; and currentTime is not specified; the stream will start at the live position. + * Seconds since beginning of content. If the content is live content; + * and currentTime is not specified; the stream will start at the live position. */ currentTime?: number; /** - * If the autoplay parameter is specified; the media player will begin playing the content when it is loaded. Even if autoplay is not specified; the media player implementation may choose to begin playback immediately. + * If the autoplay parameter is specified; the media player will begin playing + * the content when it is loaded. Even if autoplay is not specified; the media + * player implementation may choose to begin playback immediately. */ media: MediaInformation; @@ -1379,7 +1512,8 @@ declare namespace cast.framework.messages { } /** - * Provides live seekable range with start and end time in seconds and two more attributes. + * Provides live seekable range with start and end time in seconds and two more + * attributes. */ class LiveSeekableRange { constructor( @@ -1390,12 +1524,15 @@ declare namespace cast.framework.messages { ); /** - * A boolean value indicates whether a live stream is ended. If it is done; the end of live seekable range should stop updating. + * A boolean value indicates whether a live stream is ended. If it is done; + * the end of live seekable range should stop updating. */ isLiveDone?: boolean; /** - * A boolean value indicates whether the live seekable range is a moving window. If false; it will be either a expanding range or a fixed range meaning live has ended. + * A boolean value indicates whether the live seekable range is a moving window. + * If false; it will be either a expanding range or a fixed range meaning live + * has ended. */ isMovingWindow?: boolean; } @@ -1414,9 +1551,6 @@ declare namespace cast.framework.messages { */ requestId?: number; - /** - * - */ type: MessageType; } @@ -1466,7 +1600,8 @@ declare namespace cast.framework.messages { */ interface GenericMediaMetadata extends MediaMetadata { /** - * Content images. Examples would include cover art or a thumbnail of the currently playing media. + * Content images. Examples would include cover art or a thumbnail of the + * currently playing media. */ images: Image[]; @@ -1476,7 +1611,7 @@ declare namespace cast.framework.messages { releaseDate?: string; /** - *@deprecated - use @see{@link releaseDate} instead + * @deprecated - use @see{@link releaseDate} instead */ releaseYear?: number; @@ -1530,20 +1665,15 @@ declare namespace cast.framework.messages { opt_media?: MediaInformation ); - /** - * - */ media: MediaInformation; - /** - * - */ playerState: ExtendedPlayerState; } /** Event data for @see{@link EventType.ERROR} event. */ class ErrorEvent extends Event { constructor(detailedErrorCode?: DetailedErrorCode, error?: any); + /** * An error code representing the cause of the error. */ @@ -1552,7 +1682,8 @@ declare namespace cast.framework.messages { /** * The error object. * This could be an Error object (e.g.; if an Error was thrown in an event handler) - * or an object with error information (e.g.; if the receiver received an invalid command). + * or an object with error information (e.g.; if the receiver received an invalid + * command). */ error?: any; } @@ -1562,13 +1693,14 @@ declare namespace cast.framework.messages { /** * Application-specific data for this request. - * It enables the sender and receiver to easily extend the media protocol without having to use a new namespace with custom messages. + * It enables the sender and receiver to easily extend the media protocol + * without having to use a new namespace with custom messages. */ customData?: any; /** - Id of the request; used to correlate request/response. - */ + * Id of the request; used to correlate request/response. + */ requestId?: number; } @@ -1590,35 +1722,33 @@ declare namespace cast.framework.messages { enableTextTracks?: boolean; /** - * Indicates that the provided language was not explicit user request; but rather inferred from used language in voice query. + * Indicates that the provided language was not explicit user request; but rather + * inferred from used language in voice query. * It allows receiver apps to use user saved preference instead of spoken language. */ isSuggestedLanguage?: boolean; /** - * Language for the tracks that should be active. The language field will take precedence over activeTrackIds if both are specified. + * Language for the tracks that should be active. The language field will take + * precedence over activeTrackIds if both are specified. */ language?: string; - /** - * - */ textTrackStyle?: TextTrackStyle; } /** - * Media event EDIT_AUDIO_TRACKS request data. If language is not provided; the default audio track for the media will be enabled. + * Media event EDIT_AUDIO_TRACKS request data. If language is not provided; + * the default audio track for the media will be enabled. */ interface EditAudioTracksRequestData extends RequestData { /** - * Indicates that the provided language was not explicit user request; but rather inferred from used language in voice query. + * Indicates that the provided language was not explicit user request; + * but rather inferred from used language in voice query. * It allows receiver apps to use user saved preference instead of spoken language. */ isSuggestedLanguage?: boolean; - /** - * - */ language?: string; } @@ -1694,7 +1824,8 @@ declare namespace cast.framework.messages { contentType?: string; /** * Optional break media url; to allow using contentId for real id. - * If contentUrl is provided; it will be used as media url; otherwise the contentId will be used as the media url. + * If contentUrl is provided; it will be used as media url; + * otherwise the contentId will be used as the media url. */ contentUrl?: string; /** @@ -1751,13 +1882,16 @@ declare namespace cast.framework.messages { /** * If true; indicates this is embedded break in main stream. */ + isEmbedded?: boolean; /** * Whether break is watched. - * Sender can change color of progress bar marker corresponding to this break once this field changes from false to true; + * Sender can change color of progress bar marker corresponding to this break once + * this field changes from false to true; * denoting that the end-user already watched this break. */ isWatched: boolean; + /** * Where the break is located inside main video. -1 represents the end of main video. */ diff --git a/types/chromecast-caf-receiver/cast.framework.system.d.ts b/types/chromecast-caf-receiver/cast.framework.system.d.ts index 92e7732f7f..d055e252fb 100644 --- a/types/chromecast-caf-receiver/cast.framework.system.d.ts +++ b/types/chromecast-caf-receiver/cast.framework.system.d.ts @@ -5,7 +5,7 @@ declare namespace cast.framework.system { type EventType = // Fired when the system is ready. | "READY" - // Fired when the application is terminated. + // Fired when the application is terminated | "SHUTDOWN" // Fired when a new sender has connected. | "SENDER_CONNECTED" @@ -15,9 +15,19 @@ declare namespace cast.framework.system { | "ERROR" // Fired when the system volume has changed. | "SYSTEM_VOLUME_CHANGED" - // Fired when the visibility of the application has changed (for example after a HDMI Input change or when the TV is turned off/on and the cast device is externally powered). Note that this API has the same effect as the webkitvisibilitychange event raised by your document, we provided it as CastReceiverManager API for convenience and to avoid a dependency on a webkit-prefixed event. + // Fired when the visibility of the application has changed + // (for example after a HDMI Input change or when the TV is turned + // off/on and the cast device is externally powered). + // Note that this API has the same effect as the webkitvisibilitychange event raised + // by your document, we provided it as CastReceiverManager API for convenience and + // to avoid a dependency on a webkit-prefixed event. | "VISIBILITY_CHANGED" - // Fired when the standby state of the TV has changed. This event is related to the visibility chnaged event, as if the TV is in standby the visibility will be false, the visibility is more granular (as it also detects that the TV has selected a different channel) but it is not reliably detected in all TVs, standby can be used in those cases as most TVs implement it. + // Fired when the standby state of the TV has changed. + // This event is related to the visibility chnaged event, as if the TV is in standby + // the visibility will be false, the visibility is more granular + // (as it also detects that the TV has selected a different channel) + // but it is not reliably detected in all TVs, + // standby can be used in those cases as most TVs implement it. | "STANDBY_CHANGED" | "MAX_VIDEO_RESOLUTION_CHANGED" | "FEEDBACK_STARTED"; @@ -51,7 +61,7 @@ declare namespace cast.framework.system { */ interface SystemVolumeData { /** - * The level (from 0.0 to 1.0) of the system volume. + * The level (from 0.0 to 1.0) of the system volume */ level: number; @@ -77,9 +87,6 @@ declare namespace cast.framework.system { class StandbyChangedEvent { constructor(isStandby: boolean); - /** - * - */ isStandby: boolean; } /** @@ -136,7 +143,7 @@ declare namespace cast.framework.system { id: string; /** - * Indicate the sender supports large messages (>64KB). + * Indicate the sender supports large messages (>64KB) */ largeMessageSupported?: boolean; diff --git a/types/chromecast-caf-receiver/cast.framework.ui.d.ts b/types/chromecast-caf-receiver/cast.framework.ui.d.ts index b13f036be2..77d93c8082 100644 --- a/types/chromecast-caf-receiver/cast.framework.ui.d.ts +++ b/types/chromecast-caf-receiver/cast.framework.ui.d.ts @@ -50,9 +50,6 @@ declare namespace cast.framework.ui { */ field: string; - /** - * - */ type: PlayerDataEventType; /** @@ -61,7 +58,8 @@ declare namespace cast.framework.ui { value: any; } /** - * Player data binder. Bind a player data object to the player state. The player data will be updated to reflect correctly the current player state without firing any change event. + * Player data binder. Bind a player data object to the player state. + * The player data will be updated to reflect correctly the current player state without firing any change event. */ class PlayerDataBinder { constructor(playerData: PlayerData); @@ -107,7 +105,17 @@ declare namespace cast.framework.ui { currentTime: number; /** - * Whether the player metadata (ie: title; currentTime) should be displayed. This will be true if at least one field in the metadata should be displayed. In some cases; displayStatus will be true; but parts of the metadata should be hidden (ie: the media title while media is seeking). In these cases; additional css can be applied to hide those elements. For cases where the media is audio-only; this will almost always be true. In cases where the media is video; this will be true when: (1) the video is loading; buffering; or seeking (2) a play request was made in the last five seconds while media is already playing; (3) there is a request made to show the status in the last five seconds; or (4) the media was paused in the last five seconds. + * Whether the player metadata (ie: title; currentTime) should be displayed. + * This will be true if at least one field in the metadata should be displayed. + * In some cases; displayStatus will be true; but parts of the metadata should be hidden + * (ie: the media title while media is seeking). + * In these cases; additional css can be applied to hide those elements. + * For cases where the media is audio-only; this will almost always be true. + * In cases where the media is video; this will be true when: + * (1) the video is loading; buffering; or seeking + * (2) a play request was made in the last five seconds while media is already playing; + * (3) there is a request made to show the status in the last five seconds; or + * (4) the media was paused in the last five seconds. */ displayStatus: boolean; diff --git a/types/chromecast-caf-receiver/tslint.json b/types/chromecast-caf-receiver/tslint.json index f85a173bd5..495d29983d 100644 --- a/types/chromecast-caf-receiver/tslint.json +++ b/types/chromecast-caf-receiver/tslint.json @@ -1,8 +1,5 @@ { "extends": "dtslint/dt.json", "rules": { - "no-redundant-jsdoc-2": false, - "jsdoc-format": false, - "max-line-length": false } } From f9ec668d5982ab153ef6c174ee731a39c880e47e Mon Sep 17 00:00:00 2001 From: Craig Bruce <“craigrbruce@gmail.com”> Date: Fri, 8 Jun 2018 14:25:02 +1000 Subject: [PATCH 5/5] Fix current media time type in BreaksEvent --- types/chromecast-caf-receiver/cast.framework.events.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/chromecast-caf-receiver/cast.framework.events.d.ts b/types/chromecast-caf-receiver/cast.framework.events.d.ts index 0ad1bfee8c..0c69727a05 100644 --- a/types/chromecast-caf-receiver/cast.framework.events.d.ts +++ b/types/chromecast-caf-receiver/cast.framework.events.d.ts @@ -378,7 +378,7 @@ declare namespace cast.framework.events { /** * The time in the currently playing media when the break event occurred. */ - currentMediaTime?: string; + currentMediaTime?: number; /** * The reason the break clip ended.