您好,登錄后才能下訂單哦!
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-type" content="text/html; charset = utf-8"> </head> <script type="text/javascript" charset="utf-8"> function pageLoaded(){ var canvas = document.getElementById('testcanvas');//得到畫布 var context = canvas.getContext('2d');//得到繪圖環境 參數為繪圖環境的類型 //檢查音頻支持 var audiotest = document.createElement('audio'); var mp3Support,oggSupport,wavSupport; if(audiotest.canPlayType){ /* MP3格式:字符串audio/mpeg;支持的瀏覽器:IE9+、Chrome Vorbis格式:字符串audio/ogg,codecs=”vorbis”;支持的瀏覽器:Firefox 3.5+、Chrome、Opera 10.5+ WAV格式:字符串audio/wav,codecs=”1”;支持的瀏覽器:Firefox 3.5+、Opera 10.5+、Chrome */ mp3Support = "" != audiotest.canPlayType('audio/mpeg'); oggSupport = "" != audiotest.canPlayType('audio/ogg; codecs = "vorbis"'); wavSupport = "" != audiotest.canPlayType('audio/wav,codecs="1"'); } else{ mp3Support = false; oggSupport = false; wavSupport = false; } var soundFileExtn = oggSupport?'.ogg':mp3Support?'.mp3':wavSupport?'.wav':undefined; if(soundFileExtn){ //動態加載audio文件 var audio = new Audio(); //等待音頻文件加載完成 然后再播放 audio.addEventListener('canplaythrough',function(){ audio.play(); }); audio.src="/testmusic/8466/8466"+soundFileExtn; } } </script> <body onload="pageLoaded();"> <canvas width="1200" height="480" id="testcanvas" > </canvas> <audio src="/testmusic/8466/8466.wav" controls = "controls" > </audio> <audio src="/testmusic/8466/8466.mp3" controls="controls2"> </audio> <audio controls="controls3"> <!--瀏覽器會選擇第一個支持的格式 音頻格式 MINE-type MP3 audio/mpeg Ogg audio/ogg Wav audio/wav --> <source src="/testmusic/8466/8466.wav" type="audio/wav"> <source src="/testmusic/8466/8466.mp3" type="audio/mpeg"> </audio> </body> </html>
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。