Update: MediaPlayer class 84/73084/1
authorDenis Dolzhenko <d.dolzhenko@samsung.com>
Mon, 6 Jun 2016 11:33:25 +0000 (14:33 +0300)
committerDenis Dolzhenko <d.dolzhenko@samsung.com>
Mon, 6 Jun 2016 11:33:25 +0000 (14:33 +0300)
Change-Id: Ib5a234d3ce19bf719fb7f6f9500d04e2d88feb88
Signed-off-by: Denis Dolzhenko <d.dolzhenko@samsung.com>
src/Viewer/Controller/src/SmilPlayer.cpp
src/Viewer/Utils/inc/MediaPlayer.h
src/Viewer/Utils/src/MediaPlayer.cpp

index f2295b3..da4510c 100644 (file)
@@ -277,13 +277,11 @@ unsigned SmilPlayer::getCurrentPageIndex() const
 
 void SmilPlayer::showUnableToPlayVideoNotif()
 {
-    // TODO: localization "Video" word
     notification_status_message_post(msg("IDS_MSG_POP_UNABLE_TO_PLAY_DURING_CALL").cStr());
 }
 
 void SmilPlayer::showUnableToPlayAudioNotif()
 {
-    // TODO: localization "Audo" word
     notification_status_message_post(msg("IDS_MSG_POP_UNABLE_TO_PLAY_DURING_CALL").cStr());
 }
 
@@ -308,8 +306,7 @@ void SmilPlayer::onBeforeDelete(View &view)
 
 void SmilPlayer::onMediaPlayerSoundFocusChanged()
 {
-    MSG_LOG("");
-    if(m_MediaPlayer.isPlaying())
+    if(m_MediaPlayer.isPlaying() && !m_MediaPlayer.getFocus())
     {
         SmilPage *page = getCurrentPage();
         if(page)
index 1cce421..7ff07d3 100644 (file)
@@ -44,7 +44,7 @@ namespace Msg
             int getDuration() const; // msec
             void setPosition(int msec);
             static int getDuration(const std::string &uri);
-            bool isSoundFocusAcquired() const;
+            bool getFocus() const;
 
         private:
             static void on_completed_cb(void *user_data);
@@ -59,7 +59,7 @@ namespace Msg
         private:
             player_h m_Player;
             IMediaPlayerListener *m_pListener;
-            bool m_IsSoundFocusAcquired;
+            bool m_Focus;
     };
 
     class IMediaPlayerListener
index 45e3922..abd766f 100644 (file)
@@ -27,15 +27,14 @@ using namespace Msg;
 MediaPlayer::MediaPlayer()
     : m_Player()
     , m_pListener(nullptr)
-    , m_IsSoundFocusAcquired(false)
+    , m_Focus(false)
 {
+    sound_manager_set_focus_state_watch_cb(SOUND_STREAM_FOCUS_FOR_PLAYBACK, on_sound_stream_focus_state_watch_cb, this);
     player_create(&m_Player);
     player_set_sound_type(m_Player, SOUND_TYPE_MEDIA);
     player_set_volume(m_Player, 1.0, 1.0);
     player_set_looping(m_Player, false);
     player_set_completed_cb(m_Player, on_completed_cb, this);
-
-    sound_manager_set_focus_state_watch_cb(SOUND_STREAM_FOCUS_FOR_PLAYBACK, on_sound_stream_focus_state_watch_cb, this);
 }
 
 MediaPlayer::~MediaPlayer()
@@ -61,9 +60,9 @@ player_state_e MediaPlayer::getState() const
     return state;
 }
 
-bool MediaPlayer::isSoundFocusAcquired() const
+bool MediaPlayer::getFocus() const
 {
-    return m_IsSoundFocusAcquired;
+    return m_Focus;
 }
 
 void MediaPlayer::start()
@@ -154,21 +153,19 @@ void MediaPlayer::on_sound_stream_focus_state_watch_cb(sound_stream_focus_mask_e
     MSG_LOG("Interrupted focus state = ", focus_state);
     MSG_LOG("Interrupted focus change reason = ", reason);
 
-    if(reason == SOUND_STREAM_FOCUS_CHANGED_BY_CALL)
-    {
-        MediaPlayer *self = static_cast<MediaPlayer*>(user_data);
-        self->m_IsSoundFocusAcquired = focus_state == SOUND_STREAM_FOCUS_STATE_ACQUIRED;
-        ecore_main_loop_thread_safe_call_sync
-        (
-            [](void *data)->void*
-            {
-                MSG_LOG("");
-                auto *self = (MediaPlayer*)data;
-                if(self->m_pListener)
-                    self->m_pListener->onMediaPlayerSoundFocusChanged();
-                return nullptr;
-            },
-            self
-        );
-    }
+    auto *self = static_cast<MediaPlayer*>(user_data);
+    self->m_Focus = focus_state == SOUND_STREAM_FOCUS_STATE_RELEASED;
+
+    ecore_main_loop_thread_safe_call_sync
+    (
+        [](void *data)->void*
+        {
+            auto *self = (MediaPlayer*)data;
+            if(self->m_pListener)
+                self->m_pListener->onMediaPlayerSoundFocusChanged();
+            return nullptr;
+        },
+        self
+    );
+
 }