声音无法在设备上播放[Titanium]

时间:2013-07-30 21:07:02

标签: ios audio titanium playback

我使用以下代码播放声音。声音在模拟器上正常工作但在设备上不起作用。这两个设备都运行相同的iOS版本。

有没有办法调试此错误?我该如何解决这个问题?

var soundLabel = Ti.UI.createView({
backgroundColor:'red',
width:125,
height:40,
top:75,
right:340
});




 soundLabel.addEventListener('click',function(e){
   var sound = Titanium.Media.createSound();
  sound.setUrl("/Sound/"+alphabet+".wav");  
    alert("HERE");
    sound.play();
 });

1 个答案:

答案 0 :(得分:1)

尝试在行sound.play();

上方添加以下行

Titanium.Media.audioSessionMode = Ti.Media.AUDIO_SESSION_MODE_PLAYBACK;

请查看Ti.Media.Sound.play() no sound on iPhone speaker, works only on headphones。我想你也可能有同样的问题。