From 5292ce64c2a620b4f5ab461609d629647dc63531 Mon Sep 17 00:00:00 2001 From: Denis Dolzhenko Date: Thu, 1 Sep 2016 16:36:12 +0300 Subject: [PATCH] Added Initialization on demand for MediaPlayer Change-Id: I6fb45213f189f896c054302c86fd89211d8acf10 Signed-off-by: Denis Dolzhenko --- src/Viewer/Controller/inc/SmilPlayer.h | 3 ++- src/Viewer/Controller/src/SmilPlayer.cpp | 28 ++++++++++++++++++---------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/Viewer/Controller/inc/SmilPlayer.h b/src/Viewer/Controller/inc/SmilPlayer.h index 004f76e..f020d26 100644 --- a/src/Viewer/Controller/inc/SmilPlayer.h +++ b/src/Viewer/Controller/inc/SmilPlayer.h @@ -25,6 +25,7 @@ #include #include +#include namespace Msg { @@ -87,7 +88,7 @@ namespace Msg private: ISmilPlayerListener *m_pListener; Ecore_Timer *m_pTimer; - MediaPlayer m_MediaPlayer; + std::unique_ptr m_MediaPlayer; PageList m_PageList; unsigned m_CurrentPageIndex; int m_Duration; diff --git a/src/Viewer/Controller/src/SmilPlayer.cpp b/src/Viewer/Controller/src/SmilPlayer.cpp index 0d42595..4ee26a5 100644 --- a/src/Viewer/Controller/src/SmilPlayer.cpp +++ b/src/Viewer/Controller/src/SmilPlayer.cpp @@ -44,8 +44,6 @@ SmilPlayer::~SmilPlayer() void SmilPlayer::create(const MessageMms &mms) { - m_MediaPlayer.setListener(this); - // Pages: const MsgPageList &pages = mms.getPageList(); for(int i = 0; i < pages.getLength(); ++i) @@ -190,26 +188,36 @@ void SmilPlayer::playPage() void SmilPlayer::prepareMedia() { - m_MediaPlayer.stop(); + if(m_MediaPlayer) + m_MediaPlayer->stop(); + SmilPage *page = getCurrentPage(); if(page->hasMedia()) { - m_MediaPlayer.setUri(page->getMediaPath()); + if(!m_MediaPlayer) + { + m_MediaPlayer.reset(new MediaPlayer); + m_MediaPlayer->setListener(this); + } + + m_MediaPlayer->setUri(page->getMediaPath()); Evas_Object *videoSink = page->getVideoSink(); - m_MediaPlayer.setDisplay(videoSink); + m_MediaPlayer->setDisplay(videoSink); } + } void SmilPlayer::stopMedia() { - m_MediaPlayer.pause(); + if(m_MediaPlayer) + m_MediaPlayer->pause(); getCurrentPage()->playAnimation(false); } void SmilPlayer::startMedia() { - if(getCurrentPage()->hasMedia()) - m_MediaPlayer.start(); + if(m_MediaPlayer && getCurrentPage()->hasMedia()) + m_MediaPlayer->start(); getCurrentPage()->playAnimation(true); } @@ -314,12 +322,12 @@ void SmilPlayer::onBeforeDelete(View &view) void SmilPlayer::onMediaPlayerSoundFocusChanged() { - if(m_MediaPlayer.isPlaying() && m_MediaPlayer.isFocusChangedCallReason()) + if(m_MediaPlayer->isPlaying() && m_MediaPlayer->isFocusChangedCallReason()) { SmilPage *page = getCurrentPage(); if(page) { - m_MediaPlayer.pause(); + m_MediaPlayer->pause(); if(page->hasVideo()) showUnableToPlayVideoNotif(); else if(page->hasAudio()) -- 2.7.4