Impressum
  • Artikel ist eingeordnet in:
  • Flash


AS3: Video in Flash abspielen geschrieben am 25.10.2008

Hier der Quellcode um ein Video (flv) in Flash mit Actionscript abzuspielen:

ActionScript3 //Hilfsobjet um Infos zwischenzuspeichern var playerOBJ:Object=new Object(); playerOBJ.src=''; playerOBJ.width=320; playerOBJ.height=240; playerOBJ.videoURL=''; playerOBJ.videotype=''; playerOBJ.vidostatus=-1; playerOBJ.videolenge=0; playerOBJ.videofps=0; //Für Video flv-Stream var connection:Netconnection; connection = new Netconnection(); connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler); connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler); connection.connect(null); var stream:NetStream; function ns_onMetaData(info:Object):void { trace('metadata: duration=' + info.duration); trace('width=' + info.width); trace('height=' + info.height); trace('framerate=' + info.framerate); } function ns_onCuePoint(info:Object):void { trace('cuepoint: time=' + info.time + ' name=' + info.name + ' type=' + info.type); } function netStatusHandler(event:NetStatusEvent):void { trace('>'+event.info.code) /* Ausgabe: >NetConnection.Connect.Success >NetStream.Play.Start >NetStream.Buffer.Empty >NetStream.Buffer.Full >NetStream.Buffer.Flush >NetStream.Play.Stop >NetStream.Buffer.Empty >NetStream.Buffer.Flush */ switch (event.info.code) { case 'NetStream.Play.StreamNotFound': trace('Stream not found: ' + playerOBJ.videoURL); break; } }; function securityErrorHandler(event:SecurityErrorEvent):void { trace('securityErrorHandler: ' + event); }; function loadVideo(url:String):void { playerOBJ.videoURL=url; stream = new NetStream(connection); stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler); stream.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler); var custom_obj:Object = new Object(); custom_obj.onMetaData = ns_onMetaData; custom_obj.onCuePoint = ns_onCuePoint; stream.client = custom_obj; var video:Video = new Video(); video.attachNetStream(stream); stream.play(playerOBJ.videoURL); addChild(video); };
Quelle: Flashhilfe und etwas probiererei.


schreibe den ersten Kommentar:


Inhalt zur freien Verwendung gibs es beim Thema Downloads.
nach oben springen
mehr auf: Instagram, github, thingiverse