Copy link to clipboard
Copied
Hello all,
I am developing mobile app for ios devices using flash builder. How to play a live stream video from a URL ?
Copy link to clipboard
Copied
you'll want to use the netconnection and netstream classes.
This link is your friend, bookmark it:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/
Copy link to clipboard
Copied
Thanks for your reply
Can you share some examples for using netconnection and netstream ?
Copy link to clipboard
Copied
Here's an example taken from the as3 language reference library from the above link to get started, likely you'll have to use rtmp streaming with livestream...
package {
import flash.display.Sprite;
import flash.events.NetStatusEvent;
import flash.events.SecurityErrorEvent;
import flash.media.Video;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.events.Event;
public class NetConnectionExample extends Sprite {
private var videoURL:String = "http://www.helpexamples.com/flash/video/cuepoints.flv";
private var connection:NetConnection;
private var stream:NetStream;
private var video:Video = new Video();
public function NetConnectionExample() {
connection = new NetConnection();
connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
connection.connect(null);
}
private function netStatusHandler(event:NetStatusEvent):void {
switch (event.info.code) {
case "NetConnection.Connect.Success":
connectStream();
break;
case "NetStream.Play.StreamNotFound":
trace("Stream not found: " + videoURL);
break;
}
}
private function securityErrorHandler(event:SecurityErrorEvent):void {
trace("securityErrorHandler: " + event);
}
private function connectStream():void {
addChild(video);
var stream:NetStream = new NetStream(connection);
stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
stream.client = new CustomClient();
video.attachNetStream(stream);
stream.play(videoURL);
}
}
}
class CustomClient {
public function onMetaData(info:Object):void {
trace("metadata: duration=" + info.duration + " width=" + info.width + " height=" + info.height + " framerate=" + info.framerate);
}
public function onCuePoint(info:Object):void {
trace("cuepoint: time=" + info.time + " name=" + info.name + " type=" + info.type);
}
}
Copy link to clipboard
Copied
it throws Error #1069: Property onPlayStatus not found
Copy link to clipboard
Copied
not sure where that came from. try adding...
private function onPlayStatus (event):void {
}
Copy link to clipboard
Copied
the function mentioned above should probably go in the class CustomClient...
class CustomClient {
public function onMetaData(info:Object):void {
trace("metadata: duration=" + info.duration + " width=" + info.width + " height=" + info.height + " framerate=" + info.framerate);
}
public function onCuePoint(info:Object):void {
trace("cuepoint: time=" + info.time + " name=" + info.name + " type=" + info.type);
}
private function onPlayStatus (info):void {
}
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now