Very basic playlist support
This commit is contained in:
parent
63518483a3
commit
77b24d58cb
6 changed files with 149 additions and 0 deletions
|
@ -31,6 +31,7 @@ MediaPlayer {
|
|||
signal playerCreated()
|
||||
|
||||
property var queue: ([])
|
||||
signal queueUpdated()
|
||||
property bool isPlaying: playbackState == MediaPlayer.PlayingState
|
||||
|
||||
property bool inhibitPositionEvents: false
|
||||
|
@ -58,6 +59,24 @@ MediaPlayer {
|
|||
}
|
||||
}
|
||||
|
||||
function enqueueEpisode(episode_id, callback) {
|
||||
py.call('main.show_episode', [episode_id], function (episode) {
|
||||
if (episode_id != player.episode && !queue.some(function (queued) {
|
||||
return queued.episode_id === episode_id;
|
||||
})) {
|
||||
queue.push({
|
||||
episode_id: episode_id,
|
||||
title: episode.title,
|
||||
});
|
||||
queueUpdated();
|
||||
}
|
||||
|
||||
if (callback !== undefined) {
|
||||
callback();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function playbackEpisode(episode_id) {
|
||||
if (episode == episode_id) {
|
||||
// If the episode is already loaded, just start playing
|
||||
|
@ -157,6 +176,35 @@ MediaPlayer {
|
|||
}
|
||||
}
|
||||
|
||||
property var nextInQueueTimer: Timer {
|
||||
interval: 500
|
||||
|
||||
repeat: false
|
||||
|
||||
onTriggered: {
|
||||
if (queue.length > 0) {
|
||||
playbackEpisode(queue.shift().episode_id);
|
||||
player.queueUpdated();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function jumpToQueueIndex(index) {
|
||||
playbackEpisode(removeQueueIndex(index).episode_id);
|
||||
}
|
||||
|
||||
function removeQueueIndex(index) {
|
||||
var result = queue.splice(index, 1)[0];
|
||||
player.queueUpdated();
|
||||
return result;
|
||||
}
|
||||
|
||||
onStatusChanged: {
|
||||
if (status === MediaPlayer.EndOfMedia) {
|
||||
nextInQueueTimer.start();
|
||||
}
|
||||
}
|
||||
|
||||
property var savePlaybackPositionTimer: Timer {
|
||||
// Save position every minute during playback
|
||||
interval: 60 * 1000
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue