Quantcast
Channel: Adobe Community : All Content - All Communities
Viewing all articles
Browse latest Browse all 290743

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

$
0
0

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);

                                        }

                              }

                    }

          }

}


Viewing all articles
Browse latest Browse all 290743

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>