A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: want to loop external video

  1. #1
    Junior Member
    Join Date
    Jun 2007
    Posts
    20

    want to loop external video

    Hi,

    I've use this script to load video into my swf.

    Actionscript Code:
    // ActionScript 3.0
    var video:Video = new Video();
    addChild(video);

    var nc:NetConnection = new NetConnection();
    nc.connect(null);

    var ns:NetStream = new NetStream(nc);
    ns.client = {onMetaData:ns_onMetaData, onCuePoint:ns_onCuePoint};

    video.attachNetStream(ns);
    ns.play("http://www.helpexamples.com/flash/video/cuepoints.flv");

    function ns_onMetaData(item:Object):void {
        trace("metaData");
        // Resize video instance.
        video.width = item.width;
        video.height = item.height;
        // Center video instance on Stage.
        video.x = (stage.stageWidth - video.width) / 2;
        video.y = (stage.stageHeight - video.height) / 2;
    }
    function ns_onCuePoint(item:Object):void {
        trace("cuePoint");
        trace(item.name + "\t" + item.time);
    }

    how do i loop the video?

    and is it possible that i replace with another video after the 1st video is play finish?

  2. #2
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429
    You'll need to add an event listener to your connection object and listen for NetStatusEvent.NET_STATUS events. The event object passed to your handler will have a .info object property. .info will have a .code string property. You'll need to conditionally look for specific strings in order to respond appropriately.

    Actionscript Code:
    var nc:NetConnection = new NetConnection();
    nc.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
    nc.connect(null);

    function onNetStatus(event:NetStatusEvent):void{
                switch (event.info.code) {
                    case "NetStream.Play.Stop":
                        // commands for restarting
                        break;
                    case "NetStream.Play.StreamNotFound":
                        trace("Unable to locate video: " + videoURL);
                        break;
                }  
    }

    You can also just call netstream.play() with a different .flv at that point.

  3. #3
    Junior Member
    Join Date
    Jun 2007
    Posts
    20
    Quote Originally Posted by jAQUAN View Post
    You can also just call netstream.play() with a different .flv at that point.
    Hi, sorry that I found out I don't need to loop the video.

    What I want is after the video play finish, it goto and play 2nd frame.

    how to do that?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center