kdenlive-ts/src/playlist.ts

37 lines
788 B
TypeScript
Raw Normal View History

2021-10-25 21:26:23 +02:00
import { Entry } from "./entry";
import { makeIDGen } from "./util";
const playlistIndexGen = makeIDGen(0);
export abstract class Playlist {
2021-10-25 21:26:23 +02:00
public entries: Entry[] = [];
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");
}
}
export class AudioPlaylist extends Playlist {
toXML() {
2021-10-25 21:26:23 +02:00
return /* HTML */ `<playlist id="playlist${this.index}">
<property name="kdenlive:audio_track">1</property>
2021-10-25 21:26:23 +02:00
${this.renderEntries()}
</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>`;
}
}