Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package src.standard
- {
- import flash.events.*;
- import flash.media.*;
- import flash.net.*;
- import src.global.*;
- import fl.video.*;
- public class Box2Video extends Box2
- {
- var showClose:Boolean;
- public var paused:Boolean;
- var currentSeekInterval:int;
- public var ns:NetStream;
- public var duration:Number;
- var w:int;
- var h:int;
- public function Box2Video(w:Number, h:Number, url:String = null, loop:Boolean = false, showClose:Boolean = true)
- {
- this.w = w;
- this.h = h;
- var myVideo:Video = new Video();
- myVideo.smoothing = true;
- var nc:NetConnection = new NetConnection();
- nc.connect(null);
- ns = new NetStream(nc);
- myVideo.attachNetStream(ns);
- var client:Object = new Object();
- client.onCuePoint = cuePointHandler;
- client.onMetaData = metaDataHandler;
- ns.client = client;
- ns.addEventListener(NetStatusEvent.NET_STATUS, function(e:NetStatusEvent)
- {
- Console.log("Video status");
- for (var str:String in e.info)
- {
- Console.log(" " + str + ": " + e.info[str]);
- }
- if (e.info.code == "NetStream.Play.Stop")
- videoEnd();
- });
- function cuePointHandler(infoObject:Object):void
- {
- Console.log("Cue Point");
- for (var str:String in infoObject)
- Console.log(" " + str + ": " + infoObject[str]);
- }
- function metaDataHandler(infoObject:Object):void
- {
- Console.log("Meta Data");
- for (var str:String in infoObject)
- Console.log(" " + str + ": " + infoObject[str]);
- }
- ns.play(url);
- addChild(myVideo);
- setChildIndex(myVideo, 0);
- addEventListener(Event.ADDED_TO_STAGE, function(e:Event)
- {
- myVideo.width = w;
- myVideo.height = h;
- Console.log("Video init: width= " + w + ", height= " + h);
- });
- }
- public function getPlayheadPercentage()
- {
- return ns.time / duration;
- }
- public function videoEnd()
- {
- dispatchEvent(new Event(Event.COMPLETE));
- }
- public function show()
- {
- visible = true;
- }
- public function hide()
- {
- // Stop the player
- visible = false;
- }
- public function flvScrub(n:Number)
- {
- //trace("scrub=" + n);
- ns.seek(n * duration);
- return "";
- }
- public function flvPlay(urlIn:String = "")
- {
- paused = false;
- if (urlIn != "")
- {
- ns.play(urlIn);
- }
- else
- {
- ns.resume();
- }
- }
- public function flvPause()
- {
- paused = true;
- ns.pause();
- // Pause player
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement