Skip to main content
Inspiring
November 12, 2012
Question

stageVideo on android shows a black frame on the start and end of video playback

  • November 12, 2012
  • 11 replies
  • 3342 views

When my screen starts up it goes completely black for a moment and the interface becomes unreponsive for about a second when my stagevideo player class is added to the stage. My videos are encoded using Adobe Media Encoder with the 480p android settings (vbr 2 pass). I tried cbr and that had exactly the same effect. This problem happens on both air 3.5 and air 3.4. I figure this has to be something caused by my own code because I don't see many discussions about this issue.

package com.literacysoft

{

          import flash.display.Sprite;

          import flash.events.Event;

          import flash.events.NetStatusEvent;

          import flash.events.StageVideoAvailabilityEvent;

          import flash.events.StageVideoEvent;

          import flash.geom.Rectangle;

          import flash.media.StageVideo;

          import flash.media.StageVideoAvailability;

          import flash.media.Video;

          import flash.net.NetConnection;

          import flash.net.NetStream;

 

          public class SimpleStageVideo extends Sprite

          {

                    private var stageVideoAvail:Boolean;

                    private var sv:StageVideo;

                    private var videoUrl;

                    private var vidWidth;

                    private var vidHeight;

                    public var theStage;

                    private var vid;

                    private var myX;

                    private var myY;

                    public var ns;

                    public function SimpleStageVideo(w, h, dastage, x, y)

                    {

                              myX = x;

                              myY = y;

                              vidWidth = w;

                              vidHeight = h;

                              theStage = dastage;

                              addEventListener(Event.ADDED_TO_STAGE, init);

                    }

 

 

 

 

                    private function init(e:Event):void{

                              theStage.addEventListener(StageVideoAvailabilityEvent.STAGE_VIDEO_AVAILABILITY, onAvail);

                    }

 

                    private function onAvail(e:StageVideoAvailabilityEvent):void

                    {

                              stageVideoAvail = (e.availability == StageVideoAvailability.AVAILABLE);

                              initVideo();

                    }

 

                    private function initVideo():void

                    {

                              var nc:NetConnection = new NetConnection();

                              nc.connect(null);

                              ns = new NetStream(nc);

                              ns.client = this;

                              ns.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);

                              if(stageVideoAvail)

                              {

                                        sv = theStage.stageVideos[0];

                                        sv.addEventListener(StageVideoEvent.RENDER_STATE, onRender);

                                        sv.attachNetStream(ns);

                                        trace('available');

                              }

                              else

                              {

                                        vid = new Video(vidWidth, vidHeight);

                                        theStage.addChild(vid);

                                        vid.attachNetStream(ns);

                                        vid.x = myX;

                                        vid.y = myY;

                                        vid.smoothing = true;

                                        theStage.setChildIndex(vid, 0);

                                        trace('not');

                              }

 

 

                    }

 

                    private function netStatusHandler(event:NetStatusEvent):void {

 

                              trace("event.info.code "+event.info.code);

 

                              switch (event.info.code) {

                                        case "NetConnection.Connect.Success":

                                                  trace("NetConnection.Connect.Success");

                                                  break;

                                        case "NetStream.Play.Stop":

                                                  if (!stageVideoAvail){

                                                            if (vid.parent != null){

                                                                      theStage.removeChild(vid);

                                                            }

 

                                                  } else{

                                                            ns.close();

                                                  }

 

 

                              }

                    }

 

 

                    public function playMyVideo(url):void{

                              ns.play(url);

                              if (!stageVideoAvail){

                                        theStage.addChild(vid);

                                        theStage.setChildIndex(vid, 0);

                              }

 

                    }

 

                    private function onRender(e:StageVideoEvent):void

                    {

                              trace("rendering video",sv.viewPort);

                              sv.viewPort = new Rectangle(myX, myY, vidWidth, vidHeight);

 

                    }

 

                    public function onMetaData(e:Object):void

                    {

 

                    }

 

                    public function onXMPData(e:Object):void

                    {

 

                    }

                    public function onPlayStatus(whatever):void{

 

                    }

                    public function dispose():void{

                              ns.close();

                              ns.dispose();

                              if (!stageVideoAvail){

                                        if (vid.parent != null){

                                                  theStage.removeChild(vid);

                                        }

                              }

                    }

          }

}

This topic has been closed for replies.

11 replies

Participating Frequently
March 1, 2013

Bug allready reportet.

For everyone who encountered this, please votehttps://bugbase.adobe.com/index.cfm?event=bug&id=3488916

Legend
April 12, 2013

Yep, I've been encountering this bug a lot too.

Inspiring
November 12, 2012

Also I get a similar behavior in iOS with AIR 3.5. I was not having this problem with my iOS version in version 3.5

Both version 3.4 and 3.5 display the black frames before and after playback on android.

Inspiring
November 20, 2012

The latest Air 3.5 beta seems to have fixed all the iOS and Android issues. Thanks Adobe!

Colin Holgate
Inspiring
November 20, 2012

Which build number of 3.5?

Inspiring
November 12, 2012

Oh I should have also mentioned that I am testing this on a Nexus 7 tablet with the lastes operating system as of 11/11/2012

Forcing my class to use regular video instead of stageVideo eliminates the artifacts I am getting

Participant
November 12, 2012

I'm facing same isssue but i m using  Flex  SDK and adobe air 3.5.It's was working perfect  in Adoabe AIR 3.4AS Well i m using in-built video object.