Skip to content

Commit

Permalink
fix no loop after restart
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Oct 15, 2023
1 parent e7ce223 commit 0620d6e
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions mdkvideo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ class mdkVideoSource {
player_.set(State::Playing);
}

void restart() {
player_.setMedia(nullptr);
setUrls(urls_, loop_);
}

uint32_t width() const { return w_; }
uint32_t height() const { return h_; }
uint32_t flip() const { return flip_; }
Expand All @@ -167,10 +172,10 @@ class mdkVideoSource {
loop_ = loop;
urls_ = urls;
player_.setNextMedia(nullptr);
if (urls_.empty()) {
if (urls_.empty()) {
player_.set(State::Stopped);
return;
}
return;
}
string next;
auto now = player_.url();
auto it = now ? find(urls_.cbegin(), urls_.cend(), now) : urls_.cend();
Expand Down Expand Up @@ -509,7 +514,7 @@ static void mdkvideo_restart(void *data)
{
SetGlobalOption("sdr.white", obs_get_video_sdr_white_level());
auto obj = static_cast<mdkVideoSource *>(data);
obj->player_.set(State::Playing);
obj->restart();
}

static int64_t mdkvideo_get_duration(void *data)
Expand Down

0 comments on commit 0620d6e

Please sign in to comment.