media.setSoundVolume does not work on Android device?

I set the media volume via media.setSoundVolume(0) to be muted. This works well in the simulator (windows) but has no effect on my android device (s4 mini, android 4.2.2).

I also use audio.setVolume() in the same code and this works fine.

I am using the media api because I need the sound to be played directly, without any latency :frowning:

Is there a workaround to realize a mute function?

I am using this version of the corona simulator: 2013.2076 (2013.07.15).

Cheers,

Felix

I use now a variable to check if the game is muted or not and play the sounds just if the game is not muted.

But this whole media/audio api seems a bit confused to me. I found another thing that works not like expected: when I set the media volume to zero (in the simulator) also the audio volume is zero.

But seems like I have to work with different mute variables, if I want to mute the music and the sounds ie like one live up, hit, jump, …

Just in case there is no other solution and somebody else finds that thread.

Cheers,

Hi Felix.

The two libraries are different.  The media.* is the older library and depends on native hardware decoding to render audio.  While it’s faster on older Android operating systems, it has major limits of only being able to play one sound at a time, and volume control is limited.  Let’s talk about that limitation because that could be your problem.  There are two play sound functions:

media.playSound()

media.playEventSound()

The second one, media.playEventSound(), which is the fastest way to play sound does not support volume controls.  See: http://docs.coronalabs.com/api/library/media/setSoundVolume.html

The first one, if I read the docs correctly, you have to play the sound and if it’s long enough, then you can adjust the volume of that sound after  you start playing it.  It does not set the overall system sound, but the sound for the currently playing one.

Because of these limits, we really prefer  you to use the audio.* library which is based on OpenAL/OpenES and lets  you have 32 channels to mix sound at the same time while independently controlling volume on each channel independently regardless of a sound playing as well as control the master volume.  The audio.* api is much more feature rich and solid.

But on Android devices older that Android 4.1, the sounds lag.  This is a bug Google fixed in 4.1, but it doesn’t help you for older operating systems.  That’s why our advice is to use audio.* unless you need time dependent short sounds (remember you can only have one at a time) then you should use media.playEventSound() which has no volume control.

Rob

Hei Rob, thank you very much for your reply.

The lag problem was the reason why I use the media api for some sounds.

Like I said, now I use a variable to decide wether or not to play the sound. This works.

Its just sad about the time I lost, because it worked in the simulator but not on the device…

Anyway, thanks again Rob.

I use now a variable to check if the game is muted or not and play the sounds just if the game is not muted.

But this whole media/audio api seems a bit confused to me. I found another thing that works not like expected: when I set the media volume to zero (in the simulator) also the audio volume is zero.

But seems like I have to work with different mute variables, if I want to mute the music and the sounds ie like one live up, hit, jump, …

Just in case there is no other solution and somebody else finds that thread.

Cheers,

Hi Felix.

The two libraries are different.  The media.* is the older library and depends on native hardware decoding to render audio.  While it’s faster on older Android operating systems, it has major limits of only being able to play one sound at a time, and volume control is limited.  Let’s talk about that limitation because that could be your problem.  There are two play sound functions:

media.playSound()

media.playEventSound()

The second one, media.playEventSound(), which is the fastest way to play sound does not support volume controls.  See: http://docs.coronalabs.com/api/library/media/setSoundVolume.html

The first one, if I read the docs correctly, you have to play the sound and if it’s long enough, then you can adjust the volume of that sound after  you start playing it.  It does not set the overall system sound, but the sound for the currently playing one.

Because of these limits, we really prefer  you to use the audio.* library which is based on OpenAL/OpenES and lets  you have 32 channels to mix sound at the same time while independently controlling volume on each channel independently regardless of a sound playing as well as control the master volume.  The audio.* api is much more feature rich and solid.

But on Android devices older that Android 4.1, the sounds lag.  This is a bug Google fixed in 4.1, but it doesn’t help you for older operating systems.  That’s why our advice is to use audio.* unless you need time dependent short sounds (remember you can only have one at a time) then you should use media.playEventSound() which has no volume control.

Rob

Hei Rob, thank you very much for your reply.

The lag problem was the reason why I use the media api for some sounds.

Like I said, now I use a variable to decide wether or not to play the sound. This works.

Its just sad about the time I lost, because it worked in the simulator but not on the device…

Anyway, thanks again Rob.