diff --git a/src/UI/DocumentViews/MpvContainer.cc b/src/UI/DocumentViews/MpvContainer.cc index a9c2bbbdeeb354bf1eb601c92472392466db04fc..74c75fa129e95cba2b456b400600072bd792b26d 100644 --- a/src/UI/DocumentViews/MpvContainer.cc +++ b/src/UI/DocumentViews/MpvContainer.cc @@ -7,6 +7,12 @@ using namespace std::string_literals; if ((ptr) == nullptr) \ return +#define TRY_CREATE_MPV(ptr) \ + if ((ptr) == nullptr) { \ + logInfo() << "Asked to play MPV but context not created, try to create it"; \ + reCreateMpvContext(); \ + } + void MpvContainer::mpvEventWakeUpCB(void *user) noexcept { @@ -297,6 +303,7 @@ MpvContainer::printMpvError(int rc) const noexcept void MpvContainer::mpvPlay() noexcept { + TRY_CREATE_MPV(mpv); RETURN_IF_NULLPTR(mpv); if (isPlaybackPaused) mpvTogglePlayback(); @@ -313,6 +320,7 @@ MpvContainer::mpvPause() noexcept void MpvContainer::mpvTogglePlayback() noexcept { + TRY_CREATE_MPV(mpv); RETURN_IF_NULLPTR(mpv); logDebug() << "MPV: Toggling the playback"; asyncCommand(AsyncCmdType::TogglePlayback, { "cycle", "pause", "up", nullptr });