[AS3]AS3.0写的一个mp3播放器源代码的实例
[AS3]AS3.0写的一个mp3播放器源代码的实例,mp3播放器,mp3播放器源代码
[AS3]AS3.0写的一个mp3播放器源代码的实例,mp3播放器,mp3播放器源代码
- package {
- import flash.display.*;
- import flash.events.*;
- import flash.media.Sound;
- import flash.media.SoundChannel;
- import flash.media.SoundLoaderContext;
- import flash.media.ID3Info;
- import flash.net.URLRequest;
- import flash.external.ExternalInterface;
- import flash.utils.*;
- public class alarmSound extends Sprite{
- private var alarm:Sound;
- private var mp3URL:String = "http://www.cuplayer.com/test.mp3"; //"alarm_2.mp3";
- private var song:SoundChannel;
- function alarmSound() {
- inited();
- }
- private function inited():void {
- alarm = new Sound();
- var req:URLRequest = new URLRequest(mp3URL);
- var buffer:SoundLoaderContext = new SoundLoaderContext(5*1000);
- alarm.addEventListener(Event.COMPLETE, completeHandler);
- alarm.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
- alarm.addEventListener(ProgressEvent.PROGRESS, processHandler);
- alarm.addEventListener(Event.ID3, id3Handler);
- alarm.load(req, buffer);
- song = alarm.play(0, 0);//CuPlayer.com提示:从0开始,循环1次
- song.addEventListener(Event.SOUND_COMPLETE, playCompleteHandler);
- }
- private function processHandler(pro:ProgressEvent):void {
- var percent:Number = Math.floor(pro.bytesLoaded/pro.bytesTotal*100*100)/100;
- trace(pro.bytesLoaded + "---" + pro.bytesTotal + "CuPlayer.com提示:已加载..." + percent + "%");
- }
- private function playCompleteHandler(...args):void {
- //trace(alarm.length/1000 + "---" + song.position/1000);
- var estimatedTotal:Number = Math.ceil(alarm.length / (alarm.bytesLoaded / alarm.bytesTotal));
- var position:Number = Math.round(100 * (song.position / estimatedTotal));
- trace(estimatedTotal/1000/60 + "----" + position);
- }
- private function completeHandler(evt:Event):void {
- alarm.removeEventListener(Event.COMPLETE, completeHandler);
- //trace(alarm.length + "---" + song.position);
- }
- private function ioErrorHandler(evt:Event):void {
- }
- private function id3Handler(evt:Event):void {
- var id3:ID3Info = alarm.id3;
- trace('CuPlayer.com提示:音乐名称:' + id3.songName);
- trace('CuPlayer.com提示:专辑: ' + id3.album);
- trace('CuPlayer.com提示:艺术家:' + id3.artist);
- }
- }
- }
[AS3]AS3.0写的一个mp3播放器源代码的实例,mp3播放器,mp3播放器源代码
热门文章推荐
- 纯HLS(m3u8)跨平台技术(HLSPlayer,m3u8Player跨平台多终端)
- DiscuzX3.2酷播视频插件(dz论坛自定义视频插件带广告
- [微信视频]实现网站中的视频在微信平台上正常播放(超多组图)
- [rtsp]海康威视监控摄像头实现web端无插件监控实拍效果
- 很酷,酷播wordpress视频插件(支持PC/安卓/苹果跨平台播放)
- [组图]微信视频技术:支持微信视频直播和视频点播
- [AS3]as3.0的rtmp流媒体播放器写法源代码示例
- 一步一步教你制作FLV网页视频播放器
请稍候...