3、CreateJS介紹-SoundJS


需要在html5文件中引入的CreateJS庫文件是soundjs-0.5.2.min.js

HTML5文件如下:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>3、CreateJS介紹-SoundJS</title>
    <script src="soundjs-0.5.2.min.js"></script>
</head>
<body>
    <div>
        <h1 id="status">startUp</h1>
    </div>

    <script src="app.js"></script>
</body>
</html>

在HTML5文件中引入的app.js文件源碼如下:

 1 /**
 2  * create CreateJS介紹-SoundJS-app.js by dpp on 2016/1/4
 3  * @authors Your Name (you@example.org)
 4  * @date    2016-01-04 01:30:25
 5  * @version $Id$
 6  */
 7 
 8 var displayStatus;
 9 displayStatus = document.getElementById('status');
10 var src = '1.mp3';
11 createjs.Sound.alternateExtensions=['mp3'];
12 createjs.Sound.addEventListener('fileload',playSound);
13 createjs.Sound.registerSound(src);
14 
15 displayStatus.innerHTML = 'Waiting for load to complete';
16 
17 function playSound(event){
18     soundIntance = createjs.Sound.play(event.src);
19     displayStatus.innerHTML = 'playing source:' + event.src;
20 }

還需引入一個MP3文件,我寫的例子中的MP3文件名稱是1.mp3,可替換成其他的名字

 例子"3、CreateJS介紹-SoundJS"的源碼地址:https://github.com/daipianpian/CreateJS-Study/tree/master/1%E3%80%81CreateJS%E4%BB%8B%E7%BB%8D/L03_SoundJS


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM