summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Kurzberg <i.kurtsberg@samsung.com>2017-02-21 15:18:08 +0200
committerAleksandr Sapozhnik <a.sapozhnik@samsung.com>2017-02-22 06:42:14 -0800
commit0d8149b2540da27e523ab54c921f5d3968c3f780 (patch)
tree71eba675a359b405de4092f45241155df287e085
parentbc224acfe07d1fe3a89524b39f8c91f8a7be31fb (diff)
downloadalarm-0d8149b2540da27e523ab54c921f5d3968c3f780.tar.gz
alarm-0d8149b2540da27e523ab54c921f5d3968c3f780.tar.bz2
alarm-0d8149b2540da27e523ab54c921f5d3968c3f780.zip
TizenRefApp-8033 Implement playing sound in the Alert
Change-Id: Ie00aec2c5ec8f8d5843f7a2471c4c8c6d895e3af Signed-off-by: Eugene Kurzberg <i.kurtsberg@samsung.com>
-rw-r--r--alarm-app/inc/Alert/AlertView.h4
-rw-r--r--alarm-app/src/Alert/AlertView.cpp39
2 files changed, 40 insertions, 3 deletions
diff --git a/alarm-app/inc/Alert/AlertView.h b/alarm-app/inc/Alert/AlertView.h
index 4911d21..ce00642 100644
--- a/alarm-app/inc/Alert/AlertView.h
+++ b/alarm-app/inc/Alert/AlertView.h
@@ -21,6 +21,7 @@
#include "Ui/View.h"
#include <efl_extension.h>
+#include <player.h>
namespace Alert
{
@@ -35,6 +36,7 @@ namespace Alert
* @param[in] alarm Alarm to show alert for
*/
AlertView(Common::Model::Alarm alarm);
+ virtual ~AlertView() override;
private:
virtual Evas_Object *onCreate(Evas_Object *parent) override;
@@ -42,6 +44,7 @@ namespace Alert
virtual void onPageAttached(Ui::NavigatorPage *page) override;
virtual bool onBackPressed() override;
+ player_h createPlayer();
Evas_Object *createButton(Evas_Object *parent, const char *iconPath, Elm_Color_RGBA color,
const char *pressSignal, const char *unpressSignal);
Evas_Object *createDismissButton(Evas_Object *parent);
@@ -56,6 +59,7 @@ namespace Alert
Evas_Object *m_DismissButton;
Evas_Object *m_SnoozeButton;
Ecore_Timer *m_Timer;
+ player_h m_Player;
Common::Model::Alarm m_Alarm;
};
}
diff --git a/alarm-app/src/Alert/AlertView.cpp b/alarm-app/src/Alert/AlertView.cpp
index b329f80..035dc49 100644
--- a/alarm-app/src/Alert/AlertView.cpp
+++ b/alarm-app/src/Alert/AlertView.cpp
@@ -21,21 +21,29 @@
#include "App/Path.h"
#include "Ui/Window.h"
#include "Utils/Callback.h"
+#include "Utils/Logger.h"
#include "AlertLayout.h"
#define SNOOZE_MAX_COUNT 3
#define ALERT_MAX_TIME 60
+#define DEFAULT_SOUND_PATH "/opt/share/settings/Alarms/Alarms_on_call.ogg"
using namespace Alert;
using namespace Common;
using namespace Common::Model;
AlertView::AlertView(Common::Model::Alarm alarm)
- : m_DismissButton(nullptr), m_SnoozeButton(nullptr), m_Timer(nullptr),
+ : m_DismissButton(nullptr), m_SnoozeButton(nullptr),
+ m_Timer(nullptr), m_Player(createPlayer()),
m_Alarm(std::move(alarm))
{
}
+AlertView::~AlertView()
+{
+ player_destroy(m_Player);
+}
+
Evas_Object *AlertView::onCreate(Evas_Object *parent)
{
Evas_Object *layout = elm_layout_add(parent);
@@ -70,8 +78,14 @@ Evas_Object *AlertView::onCreate(Evas_Object *parent)
void AlertView::onNavigation(bool isCurrent)
{
eext_rotary_object_event_activated_set(getEvasObject(), isCurrent);
- if (!isCurrent && !elm_win_focus_get(findParent<Ui::Window>()->getEvasObject())) {
- onCancel();
+
+ if (isCurrent) {
+ player_start(m_Player);
+ } else {
+ player_stop(m_Player);
+ if (!elm_win_focus_get(findParent<Ui::Window>()->getEvasObject())) {
+ onCancel();
+ }
}
}
@@ -85,6 +99,25 @@ bool AlertView::onBackPressed()
return onCancel();
}
+player_h AlertView::createPlayer()
+{
+ sound_stream_info_h streamInfo = nullptr;
+ sound_manager_create_stream_information(SOUND_STREAM_TYPE_ALARM, nullptr, nullptr, &streamInfo);
+
+ player_h player = nullptr;
+ player_create(&player);
+ player_set_looping(player, true);
+ player_set_sound_stream_info(player, streamInfo);
+ player_set_uri(player, DEFAULT_SOUND_PATH);
+
+ sound_manager_destroy_stream_information(streamInfo);
+
+ int err = player_prepare(player);
+ WARN_IF_ERR(err, "player_prepare() failed.");
+
+ return player;
+}
+
Evas_Object *AlertView::createButton(Evas_Object *parent, const char *iconPath, Elm_Color_RGBA color,
const char *pressSignal, const char *unpressSignal)
{