Languages

Menu
Sites
Language
Sounds issues

Hello everyone!
I'm wondering here what is the why track whether the sound on my device is on/off?
The thing is that when I use  

wav_player_start

my sound's volume changes only after pressing hardware buttons. If I want to set my phone to "mute" or "vibrate" modes from the top panel the sound is still played! 
P.S.: I use 

SOUND_TYPE_RINGTONE

Thanks for helping!

Responses

4 Replies
Alex Dem

Hi,
If you need to detect is vibration or silent mode is on before playing...
1)To detect vibration mode is on/off you could:

#include <runtime_info.h>
    
bool value= false;
runtime_info_get_value_bool(RUNTIME_INFO_KEY_VIBRATION_ENABLED, &value);

2) To detect silent mode you could:

bool value = false;
system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_SOUND_SILENT_MODE, &value);

I have checked . It works ok.
Alexey.

Alex Dem

Also,
To detect  "is vibration mode on/off" at runtime you could use:

runtime_info_set_changed_cb(RUNTIME_INFO_KEY_VIBRATION_ENABLED,_runtime_info_changed_cb,NULL);

and request  value of RUNTIME_INFO_KEY_VIBRATION_ENABLED inside callback as proposed above. It works ok.

But the similar approach do not work to detect "is silent mode on/off". I have registered callback 

system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_SOUND_SILENT_MODE,_system_settings_changed_cb,NULL);

This callback is called after "Vibrate"(vibration mode) has been set but is not called  after "Mute"(silent mode) from panel. It looks like an error.
Alexey.
 

Alex Dem

But here is code to detect "silent mode" using system event api.
It works as should. After "Mute""(silent mode) from panel has been pressed - event comes and contains info that silent mode is turned on.

#include <app_event.h>

//...
event_handler_h handler;
event_add_event_handler(SYSTEM_EVENT_SILENT_MODE,
                                      (event_cb)silen_mode_event_cb, NULL, &handler);
//...

void extract_bundle_keyval_cb(const char *key, const int type, const bundle_keyval_t *kv, void *user_data) {
   void *val;
   size_t size;
   if(BUNDLE_TYPE_STR == type)
   {
       bundle_keyval_get_basic_val((bundle_keyval_t *)kv, &val, &size);
       dlog_print(DLOG_ERROR, LOG_TAG, "bundle_keyval_nfo %s %s %d", key, (char*)val,(int)size);
   }
}

void silen_mode_event_cb(const char *event_name, bundle *event_data, void *user_data)
{
    bundle_foreach (event_data, extract_bundle_keyval_cb, NULL);
}

 

AVSukhov

Hello,

Jyst fyi:

Runtime info:

https://developer.tizen.org/development/guides/native-application/system/runtime-information

System settings:

https://developer.tizen.org/development/guides/native-application/system/system-settings