1
예제를 연결하여 온라인 튜토리얼을 따르려고합니다. 나는 이것이 MP3 파일을 재생해야한다고 생각합니다. Chrome 브라우저를 사용하고 있으며 최신 버전입니다. 콘솔에 오류가 발생하지 않습니다. 이 작품을 만들기 위해 무엇을 바꾸거나 추가해야하는지 잘 모르겠습니다.기본 웹 오디오 API가 사운드를 재생하지 않습니다.
<html>
<head>
<script type="text/javascript">
var context;
var sound1Buffer = null;
var url = 'https://dl.dropboxusercontent.com/u/1957768/SrtV2.mp3';
function init(){
try {
window.AudioContext = window.AudioContext || window.webkitAudioContext;
context = new AudioContext();
}
catch(e) {
alert("web Audio api is not supported!");
}
}
window.addEventListener('load', init, false);
function loadDogSound(url){
var request = new XMLHttpRequest();
request.open("GET", url, true);
request.responseType = 'arrayBuffer';
//decode asynchronously
request.onload = function(){
context.decodeAudioData(request.response, function(buffer){
sound1Buffer = buffer;
}, onError);
}
request.send();
}
function playSound(sound1Buffer){
var source = context.createBufferSource();
source.sound1Buffer = sound1Buffer;
source.connect(context.destination);
source.start(0);
}
</script>
</head>
<body>
</body>
</html>
함수가'초기화하기()'문제없이 실행 :
다음은 작업 예입니다. 그래서 브라우저에로드 될 때 모든 기능이 실행된다고 생각하게되었습니다. 'window.addEventListener'에서 무엇인가를 변경해야합니까? 'loadDogSound'와'playSound'를 호출하는 올바른 방법은 무엇입니까? 용서 해주십시오.하지만 저는 아직도이 물건에 대해 아주 새롭습니다. – oxxi
안녕하세요, 저는 웹 오디오 API를 망설이고 있습니다. 내가 도와 줄 수있어? 채팅 하죠? - http://chat.stackoverflow.com/rooms/32365/room-for-uber5001-and-oxxi – uber5001