• 播放本地MP3 (一)


    package {
    	import flash.display.Sprite;
    	import flash.media.Sound;
    	import flash.media.SoundChannel;
    	import flash.net.URLLoader;
    	import flash.net.URLRequest;
    	import flash.text.TextField;
    	import flash.events.MouseEvent;
    	import flash.text.TextFieldAutoSize;
    
    	public class SoundChannel_stopExample extends Sprite {
    		private var snd:Sound = new Sound();
    		private var channel:SoundChannel = new SoundChannel();
    		private var button:TextField = new TextField();
    
    		public function SoundChannel_stopExample() {
    			var req:URLRequest=new URLRequest("陈奕迅 - 一丝不挂.mp3");
    			snd.load(req);
    
    			button.x=10;
    			button.y=10;
    			button.text="PLAY";
    			button.border=true;
    			button.background=true;
    			button.selectable=false;
    			button.autoSize=TextFieldAutoSize.CENTER;
    
    			button.addEventListener(MouseEvent.CLICK, clickHandler);
    
    			this.addChild(button);
    		}
    
    		private function clickHandler(e:MouseEvent):void {
    			var pausePosition:int=channel.position;
    
    			if (button.text=="PLAY") {
    				channel=snd.play(pausePosition);
    				button.text="PAUSE";
    			} else {
    				channel.stop();
    				button.text="PLAY";
    			}
    		}
    	}
    }
  • 相关阅读:
    android selector失效的原因
    Android TabActivity使用方法
    Android Build.VERSION.SDK_INT兼容介绍
    数组与指针
    字符串与字符串函数
    C控制语句:分支和跳转
    C控制语句:循环
    运算符、表达式、语句
    select
    正则验证数字
  • 原文地址:https://www.cnblogs.com/leon3286/p/1706257.html
Copyright © 2020-2023  润新知