Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7661527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:36:36+00:00 2026-05-31T13:36:36+00:00

I’m trying to get StageVideo to work in my app but I’m having problems.

  • 0

I’m trying to get StageVideo to work in my app but I’m having problems. I need to play a series of videos one after the other, the first video always plays fine but the others will only play the audio, and the StageVideo will show the last frame from the first video.

It’s as if the StageVideo has frozen and is playing the video but I can’t see it (only hear it). I’ve posted my complete code here:

I’m testing on iPad2 with Adobe Air 3.2 beta, but have also tested with 3.1 and same results.

Here is my video class:

package  {

    import flash.display.MovieClip;
    import flash.text.TextField;
    import flash.text.TextFormat;
    import flash.events.Event;
    import flash.media.StageVideo;
    import flash.events.StageVideoEvent;
    import flash.events.StageVideoAvailabilityEvent;
    import flash.media.StageVideoAvailability;
    import flash.net.NetStream;
    import flash.net.NetConnection;
    import flash.geom.Rectangle;
    import flash.events.NetStatusEvent;

    public class SVideo2 extends MovieClip {

        public static const VIDEO_FINISHED:String = 'videoFinished';

        private var debugPanel:TextField;
        private var addedToStage:Boolean = false;

        private var videoFile:String;

        private var hwaEnabled:Boolean = false;

        private var video:StageVideo;
        private var ns:NetStream;
        private var nc:NetConnection;

        public function SVideo2() {
            addDebugPanel();

            addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
        }

        private function onAddedToStage(e:Event) :void{
            output('ADDED TO STAGE');
            addedToStage = true;
            stage.addEventListener(StageVideoAvailabilityEvent.STAGE_VIDEO_AVAILABILITY, onAvail);
            removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
        }

        public function playVideo(videoFile:String) :void{
            output('playVideo: '+videoFile);
            if(addedToStage){
                this.videoFile = videoFile;
                if(hwaEnabled){
                    startPlaying();
                }
                else{
                    output('HWA NOT AVAILABLE');
                }
            }
            else{
                output('NOT ON STAGE');
            }
        }

        private function onAvail(e:StageVideoAvailabilityEvent) :void{
            output(e.availability);
            if(e.availability == StageVideoAvailability.AVAILABLE){
                output('VIDEO AVAILABLE');
                hwaEnabled = true;
            }
        }

        private function startPlaying() :void{
            output('STARTING TO PLAY');
            video = stage.stageVideos[0];
            video.addEventListener(StageVideoEvent.RENDER_STATE, onRender);

            nc = new NetConnection();
            nc.connect(null);
            ns = new NetStream(nc);

            ns.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);

            ns.client = this;

            video.attachNetStream(ns);
            ns.play(videoFile);
        }

        private function onRender(e:StageVideoEvent) :void{
            output('onRender');
            video.viewPort = new Rectangle(192, 50, 640, 480);
        }

        private function onNetStatus(e:NetStatusEvent) :void{
            output(e.info.code);
            if(e.info.code == 'Netstream.Play.Stop'){
                output('VIDEO STOPPED');
                dispatchEvent(new Event(VIDEO_FINISHED));
            }
        }

        private function addDebugPanel() :void{
            var tFormat:TextFormat = new TextFormat('Arial', 14, 0x000000, true);
            var tField:TextField = new TextField();

            tField.setTextFormat(tFormat);
            tField.multiline = true;
            tField.border = true;
            tField.borderColor = 0x000000;
            tField.background = true;
            tField.backgroundColor = 0xFFFFFF;

            tField.x = 0;
            tField.y = 568;
            tField.width = 1024;
            tField.height = 200;

            this.debugPanel = tField;
            addChild(debugPanel);
        }

        private function output(what:String) :void{
            debugPanel.appendText("\n"+what);
        }

        public function onXMPData(info:Object) :void{}
        public function onMetaData(info:Object) :void{}
        public function onCuePoint(info:Object) :void{}
        public function onPlayStatus(info:Object) :void{}

    }

}

And here’s the code I’m using in frame:

import flash.display.Sprite;
import flash.events.MouseEvent;

var vid:SVideo2 = new SVideo2();
addChild(vid);

var btn:Sprite = new Sprite();
btn.graphics.beginFill(0x333333);
btn.graphics.drawRect(0, 0, 100, 40);
btn.x = 462;
btn.y = 518;
btn.width = 100;
btn.height = 40;

addChild(btn);

btn.addEventListener(MouseEvent.CLICK, onClick);

function onClick(e:MouseEvent) :void{
    var rand:String = String(Math.floor(Math.random() * 37));
    vid.playVideo('mp4/result_'+rand+'.mp4');
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T13:36:37+00:00Added an answer on May 31, 2026 at 1:36 pm

    After fighting with this bug, and completely re-writing the code, I found that the reason was because I did not clear the netStream reference attached to the StageVideo, i.e; StageVideo.attachNetStream(null);

    This needs to be cleared before/after each new video is played.

    Before calling attachNetStream() a second time, call the currently
    attached NetStream object’s close() method. Calling close() releases
    all the resources, including hardware decoders, involved with playing
    the video. Then you can call attachNetStream() with either another
    NetStream object or null.

    • http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/StageVideo.html#attachNetStream%28%29
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
We're building an app, our first using Rails 3, and we're having to build
I need to clean up various Word 'smart' characters in user input, including but
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.