Files
gerbeur/shared/player.ts

69 lines
1.9 KiB
TypeScript

/**
* What the player's resolvers answer: a Bandcamp release's streams and a
* YouTube playlist's tracks.
*
* @module
*/
/** A track of a Bandcamp release, as {@link Tralbum} lists it. */
export interface TralbumTrack {
/**
* Position in the parsed array — the stable handle used to re-resolve a
* track after its signed URL expires.
*/
index: number;
/** The track's number on the release. */
trackNum?: number;
/** The track's title. */
title: string;
/** Seconds, fractional. */
duration?: number;
/** The signed stream URL, null when the track can't be played. */
streamUrl: string | null;
/**
* False for preorder, unreleased and still-encoding tracks. They stay in
* the list so numbering matches the release, but never enter the queue.
*/
streamable: boolean;
/** Bandcamp caps free plays per track; a capped track may serve a clip. */
capped: boolean;
}
/** `GET /api/bandcamp/tracks`: a Bandcamp page resolved at play time. */
export interface Tralbum {
/** The page it was resolved from. */
sourceUrl: string;
/** Whether the page is an album or a single track. */
itemType: "album" | "track";
/** The release's title. */
title?: string;
/** The artist's name. */
artist?: string;
/** The release's cover. */
artworkUrl?: string;
/** The release's tracks, in order. */
tracks: TralbumTrack[];
/** Epoch ms of the fetch that produced these signed URLs. */
resolvedAt: number;
}
/** A video of a YouTube playlist, as {@link YouTubePlaylist} lists it. */
export interface YouTubePlaylistTrack {
/** The video's id. */
videoId: string;
/** The video's title. */
title: string;
/** Seconds. */
duration?: number;
}
/** `GET /api/youtube/playlist`: a playlist's tracklist, for the player. */
export interface YouTubePlaylist {
/** The playlist's id. */
listId: string;
/** The playlist's title. */
title?: string;
/** Its videos, in order. */
tracks: YouTubePlaylistTrack[];
}