标签:
需要在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
标签:
原文地址:http://www.cnblogs.com/daipianpian/p/5123986.html