Merge pull request #1574 from Technius/issue-1573

Fix audio playback failure not showing message to user
presentation
Bryan Tan 6 years ago committed by GitHub
commit 225fb14e5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      src/gui/PageView.cpp
  2. 18
      src/gui/PageViewFindObjectHelper.h

@ -43,6 +43,7 @@
#include "pixbuf-utils.h"
#include "util/cpp14memory.h"
#include "util/XojMsgBox.h"
#include <gdk/gdk.h>
@ -413,6 +414,15 @@ bool XojPageView::onButtonPressEvent(const PositionInputData& pos)
{
PlayObject play(this);
play.at(x, y);
if (play.playbackStatus)
{
auto& status = *play.playbackStatus;
if (!status.success)
{
string message = FS(_F("Unable to play audio recording {1}") % status.filename);
XojMsgBox::showErrorToUser(this->xournal->getControl()->getGtkWindow(), message);
}
}
}
}
else if (h->getToolType() == TOOL_TEXT)

@ -14,6 +14,7 @@
// No include needed, this is included after PageView.h
#include <util/audio/AudioPlayer.h>
#include <optional>
class BaseSelectObject
{
@ -143,7 +144,8 @@ class PlayObject : public BaseSelectObject
{
public:
PlayObject(XojPageView* view)
: BaseSelectObject(view)
: BaseSelectObject(view)
, playbackStatus()
{
}
@ -151,6 +153,14 @@ public:
{
}
struct Status
{
bool success;
std::string filename;
};
std::optional<Status> playbackStatus;
public:
bool at(double x, double y)
{
@ -182,8 +192,10 @@ protected:
fn = path.str();
}
view->getXournal()->getControl()->getAudioController()->startPlayback(fn, (unsigned int) ts);
return true;
auto* ac = view->getXournal()->getControl()->getAudioController();
bool success = ac->startPlayback(fn, (unsigned int) ts);
playbackStatus = {success, fn};
return success;
}
}
return false;

Loading…
Cancel
Save