Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Livestream

Explorer ,
Nov 06, 2013 Nov 06, 2013

Hello all,

I am developing mobile app for ios devices using flash builder. How to play a live stream video from a URL ?

TOPICS
ActionScript
720
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 06, 2013 Nov 06, 2013

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/

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 06, 2013 Nov 06, 2013

Thanks for your reply

Can you share some examples for using netconnection and netstream ?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 06, 2013 Nov 06, 2013

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);

    }

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 06, 2013 Nov 06, 2013

it throws Error #1069: Property onPlayStatus not found

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 06, 2013 Nov 06, 2013

not sure where that came from. try adding...

private function onPlayStatus (event):void {

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 06, 2013 Nov 06, 2013
LATEST

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/NetStream.html#event:on...

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 {

}

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines