2 * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include <Elementary.h>
19 #include <media/sound_manager.h>
20 #include <AppCommon.h>
25 #define TIME_INTERVAL 3.0
35 void CVolume::m_SetMute(bool mute)
44 r = sound_manager_get_volume(SOUND_TYPE_MEDIA, &vol);
49 sound_manager_set_volume(SOUND_TYPE_MEDIA, 0);
51 sound_manager_set_volume(SOUND_TYPE_MEDIA, m->volume);
57 void CVolume::m_SetVolume(volume_val val)
69 r = sound_manager_get_volume(SOUND_TYPE_MEDIA, &vol);
70 if (r != SOUND_MANAGER_ERROR_NONE) {
71 _ERR("get volume error");
77 sound_manager_set_volume(SOUND_TYPE_MEDIA, vol);
87 void CVolume::m_UpdateVolume(void)
94 r = sound_manager_get_volume(SOUND_TYPE_MEDIA, &vol);
95 if (r != SOUND_MANAGER_ERROR_NONE) {
96 _ERR("get volume error");
100 if (vol == 0 || m->mute) {
101 elm_object_signal_emit(m->ly, SIG_VOLUME_MUTE, "base");
104 elm_object_signal_emit(m->ly, SIG_VOLUME_UNMUTE, "base");
108 elm_progressbar_value_set(m->bar, val);
110 snprintf(buf, sizeof(buf), "%d", vol);
111 elm_object_part_text_set(m->ly, PART_VOLUME_VALUE, buf);
114 Eina_Bool CVolume::sm_CbTimer(void *dt)
120 data = (SVolumeData *)dt;
122 evas_object_hide(data->ly);
125 return ECORE_CALLBACK_CANCEL;
128 void CVolume::Show(volume_val val)
133 m->timer = ecore_timer_add(TIME_INTERVAL, sm_CbTimer, m);
134 evas_object_show(m->ly);
136 ecore_timer_reset(m->timer);
143 void CVolume::Hide(void)
147 evas_object_hide(m->ly);
149 ecore_timer_del(m->timer);
153 bool CVolume::Create(Evas_Object *base)
160 ly = elm_layout_add(base);
164 elm_layout_file_set(ly, EDJEFILE, GRP_VOLUME);
165 elm_win_resize_object_add(base, ly);
166 evas_object_hide(ly);
168 bar = elm_progressbar_add(ly);
170 _ERR("failed to create progressbar");
175 evas_object_size_hint_weight_set(bar, EVAS_HINT_EXPAND,
177 elm_progressbar_horizontal_set(bar, EINA_TRUE);
178 elm_object_style_set(bar, STYLE_VOLUME_BAR);
179 elm_object_part_content_set(ly, PART_VOLUME_BAR, bar);
180 evas_object_show(bar);
184 _ERR("allocation fail");
193 sound_manager_set_session_type(SOUND_SESSION_TYPE_EXCLUSIVE);
198 void CVolume::Destroy(void)
202 ecore_timer_del(m->timer);