·您当前的位置:首页 > 技术教程 > AS2与AS3技术 >

[AS3]定义要缩放的矩形视频播放源代码实例

时间:2015-09-21 08:43酷播
定义要缩放的矩形,然后设置 Stage.displayState 属性。有关详细信息,请参阅用于 Adobe Flash Platform 的 ActionScript 3.0 参考

定义要缩放的矩形,然后设置 Stage.displayState 属性。有关详细信息,请参阅用于 Adobe Flash Platform 的 ActionScript 3.0 参考。完整的示例(如下所示)添加了额外的代码,这些代码创建连接以及视频的 NetStream 对象,并开始播放该视频。

  1. package  
  2. {  
  3.     import flash.net.NetConnection;  
  4.     import flash.net.NetStream;  
  5.     import flash.media.Video;  
  6.     import flash.display.StageDisplayState;  
  7.     import fl.controls.Button;  
  8.     import flash.display.Sprite;  
  9.     import flash.events.MouseEvent;  
  10.     import flash.events.FullScreenEvent;  
  11.     import flash.geom.Rectangle;  
  12.       
  13.     public class FullScreenVideoExample extends Sprite  
  14.     {      
  15.         var fullScreenButton:Button = new Button();  
  16.         var video:Video = new Video();  
  17.   
  18.         public function FullScreenVideoExample()  
  19.         {  
  20.             var videoConnection:NetConnection = new NetConnection();  
  21.             videoConnection.connect(null);  
  22.               
  23.             var videoStream:NetStream = new NetStream(videoConnection);  
  24.             videoStream.client = this;  
  25.   
  26.             addChild(video);  
  27.               
  28.             video.attachNetStream(videoStream);  
  29.               
  30.             videoStream.play("http://www.helpexamples.com/flash/video/water.flv");  
  31.               
  32.             fullScreenButton.x = 100;  
  33.             fullScreenButton.y = 270;  
  34.             fullScreenButton.label = "Full Screen";  
  35.             addChild(fullScreenButton);  
  36.             fullScreenButton.addEventListener(MouseEvent.CLICK, fullScreenButtonHandler);  
  37.         }  
  38.   
  39.         private function fullScreenButtonHandler(event:MouseEvent)  
  40.         {   
  41.             var screenRectangle:Rectangle = new Rectangle(video.x, video.y, video.width, video.height);  
  42.             stage.fullScreenSourceRect = screenRectangle;  
  43.             stage.displayState = StageDisplayState.FULL_SCREEN;   
  44.         }      
  45.           
  46.         public function onMetaData(infoObject:Object):void  
  47.         {  
  48.             // stub for callback function  
  49.         }  
  50.     }  

 

热门文章推荐

请稍候...

保利威视云平台-轻松实现点播直播视频应用

酷播云数据统计分析跨平台播放器