mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 12:30:18 +00:00
Improve PlayerData in chromecast-caf-receiver (#36287)
* Improve PlayerData in chromecast-caf-receiver Improve PlayerDataEventType (taken directly from the Chromecast) and the PlayerDataBinder constructor (can be checked in documentation here https://developers.google.com/cast/docs/reference/caf_receiver/cast.framework.ui.PlayerDataBinder#constructor_1 ) PlayerData needs to be instantiatable as well (see screenshot showing it is a constructor). * Fix test * Update all classes and enums accessible from PlayerData * Remove package.json * Fix tests * Update tests
This commit is contained in:
committed by
Daniel Rosenwasser
parent
0a252fb08b
commit
4f3e646ab1
+161
-152
@@ -1,55 +1,39 @@
|
||||
import { Event, DetailedErrorCode } from "./cast.framework.events";
|
||||
import { Event, DetailedErrorCode } from './cast.framework.events';
|
||||
|
||||
export as namespace messages;
|
||||
export type UserAction =
|
||||
| "LIKE"
|
||||
| "DISLIKE"
|
||||
| "FOLLOW"
|
||||
| "UNFOLLOW"
|
||||
| "FLAG"
|
||||
| "SKIP_AD";
|
||||
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";
|
||||
| 'UNKNOWN_CONTEXT'
|
||||
| 'ALBUM'
|
||||
| 'ARTIST'
|
||||
| 'PLAYLIST'
|
||||
| 'EPISODE'
|
||||
| 'SERIES'
|
||||
| 'MOVIE'
|
||||
| 'CHANNEL'
|
||||
| 'TEAM'
|
||||
| 'PLAYER'
|
||||
| 'COACH';
|
||||
|
||||
export type TextTrackType =
|
||||
| "SUBTITLES"
|
||||
| "CAPTIONS"
|
||||
| "DESCRIPTIONS"
|
||||
| "CHAPTERS"
|
||||
| "METADATA";
|
||||
export type TextTrackType = 'SUBTITLES' | 'CAPTIONS' | 'DESCRIPTIONS' | 'CHAPTERS' | 'METADATA';
|
||||
|
||||
export type TextTrackWindowType = "NONE" | "NORMAL" | "ROUNDED_CORNERS";
|
||||
export type TextTrackWindowType = 'NONE' | 'NORMAL' | 'ROUNDED_CORNERS';
|
||||
|
||||
export type TrackType = "TEXT" | "AUDIO" | "VIDEO";
|
||||
export type TrackType = 'TEXT' | 'AUDIO' | 'VIDEO';
|
||||
|
||||
export type TextTrackFontGenericFamily =
|
||||
| "SANS_SERIF"
|
||||
| "MONOSPACED_SANS_SERIF"
|
||||
| "SERIF"
|
||||
| "MONOSPACED_SERIF"
|
||||
| "CASUAL"
|
||||
| "CURSIVE"
|
||||
| "SMALL_CAPITALS";
|
||||
| 'SANS_SERIF'
|
||||
| 'MONOSPACED_SANS_SERIF'
|
||||
| 'SERIF'
|
||||
| 'MONOSPACED_SERIF'
|
||||
| 'CASUAL'
|
||||
| 'CURSIVE'
|
||||
| 'SMALL_CAPITALS';
|
||||
|
||||
export type TextTrackFontStyle = "NORMAL" | "BOLD" | "BOLD_ITALIC" | "ITALIC";
|
||||
export type TextTrackFontStyle = 'NORMAL' | 'BOLD' | 'BOLD_ITALIC' | 'ITALIC';
|
||||
|
||||
export type TextTrackEdgeType =
|
||||
| "NONE"
|
||||
| "OUTLINE"
|
||||
| "DROP_SHADOW"
|
||||
| "RAISED"
|
||||
| "DEPRESSED";
|
||||
export type TextTrackEdgeType = 'NONE' | 'OUTLINE' | 'DROP_SHADOW' | 'RAISED' | 'DEPRESSED';
|
||||
|
||||
export namespace Command {
|
||||
const ALL_BASIC_MEDIA: number;
|
||||
@@ -73,128 +57,111 @@ export namespace Command {
|
||||
const UNFOLLOW: number;
|
||||
}
|
||||
|
||||
export type SeekResumeState = "PLAYBACK_START" | "PLAYBACK_PAUSE";
|
||||
export type SeekResumeState = 'PLAYBACK_START' | 'PLAYBACK_PAUSE';
|
||||
|
||||
export type StreamingProtocolType =
|
||||
| "UNKNOWN"
|
||||
| "MPEG_DASH"
|
||||
| "HLS"
|
||||
| "SMOOTH_STREAMING";
|
||||
export type StreamingProtocolType = 'UNKNOWN' | 'MPEG_DASH' | 'HLS' | 'SMOOTH_STREAMING';
|
||||
|
||||
export type StreamType = "BUFFERED" | "LIVE" | "NONE";
|
||||
export type StreamType = 'BUFFERED' | 'LIVE' | 'NONE';
|
||||
|
||||
export type FocusState = "IN_FOCUS" | "NOT_IN_FOCUS";
|
||||
export type FocusState = 'IN_FOCUS' | 'NOT_IN_FOCUS';
|
||||
|
||||
export type ExtendedPlayerState = "LOADING";
|
||||
export type ExtendedPlayerState = 'LOADING';
|
||||
|
||||
export type ErrorType =
|
||||
| "INVALID_PLAYER_STATE"
|
||||
| "LOAD_FAILED"
|
||||
| "LOAD_CANCELLED"
|
||||
| "INVALID_REQUEST"
|
||||
| "ERROR";
|
||||
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";
|
||||
| '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 enum RepeatMode {
|
||||
REPEAT_ALL = 'REPEAT_ALL',
|
||||
REPEAT_ALL_AND_SHUFFLE = 'REPEAT_ALL_AND_SHUFFLE',
|
||||
REPEAT_OFF = 'REPEAT_OFF',
|
||||
REPEAT_SINGLE = 'REPEAT_SINGLE',
|
||||
}
|
||||
|
||||
export type IdleReason = "CANCELLED" | "INTERRUPTED" | "FINISHED" | "ERROR";
|
||||
export type IdleReason = 'CANCELLED' | 'INTERRUPTED' | 'FINISHED' | 'ERROR';
|
||||
|
||||
export type HlsSegmentFormat =
|
||||
| "aac"
|
||||
| "ac3"
|
||||
| "e_ac3"
|
||||
| "fmp4"
|
||||
| "mp3"
|
||||
| "ts"
|
||||
| "ts_aac";
|
||||
export type HlsSegmentFormat = 'aac' | 'ac3' | 'e_ac3' | 'fmp4' | 'mp3' | 'ts' | 'ts_aac';
|
||||
|
||||
export type HdrType = "sdr" | "hdr" | "dv";
|
||||
export type HdrType = 'sdr' | 'hdr' | 'dv';
|
||||
|
||||
export type PlayStringId =
|
||||
| "FREE_TRIAL_ABOUT_TO_EXPIRE"
|
||||
| "SUBSCRIPTION_ABOUT_TO_EXPIRE"
|
||||
| "STREAM_HIJACKED";
|
||||
export type PlayStringId = 'FREE_TRIAL_ABOUT_TO_EXPIRE' | 'SUBSCRIPTION_ABOUT_TO_EXPIRE' | 'STREAM_HIJACKED';
|
||||
|
||||
export type GetStatusOptions = "NO_METADATA" | "NO_QUEUE_ITEMS";
|
||||
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";
|
||||
| '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 PlayerState = 'IDLE' | 'PLAYING' | 'PAUSED' | 'BUFFERING';
|
||||
|
||||
export type QueueChangeType =
|
||||
| "INSERT"
|
||||
| "REMOVE"
|
||||
| "ITEMS_CHANGE"
|
||||
| "UPDATE"
|
||||
| "NO_CHANGE";
|
||||
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 enum QueueType {
|
||||
ALBUM = 'ALBUM',
|
||||
AUDIOBOOK = 'AUDIOBOOK',
|
||||
LIVE_TV = 'LIVE_TV',
|
||||
MOVIE = 'MOVIE',
|
||||
PLAYLIST = 'PLAYLIST',
|
||||
PODCAST_SERIES = 'PODCAST_SERIES',
|
||||
RADIO_STATION = 'RADIO_STATION',
|
||||
TV_SERIES = 'TV_SERIES',
|
||||
VIDEO_PLAYLIST = 'VIDEO_PLAYLIST',
|
||||
}
|
||||
|
||||
export enum ContainerType {
|
||||
GENERIC_CONTAINER = 0,
|
||||
AUDIOBOOK_CONTAINER = 1,
|
||||
}
|
||||
|
||||
export enum MetadataType {
|
||||
GENERIC = 0,
|
||||
@@ -202,7 +169,13 @@ export enum MetadataType {
|
||||
TV_SHOW = 2,
|
||||
MUSIC_TRACK = 3,
|
||||
PHOTO = 4,
|
||||
AUDIOBOOK_CHAPTER = 5
|
||||
AUDIOBOOK_CHAPTER = 5,
|
||||
}
|
||||
|
||||
export enum MediaCategory {
|
||||
AUDIO = 'AUDIO',
|
||||
IMAGE = 'IMAGE',
|
||||
VIDEO = 'VIDEO',
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -873,6 +846,37 @@ export class QueueIds {
|
||||
type: MessageType;
|
||||
}
|
||||
|
||||
export class ContainerMetadata {
|
||||
constructor(type?: ContainerType);
|
||||
|
||||
/**
|
||||
* Container duration in seconds. For example an audiobook playback time.
|
||||
*/
|
||||
containerDuration?: number;
|
||||
|
||||
/**
|
||||
* Container images. For example a live TV channel logo, audiobook cover,
|
||||
* album cover art, etc.
|
||||
*/
|
||||
containerImages?: Image[];
|
||||
|
||||
/**
|
||||
* The type of container object.
|
||||
*/
|
||||
containerType: ContainerType;
|
||||
|
||||
/**
|
||||
* Array of media metadata objects to describe the media content sections.
|
||||
* Used to delineate live TV streams into programs and audiobooks into chapters.
|
||||
*/
|
||||
sections?: MediaMetadata[];
|
||||
|
||||
/**
|
||||
* The title of the container, for example an audiobook title, a TV channel name, etc.
|
||||
*/
|
||||
title?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Queue data as part of the LOAD request.
|
||||
*/
|
||||
@@ -887,6 +891,11 @@ export class QueueData {
|
||||
startTime?: number
|
||||
);
|
||||
|
||||
/**
|
||||
* Metadata to describe the queue content, and optionally media sections.
|
||||
*/
|
||||
containerMetadata?: ContainerMetadata;
|
||||
|
||||
/**
|
||||
* Description of the queue.
|
||||
*/
|
||||
@@ -922,6 +931,11 @@ export class QueueData {
|
||||
*/
|
||||
repeatMode?: RepeatMode;
|
||||
|
||||
/**
|
||||
* Indicate if the queue is shuffled.
|
||||
*/
|
||||
shuffle?: boolean;
|
||||
|
||||
/**
|
||||
* The index of the item in the queue that should be used to start playback first.
|
||||
*/
|
||||
@@ -1555,12 +1569,7 @@ export class LoadByEntityRequestData {
|
||||
* attributes.
|
||||
*/
|
||||
export class LiveSeekableRange {
|
||||
constructor(
|
||||
start?: number,
|
||||
end?: number,
|
||||
isMovingWindow?: boolean,
|
||||
isLiveDone?: boolean
|
||||
);
|
||||
constructor(start?: number, end?: number, isMovingWindow?: boolean, isLiveDone?: boolean);
|
||||
|
||||
/**
|
||||
* A boolean value indicates whether a live stream is ended. If it is done;
|
||||
|
||||
+162
-47
@@ -1,40 +1,85 @@
|
||||
import { PlayerDataEventType } from "./cast.framework.ui";
|
||||
import { MediaMetadata } from "./cast.framework.messages";
|
||||
import {
|
||||
MediaMetadata,
|
||||
LiveSeekableRange,
|
||||
MediaInformation,
|
||||
MediaCategory,
|
||||
QueueData,
|
||||
} from './cast.framework.messages';
|
||||
import { CastReceiverContext } from './cast.framework';
|
||||
|
||||
export as namespace ui
|
||||
export type ContentType = "video" | "audio" | "image";
|
||||
export as namespace ui;
|
||||
export type ContentType = 'video' | 'audio' | 'image';
|
||||
|
||||
export type State =
|
||||
| "launching"
|
||||
| "idle"
|
||||
| "loading"
|
||||
| "buffering"
|
||||
| "paused"
|
||||
| "playing";
|
||||
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";
|
||||
export enum PlayerDataEventType {
|
||||
ACTIVE_TRACK_IDS_CHANGED = 'activeTrackIdsChanged',
|
||||
ANY_CHANGE = '*',
|
||||
APPLICATION_DATA_CHANGED = 'applicationDataChanged',
|
||||
BREAK_PERCENTAGE_POSITIONS_CHANGED = 'breakPercentagePositionsChanged',
|
||||
BREAK_TITLE_CHANGED = 'breakTitleChanged',
|
||||
CONTENT_TYPE_CHANGED = 'contentTypeChanged',
|
||||
CURRENT_BREAK_CLIP_NUMBER_CHANGED = 'currentBreakClipNumberChanged',
|
||||
CURRENT_TIME_CHANGED = 'currentTimeChanged',
|
||||
CUSTOM_STATE_CHANGED = 'customStateChanged',
|
||||
DISPLAY_STATUS_CHANGED = 'displayStatusChanged',
|
||||
DISPLAY_TYPE_CHANGED = 'displayTypeChanged',
|
||||
DURATION_CHANGED = 'durationChanged',
|
||||
IS_AT_LIVE_EDGE_CHANGED = 'isAtLiveEdgeChanged',
|
||||
IS_BREAK_SKIPPABLE_CHANGED = 'isBreakSkippableChanged',
|
||||
IS_LIVE_CHANGED = 'isLiveChanged',
|
||||
IS_PLAYING_BREAK_CHANGED = 'isPlayingBreakChanged',
|
||||
IS_SEEKING_CHANGED = 'isSeekingChanged',
|
||||
LIVE_SEEKABLE_RANGE_CHANGED = 'liveSeekableRangeChanged',
|
||||
MEDIA_CATEGORY_CHANGED = 'mediaCategoryChanged',
|
||||
MEDIA_CHANGED = 'mediaChanged',
|
||||
MEDIA_SESSION_ID_CHANGED = 'mediaSessionIdChanged',
|
||||
MEDIA_START_ABSOLUTE_TIME_CHANGED = 'mediaStartAbsoluteTimeChanged',
|
||||
METADATA_CHANGED = 'metadataChanged',
|
||||
NEXT_SUBTITLE_CHANGED = 'nextSubtitleChanged',
|
||||
NEXT_THUMBNAIL_URL_CHANGED = 'nextThumbnailUrlChanged',
|
||||
NEXT_TITLE_CHANGED = 'nextTitleChanged',
|
||||
NUMBER_BREAK_CLIPS_CHANGED = 'numberBreakClipsChanged',
|
||||
PLAYBACK_RATE_CHANGED = 'playbackRateChanged',
|
||||
PRELOADING_NEXT_CHANGED = 'preloadingNextChanged',
|
||||
PRESENTATION_CHANGED = 'presentationChanged',
|
||||
QUEUE_DATA_CHANGED = 'queueDataChanged',
|
||||
SECTION_DURATION_CHANGED = 'sectionDurationChanged',
|
||||
SECTION_START_TIME_IN_MEDIA_CHANGED = 'sectionStartTimeInMediaChanged',
|
||||
STATE_CHANGED = 'stateChanged',
|
||||
SUBTITLE_CHANGED = 'subtitleChanged',
|
||||
SUPPORTED_MEDIA_COMMANDS_CHANGED = 'supportedMediaCommandsChanged',
|
||||
THUMBNAIL_URL_CHANGED = 'thumbnailUrlChanged',
|
||||
TITLE_CHANGED = 'titleChanged',
|
||||
WHEN_SKIPPABLE_CHANGED = 'whenSkippableChanged',
|
||||
}
|
||||
|
||||
/**
|
||||
* Data about running application or remote controlled application.
|
||||
*/
|
||||
export class ApplicationData {
|
||||
constructor(name: string, iconUrl: string, groupName?: string, isRemoteControl?: boolean);
|
||||
|
||||
/**
|
||||
* Name of audio group for running app.
|
||||
*/
|
||||
groupName: string;
|
||||
|
||||
/**
|
||||
* Application icon URL
|
||||
*/
|
||||
iconUrl: string;
|
||||
|
||||
/**
|
||||
* Whether the application is running as a remote control to another playback receiver;
|
||||
*/
|
||||
isRemoteControl: boolean;
|
||||
|
||||
/**
|
||||
* Application name.
|
||||
*/
|
||||
name: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Player data changed event. Provides the changed field (type); and new value.
|
||||
@@ -59,37 +104,43 @@ export class PlayerDataChangedEvent {
|
||||
* The player data will be updated to reflect correctly the current player state without firing any change event.
|
||||
*/
|
||||
export class PlayerDataBinder {
|
||||
constructor(playerData: PlayerData);
|
||||
constructor(playerData: object | PlayerData);
|
||||
|
||||
/**
|
||||
* Add listener to player data changes.
|
||||
*/
|
||||
addEventListener: (
|
||||
type: PlayerDataEventType,
|
||||
listener: PlayerDataChangedEventHandler
|
||||
) => void;
|
||||
addEventListener: (type: PlayerDataEventType, listener: PlayerDataChangedEventHandler) => void;
|
||||
|
||||
/**
|
||||
* Remove listener to player data changes.
|
||||
*/
|
||||
removeEventListener: (
|
||||
type: PlayerDataEventType,
|
||||
listener: PlayerDataChangedEventHandler
|
||||
) => void;
|
||||
removeEventListener: (type: PlayerDataEventType, listener: PlayerDataChangedEventHandler) => void;
|
||||
}
|
||||
/**
|
||||
* Player data. Provide the player media and break state.
|
||||
*/
|
||||
export interface PlayerData {
|
||||
export class PlayerData {
|
||||
constructor();
|
||||
|
||||
/**
|
||||
* Active track ids of current media.
|
||||
*/
|
||||
activeTrackIds: number[];
|
||||
|
||||
/**
|
||||
* Application data.
|
||||
*/
|
||||
applicationData?: ApplicationData;
|
||||
|
||||
/**
|
||||
* Array of breaks positions in percentage.
|
||||
*/
|
||||
breakPercentagePositions: number[];
|
||||
|
||||
/**
|
||||
* Content Type.
|
||||
* Title of the current playing break;
|
||||
*/
|
||||
contentType: ContentType;
|
||||
breakTitle: string;
|
||||
|
||||
/**
|
||||
* The number of the current playing break clip in the break.
|
||||
@@ -101,6 +152,13 @@ export interface PlayerData {
|
||||
*/
|
||||
currentTime: number;
|
||||
|
||||
/**
|
||||
* User custom state, Should be used to separate playback and UI logic, to allow
|
||||
* same UI code to run in a remote control. The state can be set by calling
|
||||
* cast.framework.PlayerManager#sendCustomState
|
||||
*/
|
||||
customState?: object;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
@@ -116,11 +174,21 @@ export interface PlayerData {
|
||||
*/
|
||||
displayStatus: boolean;
|
||||
|
||||
/**
|
||||
* Property to differentiate between different screen types. TV is default.
|
||||
*/
|
||||
displayType: string;
|
||||
|
||||
/**
|
||||
* Media duration in seconds; Or break duration if playing break.
|
||||
*/
|
||||
duration: number;
|
||||
|
||||
/**
|
||||
* Indicate if the media stream is playing at live edge.
|
||||
*/
|
||||
isAtLiveEdge: boolean;
|
||||
|
||||
/**
|
||||
* Indicate break clip can be skipped.
|
||||
*/
|
||||
@@ -141,10 +209,37 @@ export interface PlayerData {
|
||||
*/
|
||||
isSeeking: boolean;
|
||||
|
||||
/**
|
||||
* Indicate the seekable range of the content if it is a live stream.
|
||||
*/
|
||||
liveSeekableRange?: LiveSeekableRange;
|
||||
|
||||
/**
|
||||
* Current media information.
|
||||
*/
|
||||
media?: MediaInformation;
|
||||
|
||||
/**
|
||||
* The media category (video, audio, or image).
|
||||
*/
|
||||
mediaCategory?: MediaCategory;
|
||||
|
||||
/**
|
||||
* Unique id for media session. It is updated when a new load request is received.
|
||||
*/
|
||||
mediaSessionId: number;
|
||||
|
||||
/**
|
||||
* Indicates absolute time (Epoch time in seconds) for live streams. For live event
|
||||
* it would be the time the event started, otherwise it will be start of the
|
||||
* seekable range when the streaming started.
|
||||
*/
|
||||
mediaStartAbsoluteTime?: number;
|
||||
|
||||
/**
|
||||
* Media metadata.
|
||||
*/
|
||||
metadata: MediaMetadata;
|
||||
metadata?: MediaMetadata | object;
|
||||
|
||||
/**
|
||||
* Next Item subtitle.
|
||||
@@ -166,11 +261,31 @@ export interface PlayerData {
|
||||
*/
|
||||
numberBreakClips: number;
|
||||
|
||||
/**
|
||||
* Media playback rate.
|
||||
*/
|
||||
playbackRate: number;
|
||||
|
||||
/**
|
||||
* Flag to show/hide next item metadata.
|
||||
*/
|
||||
preloadingNext: boolean;
|
||||
|
||||
/**
|
||||
* Queue data.
|
||||
*/
|
||||
queueData?: QueueData;
|
||||
|
||||
/**
|
||||
* Indicate the section duration in seconds.
|
||||
*/
|
||||
sectionDuration?: number;
|
||||
|
||||
/**
|
||||
* Indicate the section start time, in media time in seconds.
|
||||
*/
|
||||
sectionStartTimeInMedia?: number;
|
||||
|
||||
/**
|
||||
* Current player state.
|
||||
*/
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import { MediaMetadata } from "chromecast-caf-receiver/cast.framework.messages";
|
||||
import { MediaMetadata } from 'chromecast-caf-receiver/cast.framework.messages';
|
||||
|
||||
// The following test showcases how you can import individual types directly from the namespace:
|
||||
|
||||
const mediaMetadata = new MediaMetadata(
|
||||
cast.framework.messages.MetadataType.GENERIC
|
||||
);
|
||||
const mediaMetadata = new MediaMetadata(cast.framework.messages.MetadataType.GENERIC);
|
||||
mediaMetadata.metadataType = cast.framework.messages.MetadataType.TV_SHOW;
|
||||
|
||||
// The following tests showcase how you can globally access 'cast' types using
|
||||
@@ -12,23 +10,23 @@ mediaMetadata.metadataType = cast.framework.messages.MetadataType.TV_SHOW;
|
||||
// conforms exactly to the CAF documentation.
|
||||
|
||||
// tslint:disable-next-line
|
||||
const breaksEvent = new cast.framework.events.BreaksEvent("BREAK_STARTED");
|
||||
breaksEvent.breakId = "some-break-id";
|
||||
breaksEvent.breakClipId = "some-break-clip-id";
|
||||
const breaksEvent = new cast.framework.events.BreaksEvent('BREAK_STARTED');
|
||||
breaksEvent.breakId = 'some-break-id';
|
||||
breaksEvent.breakClipId = 'some-break-clip-id';
|
||||
|
||||
// tslint:disable-next-line
|
||||
const track = new cast.framework.messages.Track(1, "TEXT");
|
||||
const track = new cast.framework.messages.Track(1, 'TEXT');
|
||||
// tslint:disable-next-line
|
||||
const breakClip = new cast.framework.messages.BreakClip("id");
|
||||
const breakClip = new cast.framework.messages.BreakClip('id');
|
||||
// tslint:disable-next-line
|
||||
const adBreak = new cast.framework.messages.Break("id", ["id"], 1);
|
||||
const adBreak = new cast.framework.messages.Break('id', ['id'], 1);
|
||||
// tslint:disable-next-line
|
||||
const rEvent = new cast.framework.events.RequestEvent("BITRATE_CHANGED", {
|
||||
requestId: 2
|
||||
const rEvent = new cast.framework.events.RequestEvent('BITRATE_CHANGED', {
|
||||
requestId: 2,
|
||||
});
|
||||
// tslint:disable-next-line
|
||||
const pManager = new cast.framework.PlayerManager();
|
||||
pManager.addEventListener("STALLED", () => {});
|
||||
pManager.addEventListener('STALLED', () => {});
|
||||
pManager.addEventListener(cast.framework.events.category.CORE, () => {});
|
||||
pManager.addEventListener(cast.framework.events.category.DEBUG, () => {});
|
||||
pManager.addEventListener(cast.framework.events.category.FINE, () => {});
|
||||
@@ -43,9 +41,7 @@ const items = qBase.fetchItems(1, 3, 4);
|
||||
// tslint:disable-next-line
|
||||
const breakSeekData = new cast.framework.breaks.BreakSeekData(0, 100, []);
|
||||
// tslint:disable-next-line
|
||||
const breakClipLoadContext = new cast.framework.breaks.BreakClipLoadInterceptorContext(
|
||||
adBreak
|
||||
);
|
||||
const breakClipLoadContext = new cast.framework.breaks.BreakClipLoadInterceptorContext(adBreak);
|
||||
// tslint:disable-next-line
|
||||
const breakManager: cast.framework.breaks.BreakManager = {
|
||||
getBreakById: () => adBreak,
|
||||
@@ -56,7 +52,7 @@ const breakManager: cast.framework.breaks.BreakManager = {
|
||||
setBreakClipLoadInterceptor: () => {},
|
||||
setBreakSeekInterceptor: () => {},
|
||||
setPlayWatchedBreak: () => {},
|
||||
setVastTrackingInterceptor: () => {}
|
||||
setVastTrackingInterceptor: () => {},
|
||||
};
|
||||
|
||||
// tslint:disable-next-line
|
||||
@@ -66,59 +62,57 @@ lrd.activeTrackIds = [1, 2];
|
||||
lrd.media = {
|
||||
tracks: [],
|
||||
textTrackStyle: {},
|
||||
streamType: "BUFFERED",
|
||||
streamType: 'BUFFERED',
|
||||
metadata: {
|
||||
metadataType: cast.framework.messages.MetadataType.GENERIC
|
||||
metadataType: cast.framework.messages.MetadataType.GENERIC,
|
||||
},
|
||||
hlsSegmentFormat: "aac",
|
||||
contentId: "id",
|
||||
contentType: "type",
|
||||
hlsSegmentFormat: 'aac',
|
||||
contentId: 'id',
|
||||
contentType: 'type',
|
||||
breakClips: [breakClip],
|
||||
breaks: [adBreak]
|
||||
breaks: [adBreak],
|
||||
};
|
||||
lrd.queueData = {};
|
||||
|
||||
// tslint:disable-next-line
|
||||
const appData: cast.framework.system.ApplicationData = {
|
||||
id: () => "id",
|
||||
launchingSenderId: () => "launch-id",
|
||||
name: () => "name",
|
||||
namespaces: () => ["namespace"],
|
||||
sessionId: () => 1
|
||||
id: () => 'id',
|
||||
launchingSenderId: () => 'launch-id',
|
||||
name: () => 'name',
|
||||
namespaces: () => ['namespace'],
|
||||
sessionId: () => 1,
|
||||
};
|
||||
|
||||
// tslint:disable-next-line
|
||||
const readyEvent = new cast.framework.system.ReadyEvent(appData);
|
||||
const data = readyEvent.data;
|
||||
// tslint:disable-next-line
|
||||
const pData: cast.framework.ui.PlayerData = {
|
||||
breakPercentagePositions: [1],
|
||||
contentType: "video",
|
||||
currentBreakClipNumber: 2,
|
||||
currentTime: 1234,
|
||||
displayStatus: true,
|
||||
duration: 222,
|
||||
isBreakSkippable: false,
|
||||
isLive: true,
|
||||
isPlayingBreak: false,
|
||||
isSeeking: true,
|
||||
// tslint:disable-next-line
|
||||
metadata: new cast.framework.messages.MediaMetadata(
|
||||
cast.framework.messages.MetadataType.GENERIC
|
||||
),
|
||||
nextSubtitle: "sub",
|
||||
nextThumbnailUrl: "url",
|
||||
nextTitle: "title",
|
||||
numberBreakClips: 3,
|
||||
preloadingNext: false,
|
||||
state: "paused",
|
||||
thumbnailUrl: "url",
|
||||
title: "title",
|
||||
whenSkippable: 321
|
||||
};
|
||||
const pData = new cast.framework.ui.PlayerData();
|
||||
pData.breakPercentagePositions = [1];
|
||||
pData.currentBreakClipNumber = 2;
|
||||
pData.currentTime = 1234;
|
||||
pData.displayStatus = true;
|
||||
pData.duration = 222;
|
||||
pData.isBreakSkippable = false;
|
||||
pData.isLive = true;
|
||||
pData.isPlayingBreak = false;
|
||||
pData.isSeeking = true;
|
||||
// tslint=disable-next-lin;
|
||||
pData.metadata = new cast.framework.messages.MediaMetadata(cast.framework.messages.MetadataType.GENERIC);
|
||||
pData.nextSubtitle = 'sub';
|
||||
pData.nextThumbnailUrl = 'url';
|
||||
pData.nextTitle = 'title';
|
||||
pData.numberBreakClips = 3;
|
||||
pData.preloadingNext = false;
|
||||
pData.state = 'paused';
|
||||
pData.thumbnailUrl = 'url';
|
||||
pData.title = 'title';
|
||||
pData.whenSkippable = 321;
|
||||
|
||||
// tslint:disable-next-line
|
||||
const binder = new cast.framework.ui.PlayerDataBinder(pData);
|
||||
binder.addEventListener("ANY_CHANGE", e => {});
|
||||
const playerDataBinderWithPlayerData = new cast.framework.ui.PlayerDataBinder(pData);
|
||||
const binder = new cast.framework.ui.PlayerDataBinder({});
|
||||
binder.addEventListener(cast.framework.ui.PlayerDataEventType.ANY_CHANGE, e => {});
|
||||
// tslint:disable-next-line
|
||||
const supportedCommands: number =
|
||||
cast.framework.messages.Command.ALL_BASIC_MEDIA |
|
||||
|
||||
Reference in New Issue
Block a user