2016-04-12 14 views
0

私はデスクトップ上でうまく動作するWebベースのメッセージングシステムを使用していますが、モバイルブラウザでは音声が開始されません。次のように 命令は、次のとおりです。音声がモバイルブラウザで再生されない

でこの問題発生しない何ブラウザ
var mySound = new buzz.sound("/sounds/new_msg", { 
             formats: [ "ogg", "mp3", "aac" ] 
            }); 

            mySound.play(); 
           }, function (err) { 
            // code to handle read error 
            console.log(err); 
           }); 

答えて

0

あなたの結果で私たちを更新し、このコードを使用してみてください:

function initAudio() { 
    var audio = new Audio('./path/to/my/sound.mp3'); 
    audio.addEventListener('play', function() { 
     // When the audio is ready to play, immediately pause. 
     audio.pause(); 
     audio.removeEventListener('play', arguments.callee, false); 
    }, false); 
    document.addEventListener('click', function() { 
     // Start playing audio when the user clicks anywhere on the page, 
     // to force Mobile Safari to load the audio. 
     document.removeEventListener('click', arguments.callee, false); 
     audio.play(); 
    }, false); 
} 
関連する問題