Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(FEC-13540): allow passing entry id to start playing the playlist from #688

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/common/playlist/playlist-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,18 @@ class PlaylistManager {
new FakeEvent(PlaylistEventType.PLAYLIST_LOADED, { playlist: this })
);
this._addBindings();
this.playNext();
const startPlaylistAtEntryId = config.options?.startAtEntryId;
let wasEntryIdSet = false;
if (startPlaylistAtEntryId && typeof startPlaylistAtEntryId === 'string') {
const entryToPlay: PlaylistItem | undefined = this._playlist.items.find((item: PlaylistItem) => item.sources.id === startPlaylistAtEntryId);
if (entryToPlay) {
wasEntryIdSet = true;
this.playItem(entryToPlay.index);
}
}
if (!wasEntryIdSet) {
this.playNext();
}
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/types/playlist/playlist-options.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
/**
* @typedef {Object} KPPlaylistOptions
* @typedef {Object} PlaylistOptions
* @property {boolean} [autoContinue=true] - Determines whether to continue to the next item automatically.
* @property {boolean} [loop=false] - Determines whether to play the playlist in a loop. When selected, the playlist will play automatically even if autoContinue is set to false.
* @property {string} [startAtEntryId] - Determines which entry id to start to the play the playlist from.
*/
export interface PlaylistOptions {
autoContinue: boolean;
loop: boolean;
imageDuration: number;
startAtEntryId?: string
}