2021-10-25 21:26:23 +02:00
|
|
|
import { Entry } from "./entry";
|
2021-10-25 20:55:13 +02:00
|
|
|
import { makeIDGen } from "./util";
|
|
|
|
|
|
|
|
const playlistIndexGen = makeIDGen(0);
|
|
|
|
|
|
|
|
export abstract class Playlist {
|
2021-10-25 21:26:23 +02:00
|
|
|
public entries: Entry[] = [];
|
2021-10-25 20:55:13 +02:00
|
|
|
constructor(public index = playlistIndexGen.next().value) {}
|
|
|
|
|
|
|
|
abstract toXML(): string;
|
2021-10-25 21:26:23 +02:00
|
|
|
|
|
|
|
addEntry(entry: Entry) {
|
|
|
|
this.entries.push(entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
renderEntries() {
|
|
|
|
return this.entries.map((e) => e.toXML()).join("\n");
|
|
|
|
}
|
2021-10-25 20:55:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export class AudioPlaylist extends Playlist {
|
|
|
|
toXML() {
|
2021-10-25 21:26:23 +02:00
|
|
|
return /* HTML */ `<playlist id="playlist${this.index}">
|
2021-10-25 20:55:13 +02:00
|
|
|
<property name="kdenlive:audio_track">1</property>
|
2021-10-25 21:26:23 +02:00
|
|
|
${this.renderEntries()}
|
2021-10-25 20:55:13 +02:00
|
|
|
</playlist>`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export class VideoPlaylist extends Playlist {
|
|
|
|
toXML() {
|
2021-10-25 21:26:23 +02:00
|
|
|
return /* HTML */ ` <playlist id="playlist${this.index}">
|
|
|
|
${this.renderEntries()}
|
|
|
|
</playlist>`;
|
2021-10-25 20:55:13 +02:00
|
|
|
}
|
|
|
|
}
|