Search code examples
actionscript-3flashvideoair

AS3 NetStream lags on first frame


I'm developing an application in Adobe Air to display videos for a museum exhibit at a resolution of 2560x1440. The application works without a hitch on my machine, but when I run it on another (less powerful) computer, it does not function as intended. I've texted the application on two machines besides my own.

The problem is when one of the videos is called up, the video is called up and displays the first frame of the video and lags there for a good number of seconds (5-10), however I can still hear audio. After about 8-10 seconds, the video plays back as if it had been playing before and stutters briefly (1-2 seconds) before resuming playback normally. This is consistent behavior every time a video is launched as long as it's a fairly large video (> 50 MB as far as I can tell).

This does not happen on my development machine, which has a GTX 980 graphics card in it, but besides that and the motherboard, I can't think of any differences between the specs of the multiple machines.

The video throws an event indicating the buffer is full immediately as a video is launched, so buffering doesn't seem to be the issue.

Edit: Code (Pastebin)

Edit 2: Figured out it was the first frame, not a black screen


Solution

  • Still not entirely sure where the root of the problem lies, but what fixed it was adding this code right after calling the video. What it does is pause the playback and add a timer for one second, then seek 0.5 seconds into the video. I haven't run tests with this yet beyond getting past that first frame lag, but it works.

    ns.pause();
    var hesitate:Timer = new Timer(1000, 1);
    hesitate.addEventListener(TimerEvent.TIMER_COMPLETE, function(e:TimerEvent)
    {
        ns.seek(0.5);
        ns.resume();
    });
    hesitate.start();