import { ChromecastDevice } from "stratocaster"; export interface IApp { start(): Promise; } export declare type Opts = any[]; export interface IAppConstructor { tokenConfigKeys?: string[]; new (device: ChromecastDevice, ...options: TOptions): TSelf; } export declare type OptionsFor = T extends IAppConstructor ? TOpt : never; export declare type AppFor = T extends IAppConstructor ? TSelf : never; export interface IPlayableOptions { /** * By default, if the app supports it (and we know how) we will * attempt to resume playback of whatever entity is represented by * a Playable: * * - Series (and playlists) should resume the next episode in the * series, or the last watched if unfinished * - Episodes and movies should resume wherever we left off, or * start at the beginning if new or completed * * If you prefer to start at the beginning regardless of whatever * resume features the app supports for the given entity---assuming * the app supports disabling resume for the entity---pass `false` * for this value. */ resume?: boolean; } export declare type IPlayable = (app: T, opts: IPlayableOptions) => Promise; export interface IQueryResult { /** * The name of the app that provided the result */ appName: string; /** * Title of the entity that matched the query */ title: string; /** * Description of the entity, if available */ desc?: string; /** * Image URL for cover art, if available */ cover?: string; /** * Playable URL for this entity, if available */ url?: string; /** * If `true`, the item can be played, but will have ads */ hasAds?: boolean; /** * If `true`, it is a preferred result from the service, * perhaps bookmarked or in a "watch list" */ isPreferred?: boolean; } export declare enum RecommendationType { Recent = "recent", Saved = "saved", New = "new", Popular = "popular", Interest = "interest", Curated = "curated" } export interface IRecommendation extends IQueryResult { recommendationType: RecommendationType; recommendationCategoryKey?: string; recommendationCategoryTitle?: string; } export interface IRecommendationQuery { excludeTypes?: RecommendationType[]; } export interface IEpisodeQueryResult extends IQueryResult { seriesTitle: string; } export interface ISeasonAndEpisodeQuery { episodeIndex: number; seasonIndex: number; } /** * IEpisodeQuery is a map describing how to locate a specific * episode to play within a series. Not all providers will * support all query types; in such cases, their channel should * return an empty set */ export declare type IEpisodeQuery = ISeasonAndEpisodeQuery; /** * The ISeriesContentListings interface describes a helper for listing episodes and * seasons in a Series. Implementations may cache and share data between method * calls for efficiency (especially if the service has a single API call that * returns data to facilitate multiple methods). */ export interface ISeriesContentListings { listSeasons(): Promise; listEpisodesInSeason(season: IQueryResult): Promise; } /** * The IPlayerChannel interface is a high-level, unified means of * interacting with a particular app and its service. */ export interface IPlayerChannel { /** * Return true if your app "owns" the given URL. The first * app that returns `true` from this method will be elected * to `createPlayable` for the URL. */ ownsUrl(url: string): boolean; /** * Will only be called if {@see canPlayUrl} returned `true`. * If the URL resolves to something that can't be played, * the returned Promise should reject. */ createPlayable(url: string): Promise>>; /** * Create a helper for resolving season/episode listings. * If undefined is returned from this method, the provided IQueryResult * does not represent a series. */ createContentListingsFor?(item: IQueryResult): Promise; /** * Find a specific {@see Player.play}'able episode for the * given {@see IQueryResult}. */ findEpisodeFor?(item: IQueryResult, query: IEpisodeQuery): Promise; /** * Search for {@see Player.play}'able media by title */ queryByTitle?(title: string): AsyncIterable; /** * Search for {@see Player.play}'able media by title, requesting a specific * episode in the matching series */ queryEpisodeForTitle?(title: string, query: IEpisodeQuery): AsyncIterable; /** * Search for {@see Player.play}'able media per the source * apps' recommendations. * @deprecated Most channels implemented this as `queryRecent`, so the naming * is unhelpful. Use `queryRecent` or `queryRecommendations` instead. */ queryRecommended?(): AsyncIterable; /** * Search for {@see Player.play}'able media per the source apps' * recommendations. If no `query` is provided (or if the provider doesn't * support `query` filtering) some default set of recommendation types will be * selected. * * NOTE: This method is not currently stable; its behavior may change * slightly in point releases, and `IRecommendationQuery` may also change. * Requests for the "default" behavior (IE: without any `query` provided) * are unlikely to break, but no specific "default" behavior is guaranteed. */ queryRecommendations?(query?: IRecommendationQuery): AsyncIterable; /** * Search for {@see Player.play}'able media per the source * apps' recently viewed media. */ queryRecent?(): AsyncIterable; } export interface IPlayerEnabledConstructor extends IAppConstructor { /** * Create a Channel that can be used to interact with this App * and its associated service */ createPlayerChannel(options?: TOptions): IPlayerChannel; }