Created
June 15, 2012 18:52
-
-
Save mattlundstrom/2938153 to your computer and use it in GitHub Desktop.
Flash Video
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var nc:NetConnection = new NetConnection(); | |
nc.connect(null); | |
var ns:NetStream = new NetStream(nc); | |
ns.client = {}; | |
ns.client.onMetaData = nsOnMetaData; | |
ns.client.onCuePoint = nsOnCuePoint; | |
ns.addEventListener(NetStatusEvent.NET_STATUS, nsOnNetStatus); | |
ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, onAsyncError); | |
var video:Video = new Video(); | |
addChild(video) | |
video.attachNetStream(ns); | |
ns.play("video.flv"); | |
// VIDEO EVENTS | |
function nsOnMetaData(item:Object):void { | |
trace("METADATA:"); | |
} | |
function nsOnCuePoint(item:Object):void { | |
trace("CUEPOINT:"); | |
trace(item.name + "\t" + item.time); | |
switch (item.name) { | |
case "cuepointName" : | |
// WHEN CP1 HITS DO THIS | |
break; | |
} | |
} | |
function nsOnNetStatus(e:NetStatusEvent):void { | |
trace("NETSTATUS:"); | |
trace(e.info.code); | |
switch (e.info.code) { | |
case "NetStream.Play.Start" : | |
break; | |
case "NetStream.Play.Stop" : | |
// WHEN THE VIDEO ENDS CODE HERE IS EXECUTED | |
break; | |
case "NetStream.Buffer.Empty" : | |
break; | |
} | |
} | |
function onAsyncError(e:AsyncErrorEvent):void { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment