const Clip *back() const { return clip(size() - 1); }
void set_currently_playing(int index); // -1 = none. Only makes sense for the playlist.
+ int get_currently_playing() const { return currently_playing_index; }
void emit_data_changed(size_t row);
#include "clip_list.h"
#include "player.h"
+#include "post_to_main_thread.h"
#include "ui_mainwindow.h"
#include <string>
preview_player = new Player(ui->preview_display);
live_player = new Player(ui->live_display);
+ live_player->set_done_callback([this]{
+ post_to_main_thread([this]{
+ live_player_clip_done();
+ });
+ });
}
void MainWindow::queue_clicked()
row = selected->selectedRows(0)[0].row();
}
- const Clip &clip = *cliplist_clips->clip(row);
+ const Clip &clip = *playlist_clips->clip(row);
live_player->play_clip(clip, clip.stream_idx);
playlist_clips->set_currently_playing(row);
}
+
+void MainWindow::live_player_clip_done()
+{
+ int row = playlist_clips->get_currently_playing();
+ if (row != -1 && row < int(playlist_clips->size()) - 1) {
+ ++row;
+ const Clip &clip = *playlist_clips->clip(row);
+ live_player->play_clip(clip, clip.stream_idx);
+ playlist_clips->set_currently_playing(row);
+ } else {
+ playlist_clips->set_currently_playing(-1);
+ }
+}
if (eof) break;
}
- // TODO: callback so that the next playlist item can be cued.
{
unique_lock<mutex> lock(cue_state_mu);
cue_state = PAUSED;
}
+
+ if (done_callback != nullptr) {
+ done_callback();
+ }
}
}
#include "clip_list.h"
#include <condition_variable>
+#include <functional>
#include <mutex>
class JPEGFrameView;
void play_clip(const Clip &clip, unsigned stream_idx);
+ // Not thread-safe to set concurrently with playing.
+ // Will be called back from the player thread.
+ using done_callback_func = std::function<void()>;
+ void set_done_callback(done_callback_func cb) { done_callback = cb; }
+
private:
void thread_func();
JPEGFrameView *destination;
+ done_callback_func done_callback;
std::mutex mu;
Clip current_clip; // Under mu.