From b4739025141ad14898c853630714a6782cdb2143 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Tue, 25 Apr 2017 11:29:04 +0200 Subject: [PATCH] feat(src/components/sound-player/SoundPlayer): handle end of file --- .../components/assistant/AssistantModel.cpp | 1 + .../components/sound-player/SoundPlayer.cpp | 21 +++++++++++++++++++ .../components/sound-player/SoundPlayer.hpp | 6 +++++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/linphone-desktop/src/components/assistant/AssistantModel.cpp b/linphone-desktop/src/components/assistant/AssistantModel.cpp index 90d9c986f..e5ffb1918 100644 --- a/linphone-desktop/src/components/assistant/AssistantModel.cpp +++ b/linphone-desktop/src/components/assistant/AssistantModel.cpp @@ -37,6 +37,7 @@ public: mAssistant = assistant; } +private: void onCreateAccount ( const shared_ptr &, linphone::AccountCreatorStatus status, diff --git a/linphone-desktop/src/components/sound-player/SoundPlayer.cpp b/linphone-desktop/src/components/sound-player/SoundPlayer.cpp index a9854b51d..fb4c2ed93 100644 --- a/linphone-desktop/src/components/sound-player/SoundPlayer.cpp +++ b/linphone-desktop/src/components/sound-player/SoundPlayer.cpp @@ -25,10 +25,31 @@ #include "SoundPlayer.hpp" +using namespace std; + // ============================================================================= +class SoundPlayer::Handlers : public linphone::PlayerListener { +public: + Handlers (SoundPlayer *soundPlayer) { + mSoundPlayer = soundPlayer; + } + +private: + void onEofReached (const shared_ptr &) override { + mSoundPlayer->stop(); + } + + SoundPlayer *mSoundPlayer; +}; + +// ----------------------------------------------------------------------------- + SoundPlayer::SoundPlayer (QObject *parent) : QObject(parent) { + mHandlers = make_shared(this); + mInternalPlayer = CoreManager::getInstance()->getCore()->createLocalPlayer("", "", nullptr); + mInternalPlayer->setListener(mHandlers); } // ----------------------------------------------------------------------------- diff --git a/linphone-desktop/src/components/sound-player/SoundPlayer.hpp b/linphone-desktop/src/components/sound-player/SoundPlayer.hpp index 1f58a6354..ca9b3d7b8 100644 --- a/linphone-desktop/src/components/sound-player/SoundPlayer.hpp +++ b/linphone-desktop/src/components/sound-player/SoundPlayer.hpp @@ -34,6 +34,8 @@ namespace linphone { } class SoundPlayer : public QObject { + class Handlers; + Q_OBJECT; Q_PROPERTY(QString source READ getSource WRITE setSource NOTIFY sourceChanged); @@ -81,9 +83,11 @@ private: int getDuration () const; - std::shared_ptr mInternalPlayer; QString mSource; PlaybackState mPlaybackState = StoppedState; + + std::shared_ptr mInternalPlayer; + std::shared_ptr mHandlers; }; #endif // SOUND_PLAYER_H_