Can't detect when my netstream FLV stops.

I want to detect when my FLV stops and jump to another video. How can I do this? My current code is:
The first video plays fine, but it just stops when it is done.
// Setting up my netstream and playing my video
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
var vid:Video = new Video(320, 240);
this.addChild(vid);
vid.attachNetStream(ns);
ns.play("video0.flv");
ns.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
// This is what I thought I had to do to detect the stop
function netStatusHandler(event:NetStatusEvent):void {
    switch(event) {
      case "NetStream.Play.Complete":
         ns.close();
         ns.play("video2.flv");
// Handles Async errors by ignoring them
function asyncErrorHandler(event:AsyncErrorEvent):void {
    // Ignore
Thanks!

Ok, so I made the changes and now it seems the movie merely freezes when finished playing. My code that is for clicking hot spots
and playing videos works though. I do also have some trouble with the movies either playing only a second or two, then stopping, as
well, or still hearing some of the sound form the previous video. Before I had used the (ns.time == oldTime) to determine if the video
had stopped or not, but it seems to get me into trouble. Any advice?
Thanks for the help so far.
My code
gotoAndStop(1);
// Loading Text File into Array
var textFile:URLRequest = new URLRequest("info.txt");
var textLoader:URLLoader = new URLLoader();
textLoader.load(textFile);
var inputArray:Array = new Array();
var videoArray:Array = new Array();
textLoader.addEventListener(Event.COMPLETE, loadComplete);
var i:int = 0;
var j:int;
var currentSize:int = 0;
var currentVideo:int = 0;
addEventListener(Event.ENTER_FRAME,onEnterFrame);
var oldTime:Number = -1;
stage.addEventListener(MouseEvent.CLICK,mouseClick);
var currentNumber:int = 0;
var counter:int;
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
ns.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
var vid:Video = new Video(320, 240);
this.addChild(vid);
vid.attachNetStream(ns);
ns.play("video0.flv");
function onEnterFrame(event:Event) {
    //if (ns.time == oldTime) {
        //if (videoArray[currentVideo].length <= 2) {
            //ns.close();
            //gotoAndStop(2);
        //else
            //newVideo(videoArray[currentVideo][1]);
    //oldTime = ns.time;
function mouseClick(event:MouseEvent) {
    if (videoArray[currentVideo].length > 2) {
        for (i = 2; i < videoArray[currentVideo].length; i+=5) {
            if (mouseX >= videoArray[currentVideo][i+1] && mouseX <= videoArray[currentVideo][i+2] &&
                mouseY >= videoArray[currentVideo][i+3] && mouseY <= videoArray[currentVideo][i+4]) {
                    newVideo(videoArray[currentVideo][i]);
function asyncErrorHandler(event:AsyncErrorEvent):void {
    // Ignore
function loadComplete(event:Event):void {
    textLoader.removeEventListener(Event.COMPLETE, loadComplete);
    var tempString:String = textLoader.data;
    inputArray = tempString.replace(/^\s+/,"").replace(/\s+$/,"").split(/\s+/);
    while (i < inputArray.length) {
        videoArray[currentNumber] = new Array();
        currentSize = inputArray[i];
        counter = 0;
        for (j = i; j < (i + currentSize); j++) {
            videoArray[currentNumber][counter] = inputArray[j];
            counter++;
        i = j;
        currentNumber++;
    inputArray = null;
function netStatusHandler(event:NetStatusEvent):void {
    switch(event.info.code) {
      case "NetStream.Play.Complete":
         ns.play("video2.flv");
         break;
function newVideo(newTarget:int) {
        //ns.close();
        ns.play("video" + newTarget + ".flv");
        currentVideo = newTarget;

Similar Messages

  • How can I detect when a sub vi finishes

    Hi All,
    I'm new to labview and would like some assistance.
    I have produced a sub vi that generates 2 half sine wave of adjustable frequency and amplitude. These are cascaded to produce a number of cycles. These are all included in a case statement. The false state produces a dc output and the true state produces the sine cycles.
    Before the button is pressed a dc level is output, when it is pressed  a number of sine cycles are out and when they have finished the dc level should reappear.
    I would like to know how to detect the completion of the sub vi in the true case so I can switch the case statement back to false asap.
    I'm having problems with gaps in the output data when the sub vi teminates and the case statement reverts back to the false state.
    Many thanks
    Andy
    Attachments:
    PulseGeneration.vi ‏164 KB
    HalfWaveBlock.vi ‏77 KB

    Hello Andy
    Thank you for getting in touch regarding your problem, I am an applications engineer at National Instruments and I will be supporting you with your query. As I understand you have a case structure which opens a sub vi, runs for a while and then changes back to its original state, and the problem you are having is switching from the vi execution case to an alternative case.
    Thank you for sending in your vi's, I have been able to look at the HalfWaveBlock vi, but have not been able to open the pulse generation vi, could you send this again please? I can then look at your code and possible ways to implement the functionality.
    There are a few options for approaching this task.
    - Time the sub vi execution and add a timing condition to the case structure in your main code.
    - Have a condition in the sub vi that alerts the main vi of completion.
    I have also found some resources which will help you understand the functions you are using and will also give you some ideas for implementing further functionality.
    - Execution Structures: http://zone.ni.com/devzone/cda/tut/p/id/12293
    - VI analyser toolkit: http://zone.ni.com/devzone/cda/tut/p/id/5046
    - Sub Vi indicator: http://digital.ni.com/public.nsf/allkb/26B1D8C3629475B686256DAD005816F6?OpenDocument
    - Timing, Shift Registers and case structures: http://forums.ni.com/t5/forums/replypage/board-id/170/message-id/579608/tab/rich
    There are also a number of examples available through the help tab and example finder window within LabVIEW itself. A few that I recommend looking at are.
    - Dynamic Load Example.vi
    - Dynamically Monitor VI
    If you could look at these resources and send me your code, we can then both continue to work on a solution to this issue.
    Regards
    Stephanie L
    Applications Engineer
    National Instruments UK and Ireland

  • How can i control when my animation starts/stops with external JS

    I am making a web app that will allow you to go through "pages" by clicking and dragging or sliding your finger (touch devices).
    I am wanting to make a seperate animation on Edge for each page and play it when the current page is on witht the relevant edge comp.
    So far my code allows me to know what page is being viewed and that the animation should be played, however I can not figure out how to play the comp.
    ie.
    WHEN page = 1, play composition "page1".
         If currentPage is not currentPage, stop composition "page 1".
    Please could you help me as I've been racking my brain all day to figure this out.

    Hi,
    You'll find a tutoriel here.
    Then, example #1 and example #2.

  • How can I detect when a hibernate mode accures during my program?

    hello everyone
    I 'm trying to find some way to let my program know the moment when the user tries to get the computer into hibernate mode ?
    is this possible in any way under java?

    Since you already know about JNI, and since you've already been told you can't do it in pure Java, what more are you waiting for? You might as well investigate the JNI route. The only other option I see is JNA.

  • How can I detect when a text field changes in Cocoa-Applescript?

    I'm working on an application where I have one text field, and below it, a "Send" button. When the button is pressed, is sends whatever is typed in the field to all the user's Skype contacts. I have to prevent the user from sending a blank message to all contacts, so I have to change the button's setEnabled. I've been using an NSTimer to check every second, which works, but it lags my application hugely. Is there any handler that is run whenever text is added or deleted? Perhaps something like:
    on myTextFieldDidChange_(aNotification)

    A specific text field is not used in the handler call - the delegate method is called for all text fields.  In the case where you have several text fields, you can get the notification's object, for example:
    on controlTextDidChange_(aNotification) -- a text field changed, so check it out
      set thisTextField to aNotification's object() -- the current control being changed
      set theText to thisTextField's stringValue()
      log theText
      -- whatever
    end controlTextDidChange_
    Note that you need to connect the text field's delegate outlet to your AppDelegate (or whatever class you are using for the delegate).

  • HT201263 What can I do when my phone just stopped working?

    My iPhone decided mid-message to turn off (even though on 100%) and came back on to the Apple start-up screen.
    It continues to light up, then fade out, then light up again etc. I cannot get on my phone, so I cannot restore it. What can I do?

    Plug it in to power.  If it doesn't automatically come on within 15 minutes, try a Reset... press the home and sleep/lock buttons until you see the Apple logo, ignoring the slider. Takes about 5-15 secs of button holding and you won't lose any data or settings.
    If this doesn't work, you likely have a hardware issue.

  • Puzzler - Is there a way to detect when an external headphone or speaker is plugged in?

    I have a puzzler, and my initial question is simply, is there a way to see via Windows if/when an external headphone or microphone is plugged in, or is that all an electrical circuit independent of the OS?
    Background: (not necessarily the question I'm asking, but providing anyway):
    The background is this:  Dozens, Hundreds, I think Thousands of owners of Toshiba Satellite owners with Conexant sound devices (including myself) the world over have this problem where the sound stops working about 1 to 2 minutes into playing non-stop
    sounds/music/videos.  In spite of all the experts telling these poor people to run a system restore and wipe out the past years of files and everything on their computer, the problem prevails no matter what.  Some have even installed Linux, and the
    problem persists. To me, it seems that the problem doesn't occur if the only sounds are the occasional bing or bong from a system warning, it seems to fail after 1 to 2 minutes of continuous play (but this particular observation is mine only, nobody else has
    taken the time to point that out).
    A few have claimed success via blowing the jacks out with compressed air, but that's not repeatable universally.  Most people end up keeping external speakers plugged in permanently. In other words, it seems a lot like a hardware problem; However,
    {edit 3}, my addition of "Edit 2" below makes it seem less like hardware.
    One interesting thing:  Headphones/speakers work permanently, there's no problem.  More curiously, when the sound goes out, plugging any form of headphone/microphone jack into
    EITHER the headphone
    OR the microphone jack turns the sound back on too.  This includes male-to-male extension cable with nothing installed.  If nothing is on the other end, the sound will go out
    again shortly, but jiggling or removing the male to male turns it back on.
    EDIT 2: When the sound goes out, another way to get it back: From system tray, right click the speaker item and choose SOUNDS.  The virtual VU meter shows that audio is playing (in tandem with the song, etc.), and is still showing audio
    playing.  The tabs available are Playback, Recording, Sounds, and Communications.  When the sound does stop (assuming I was watching Playback), I click the Recording tab (just the tab header), and sound starts again.
    P.S. What's the difference between "High Definition Audio Controller" under System Devices, and "Conexant SmartAudio HD" under "Sound, Video, and Game Controllers", in Device Manager?  The "conexant smartaudio hd"
    points to the latest Conexant driver, the "High Definition Audio Controller" points to a default windows driver.  Just curious
    I've Binged this extensively:  Toshiba doesn't acknowledge the problem and nobody has fully solved the issue. I'm just curiously trying a few things myself, and I'm not sure if there's a way for the system to tell me an external mic/speaker has been
    plugged in.
    So to recap:  My main question, can I detect when the computer thinks a headphone or microphone is plugged in? (My theory, if I can prove that the computer THINKS something is plugged in, it's a start). 
    Only secondarily, if anyone's interested, feel free to suggest ideas (here's what dozens of other posts have disproven: System restore; windows reinstall; outdated sound driver; outdated video driver; remove and re-detect sound and device via device manager;
    malware; BIOS upgrade; Flash and/or the Flash/Firefox/Hardware Acceleration issue (problem happens with MP3, Flash, WMA, HTML5, Games, everything).
    Thanks in advance!
    EDIT: One person (theirs was under warranty, mine's not) ended up getting a new motherboard & speaker via Toshiba warranty, diagnosis ""machine intermittent no sound due to PCB faulty".  I'm still interested in troubleshooting,
    though.  Link:
    One lucky person, who got their motherboard replaced (they were under warranty, most of us aren't)

    Hi,
    If there are any headphone or speaker plugged in and detected, it will show in audio device manager console.
    Type mmsys.cpl in Run, it will open Sound console.
    Have you tried Hardware and Sound troubleshooter?
    Andy Altmann
    TechNet Community Support

  • Detecting when exception was thrown using custom class loader

    Hello all,
    I would like to implement the solution described here - http://stackoverflow.com/questions/75218/how-can-i-detect-when-an-exceptions-been-thrown-globally-in-java - that uses custom class loader in order to detect when an Exeption thrown somewhere in the JVM hosting my app, please note that exceptions might be thrown from 3rd party jars the app is using. So, thanks to help I got from another post, I've managed to code the custom class loader. My question is how can the class loader wrap the original exception, as the methods in ClassLoader deals with classes, not instances. So where should I set the original exception?
    Thanks!
    Edited by: user9355666 on Sep 28, 2010 10:48 PM

    user9355666 wrote:
    I think I'm missing something fundumental, forgive me for being slow...
    This is what I did so far. For the exception wrapper I made a simple class extens Exception that recieve Exception in its ctor and store it. I also subclassed ClassLoader and override its loadClass(). I've registered it as the system classloader. My thinking was to check in that point that if the requested class is instance of Exception and if yes, returning my wrapper class wrapping this exception. But, since loadClass() return class, how can I set in the wrapper the original exception?
    In addition, let's say 2 different places in the code throws NPE, to my understanding the classloader will load NPE only once, so how throwing the NPE in the second time can be detected?you are missing a key point. you should creating a custom implementation of the NPE class which hooks into your detection code in its constructor. from that point forward, anytime any NPE (which is your custom class) is constructed, you can detect it.

  • How to detect when 2 movie clips have been clicked?

    Hello:
    I'd like to know how can I detect when 2 movie clips have been clicked (irregardles of the order).
    What I have is this:
    In my main timeline I have 2 independent movie clips (mc_him and mc_her) each in it's own layer that, when clicked, play an internal animation without moving my main playhead anywhere. What I need to do is, once they are both clicked (as I said, it doesen't matter in what order), a button that sends me to another section of my movie has to appear. It really doesen't matter if the button shows by enabling it with alpha or by sending me to a specific frame where my button lies. What I need to detect is both clicks so that the button shows up.
    How can I achieve this?
    Thank you very much.

    btn1.onRelease=function(){
    // do whatever
    this.clicked = true;
    checkBothClickedF();
    btn2.onRelease=function(){
    // do whatever
    this.clicked = true;
    checkBothClickedF();
    function checkBothClickedF():Void{
    if(btn1.clicked&&btn2.clicked){
    // do something. both clicked
    // reset both clicked properties?

  • How to detect when new record is created?

    How can I detect when new record is created in PA30? For example, a newly create record for infotype 6 (address).
    Can I get the information in PCL4?

    Hi Irene,
    the field PAnnnn-AEDTM, nnnn is the infotype number, will give you the date when the record was last changed.
    Not sure if you can precisely get the date when the infotype was created. I dont feel the need to read cluster form the same.
    Regards,
    Pulkit

  • Detecting when you leave a frame

    How can i detect when a particular frame is left? i.e. The
    user is viewing fram x, they click one of several buttons or
    perform a particular action which causes the swf to move to a
    different frame how can i detect when it exits the original frame
    x?

    I'm not sure I quite understand your question ... if the user
    clicks a button that will move the playhead ... the playhead will
    leave the frame then, at that time, playhead gone ...?
    unless you have something else that runs before it moves the
    main timeline's playhead ... but in that case then, at the end of
    that action is when the palyhead will leave the frame, place a call
    there to the item that needs notification ...? You don't really
    need anything to detect it.

  • [Q] Can I insert the cue point when recording an FLV via FMS2???

    Hi... :)
    I think this can be a simple yes/no question...
    Does anybody know if I can insert the cue point when
    recording an FLV via FMS2 via AS???
    Thanks... :)
    CyanBlue

    According with fms2 documentation, you can define cue points
    in an FLV file when you first encode the file, or when you import a
    video clip in the Flash authoring tool by using the Video Import
    wizard.
    The FMS2 only handles with cue points.... using the
    NetStream.onCuePoint event handler.

  • Can I use the FLVTagScriptDataObject to call a function when the netstream byte parser gets to it?

    Hi,
    I am trying to trigger an event when the netstream begins to play a certain portion of a flv file that is being fed into the stream via the appendBytes method.  Is there anyway to feed the event, or a function, or any means of communicating that playback has reached this point into the byte parser?  I figured it would be possible using the FLVTagScriptDataObject but I cannot get any sort of callback when I pass the bytes generated from the tag into the appendBytes method.
    var dataTag:FLVTagScriptDataObject = new FLVTagScriptDataObject();
                dataTag.objects = [{"textData":"text"}];
                var bytes:ByteArray = new ByteArray();
                dataTag.write(bytes);
                appendBytes(bytes);
    I tried something like this trying to create a onCuePoint or onTextData callback but I didn't have any success.
    Any pointers?
    Thanks.

    I found a code example in the HTTPNetStream.as around line 1171:
    case HTTPStreamingState.STOP:
                            var playCompleteInfo:Object = new Object();
                            playCompleteInfo.code = NetStreamCodes.NETSTREAM_PLAY_COMPLETE;
                            playCompleteInfo.level = "status";
                            var playCompleteInfoSDOTag:FLVTagScriptDataObject = new FLVTagScriptDataObject();
                            playCompleteInfoSDOTag.objects = ["onPlayStatus", playCompleteInfo];
                            var tagBytes:ByteArray = new ByteArray();
                            playCompleteInfoSDOTag.write(tagBytes);
                               CONFIG::FLASH_10_1
                                appendBytesAction(NetStreamAppendBytesAction.END_SEQUENCE);
                                appendBytesAction(NetStreamAppendBytesAction.RESET_SEEK);
                            attemptAppendBytes(tagBytes);
                            setState(HTTPStreamingState.HALT);
                            break;

  • Detecting when an external swf has stopped playing

    I want to load a short swf to play whilst a flv loads in the
    background. The problem is detecting when the swf has finished
    playing. I would use the current and total frames but unable to
    identify what swf or mc to attach the methods to. I have tried
    Loader.content but this is not working.
    Any ideas please.

    It looks like you're using AS3 and a Loader object. If that's
    the case then you can access the loaded content like this:

  • Echo detected when using skype software - can anyone help?

    Hi, can anyone help?
    I've detected an echo when using skype software.  This occurs through the computer of the person I'm speaking to, so that when they speak, an echo comes back to them half a second later.  I'm wondering if the speakers and microphone on my laptop are located too close together and the microphone is retransmitting sound from the speakers?  My laptop is an HP mini 110. 
    Is there anything I can alter through my audio settings to stop this happening?
    Any advice is appreciated!

    I have a Mini 110 that performs beautifully with Skype (no echo, etc).  I have two other HP systems that don't do anywhere near as well.  I did tweak the graphics card on mine, which tremendously improved the video.  However...we are talking sound here, so I'll list the settings on my 110 for you to compare to yours:
    I'm sure you already know how to find the settings, but...in Skype, do Tools>Audio Settings
    Microphone:  set at about 45% with Automatically adjust microphone settings checked
    Speakers:  set at about 75% with Automatically adjust speaker settings checked
    Like I said, my Mini is a jewel.  I wish I could say the same for my G60-535DX.

Maybe you are looking for

  • Airport password not working

    I have been trying to connect a Brother MFC 7480W printer wirelessly. It doesn't like my password, and in all of the shenanigans I have been trying, my Airport Model A1034, 2005, password started acting differently. On my computer, I no longer need t

  • Modeling Persistence

    Hi, I have a question regarding use of Domain Model pattern. In our project we are creating customer profiles. We have modeled profile like this class Profile { Name name; List<Address> addressList; List <Phone> phoneList; We have CRUD operations for

  • Not able to invoke ATG  Rest services

    Hi, I'm new ATG Rest service, To just create a dummy rest service I followed the below steps. 1. added REST module in MANIFEST.MF file ATG-Required: DAS DPS DSS DCS B2CCommerce DAS REST 2. created restSecurityCnfiguration.xml under atg/rest/seurity a

  • Star Schema doubts?

    Exepert's, I have cube ZSAL_ANA .I am having Two dimensions 1.Sales and 2.Customer. Sales Region contains Sales Region  and Sales Location.Customer Dimension contains Customer Type and Customer location.Ok Now Correct me if I am wrong? In Fact table

  • New user elements 11

    I have just started using PE 11 and have found there is only a basic theme in photo collage, are there others available to download? my product is activated etc. it isn't a trial version.