import { Entry } from "./entry"; import { makeIDGen } from "./util"; const playlistIndexGen = makeIDGen(0); export abstract class Playlist { public entries: Entry[] = []; constructor(public index = playlistIndexGen.next().value) {} abstract toXML(): string; addEntry(entry: Entry) { this.entries.push(entry); } renderEntries() { return this.entries.map((e) => e.toXML()).join("\n"); } } export class AudioPlaylist extends Playlist { toXML() { return /* HTML */ ` 1 ${this.renderEntries()} `; } } export class VideoPlaylist extends Playlist { toXML() { return /* HTML */ ` ${this.renderEntries()} `; } }