Skip to content

Commit

Permalink
try to play from begin if current video is removed
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Oct 8, 2023
1 parent 7018898 commit 6aa61f9
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions mdkvideo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,21 +140,22 @@ class mdkVideoSource {
loop_ = loop;
urls_ = urls;
player_.setNextMedia(nullptr);
if (urls_.empty())
if (urls_.empty()) {
player_.set(State::Stopped);
return;
}
string next;
auto now = player_.url();
if (!now) {
auto it = now ? find(urls_.cbegin(), urls_.cend(), now) : urls_.cend();
if (!now || it == urls_.cend()) {
next_it_ = urls_.cbegin();
if (++next_it_ == urls_.cend() && loop_)
next_it_ = urls_.cbegin();
play(urls_.front().data());
return;
}
auto it = find(urls_.cbegin(), urls_.cend(), now);
if (it != urls_.cend())
next_it_ = ++it;
if (it == urls_.cend()) {
next_it_ = ++it;
if (it == urls_.cend()) {
if (!loop_) {
player_.setNextMedia(nullptr);
return;
Expand Down

0 comments on commit 6aa61f9

Please sign in to comment.