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);
50 sound_manager_set_volume(SOUND_TYPE_MEDIA, m->volume);
56 void CVolume::m_SetVolume(volume_val val)
68 r = sound_manager_get_volume(SOUND_TYPE_MEDIA, &vol);
69 if (r != SOUND_MANAGER_ERROR_NONE) {
70 _ERR("get volume error");
76 sound_manager_set_volume(SOUND_TYPE_MEDIA, vol);
86 void CVolume::m_UpdateVolume(void)
96 r = sound_manager_get_volume(SOUND_TYPE_MEDIA, &vol);
97 if (r != SOUND_MANAGER_ERROR_NONE) {
98 _ERR("get volume error");
102 if (vol == 0 || m->mute) {
103 elm_object_signal_emit(m->ly, SIG_VOLUME_MUTE, "base");
106 elm_object_signal_emit(m->ly, SIG_VOLUME_UNMUTE, "base");
110 elm_progressbar_value_set(m->bar, val);
112 snprintf(buf, sizeof(buf), "%d", vol);
113 elm_object_part_text_set(m->ly, PART_VOLUME_VALUE, buf);
116 Eina_Bool CVolume::sm_CbTimer(void *dt)
121 return ECORE_CALLBACK_CANCEL;
123 data = (SVolumeData *)dt;
125 evas_object_hide(data->ly);
128 return ECORE_CALLBACK_CANCEL;
131 void CVolume::Show(volume_val val)
136 m->timer = ecore_timer_add(TIME_INTERVAL, sm_CbTimer, m);
137 evas_object_show(m->ly);
139 ecore_timer_reset(m->timer);
146 void CVolume::Hide(void)
150 evas_object_hide(m->ly);
152 ecore_timer_del(m->timer);
156 bool CVolume::Create(Evas_Object *base)
165 _ERR("allocation fail");
169 ly = elm_layout_add(base);
175 elm_layout_file_set(ly, EDJEFILE, GRP_VOLUME);
176 elm_win_resize_object_add(base, ly);
177 evas_object_hide(ly);
179 bar = elm_progressbar_add(ly);
181 _ERR("failed to create progressbar");
187 evas_object_size_hint_weight_set(bar, EVAS_HINT_EXPAND,
189 elm_progressbar_horizontal_set(bar, EINA_TRUE);
190 elm_object_style_set(bar, STYLE_VOLUME_BAR);
191 elm_object_part_content_set(ly, PART_VOLUME_BAR, bar);
192 evas_object_show(bar);
197 sound_manager_set_session_type(SOUND_SESSION_TYPE_EXCLUSIVE);
202 void CVolume::Destroy(void)
206 ecore_timer_del(m->timer);