Skip to main content
Inspiring
Nov 12, 2012 2:13 AM UTC
Question

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

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 is closed to new replies. Start a new post to keep the conversation going.

11 replies

Participating Frequently
Mar 1, 2013 9:38 PM UTC

Bug allready reportet.

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

Translate
Legend
Apr 12, 2013 2:20 PM UTC

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

Translate
Inspiring
Nov 12, 2012 9:00 PM UTC

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.

Translate
Inspiring
Nov 20, 2012 4:25 PM UTC

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

Translate
Colin Holgate
Inspiring
Nov 20, 2012 4:26 PM UTC

Which build number of 3.5?

Translate
Inspiring
Nov 12, 2012 2:57 AM UTC

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

Translate
Participant
Nov 12, 2012 6:10 PM UTC

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.

Translate