Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-12284] iOS: Sound player volume is really low, especially on device

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionInvalid
Resolution Date2013-02-21T20:25:55.000+0000
Affected Version/sn/a
Fix Version/s2013 Sprint 04 API, 2013 Sprint 04
ComponentsiOS
Labelsapi
ReporterDavide Cassenti
AssigneeVishal Duggal
Created2013-01-15T02:39:40.000+0000
Updated2017-07-26T03:31:55.000+0000

Description

Problem description

The volume of the sound player, especially on device, is really low; also setting the volume to 1.0 - loudest - does not make it very high. Volume does not depend on the device volume as well.

Steps to reproduce

Just create a Sound player and run the code on a device:
var player = Ti.Media.createSound({
    url:"sound.wav",
    volume: 1.0
});
player.play();
On the simulator the situation is a bit better, but overall the volume is quite low.

Comments

  1. Vishal Duggal 2013-02-21

    The SoundProxy uses the applications shared audio session which can be configured through the Ti.Media module. There are 4 audio session modes that can be used for playback. Ti.Media.AUDIO_SESSION_MODE_AMBIENT - Sound directed through speakers. Ringer silent mutes volume. Ti.Media.AUDIO_SESSION_MODE_SOLO_AMBIENT - Sound directed through speakers. Ringer silent mutes volume. Ti.Media.AUDIO_SESSION_MODE_PLAYBACK - Sound directed through speakers. Ringer silent ignored. Ti.Media.AUDIO_SESSION_MODE_PLAY_AND_RECORD - Sound directed through receiver. Ringer silent ignored. Not recommended for playback. However the volume of the SoundProxy is not tied to the hardware volume. It is actually a fraction of the current device volume. To change the volume of the device use the Ti.Media.appMusicPlayer and set the volume on that object. All these volume settings are of course limited by the volume of the sound file you are trying to play. I would suggest that you use set the Ti.Media.audioSessionMode property to one of Ti.Media.AUDIO_SESSION_MODE_AMBIENT, Ti.Media.AUDIO_SESSION_MODE_SOLO_AMBIENT, Ti.Media.AUDIO_SESSION_MODE_PLAYBACK, set the player.volume=1.0 and set the Ti.Media.appMusicPlayer.volume=1.0. Sample Code below. Replace with your own sound file to see how things work together.
       var win = Ti.UI.createWindow({
           backgroundColor : 'white',
       });
       
       var modes = [Ti.Media.AUDIO_SESSION_MODE_AMBIENT, Ti.Media.AUDIO_SESSION_MODE_SOLO_AMBIENT, Ti.Media.AUDIO_SESSION_MODE_PLAYBACK,Ti.Media.AUDIO_SESSION_MODE_PLAY_AND_RECORD]
       
       var mode = 0;
       var view = Ti.UI.createView({
       	layout:'vertical',
       	height:Ti.UI.SIZE
       })  
       
       var appMusicVolume = Ti.UI.createView({
       	layout:'vertical',
       	height:Ti.UI.SIZE
       })
       
       var l1 = Ti.UI.createLabel({
       	text:'APP MUSIC PLAYER VOLUME'
       })
       
       var sl1 = Ti.UI.createSlider({
       	min:0,
       	max:1
       })
       
       var playerVolume = Ti.UI.createView({
       	layout:'vertical',
       	height:Ti.UI.SIZE
       })
       
       var l2 = Ti.UI.createLabel({
       	text:'PLAYER VOLUME'
       })
       
       var sl2 = Ti.UI.createSlider({
       	min:0,
       	max:1
       })
       
       appMusicVolume.add(l1);
       appMusicVolume.add(sl1);
       playerVolume.add(l2);
       playerVolume.add(sl2);
       
       
       var b1 = Ti.UI.createButton({
       	title:'PLAY FILE',
       	top:10
       })
       
       var b2 = Ti.UI.createButton({
       	title:'SET AUDIO SESSION MODE',
       	top:10
       })
       
       var label = Ti.UI.createLabel({
       	top:10,
       	text:'SESSION MODE'
       })
       
       var label2 = Ti.UI.createLabel({
       	top:10,
       	text:'VOLUME'
       })
       
       
       var getAudioSessionMode = function(){
       	var sessionMode = Ti.Media.audioSessionMode;
       	if (sessionMode == Ti.Media.AUDIO_SESSION_MODE_AMBIENT) {
       		label.text = 'SESSION MODE AMBIENT'
       	}
       	else if (sessionMode == Ti.Media.AUDIO_SESSION_MODE_SOLO_AMBIENT) {
       		label.text = 'SESSION MODE SOLO AMBIENT'
       	}
       	else if (sessionMode == Ti.Media.AUDIO_SESSION_MODE_PLAYBACK) {
       		label.text = 'SESSION MODE PLAYBACK'
       	}
       	else if (sessionMode == Ti.Media.AUDIO_SESSION_MODE_PLAY_AND_RECORD) {
       		label.text = 'SESSION MODE PLAY AND RECORD'
       	}
       	else if (sessionMode == Ti.Media.AUDIO_SESSION_MODE_RECORD) {
       		label.text = 'SESSION MODE RECORD'
       	}
       	else {
       		label.text = 'SESSION MODE UNKNOWN '+sessionMode
       	}
       }
       
       win.addEventListener('open',function(){
       	getAudioSessionMode();
       	sl1.value = Ti.Media.appMusicPlayer.volume;
       	sl2.value = player.volume;
       });
       
       view.add(appMusicVolume);
       view.add(playerVolume);
       view.add(b1);
       view.add(b2);
       view.add(label);
       view.add(label2);
       win.add(view);
       win.open();
       
       var player = Ti.Media.createSound({
           url:"cricket.wav",
           volume: 1.0
       });
       
       b1.addEventListener('click',function(){
       	player.play();
       })
       
       b2.addEventListener('click',function(){
       	mode = mode % modes.length;
       	player.stop();
       	Ti.Media.setAudioSessionMode(modes[mode]);
       	getAudioSessionMode();
       	mode++;
       })
       
       Ti.Media.addEventListener('volume',function(e){
       	label2.text = 'VOLUME: '+e.volume;
       	sl1.value = Ti.Media.appMusicPlayer.volume;
       	sl2.value = player.volume;
       })
       
       var sl1Valid = false;
       sl1.addEventListener('touchstart',function(){
       	sl1Valid = true;
       })
       sl1.addEventListener('touchend',function(){
       	sl1Valid = false;
       })
       sl1.addEventListener('change',function(e){
       	if(sl1Valid == true) {
       		Ti.Media.appMusicPlayer.volume = e.value;
       	}
       })
       var sl2Valid = false;
       sl2.addEventListener('touchstart',function(){
       	sl2Valid = true;
       })
       sl2.addEventListener('touchend',function(){
       	sl2Valid = false;
       })
       sl2.addEventListener('change',function(e){
       	if(sl2Valid == true) {
       		player.volume = e.value;
       	}
       })
       
  2. Lee Morris 2017-07-26

    Closing ticket as invalid.

JSON Source