Jump to content
Search Community

Video Content Not Seen Until Loaded Completely

gokceng test
Moderator Tag

Recommended Posts

Hi,

I'm using Flash Builder. I load videos from an xml and after that i add video content to application. Code is like that:

 

Application.mxml:

 

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
  xmlns:s="library://ns.adobe.com/flex/spark"
  xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" creationComplete="application1_creationCompleteHandler(event)">
<fx:Script>
 <![CDATA[
  import com.greensock.TweenLite;
  import com.greensock.events.LoaderEvent;
  import com.greensock.layout.AlignMode;
  import com.greensock.loading.LoaderMax;
  import com.greensock.loading.VideoLoader;
  import com.greensock.loading.XMLLoader;
  import com.greensock.loading.display.ContentDisplay;
  import com.greensock.loading.display.FlexContentDisplay;

  import mx.collections.ArrayCollection;
  import mx.events.FlexEvent;

  import spark.components.Button;
  import spark.components.HGroup;
  import spark.components.VideoPlayer;
  protected var videosPath:String = "assets/videos.xml";
  [bindable]
  protected var videos:ArrayCollection = new ArrayCollection();
  protected var video1:FlexContentDisplay;


  protected function application1_creationCompleteHandler(event:FlexEvent):void
  {
   // TODO Auto-generated method stub
   LoaderMax.activate([xmlLoader, VideoLoader]);
   LoaderMax.contentDisplayClass = FlexContentDisplay;
   loadVideos2();
  }

  protected function loadVideos2():void
  {
   var loader:XMLLoader = new XMLLoader(videosPath, {name:"xmlDoc", onComplete:completeHandler});
   loader.load();
  }

  private function completeHandler(event:LoaderEvent):void
  {
   var queue:XMLLoader = LoaderMax.getLoader("xmlDoc");
   videos = new ArrayCollection(queue.getChildren());
   var vl:VideoLoader = videos.getItemAt(0) as VideoLoader;
   video1 = vl.content;
   video1.horizontalCenter = 0;
   video1.verticalCenter = 0;

   addElement(video1);
  }
 ]]>
</fx:Script>
<fx:Declarations>
 <!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
</s:Application>

 

 

videos.xml:

 

<?xml version="1.0" encoding="utf-8" ?>
<data>
<item>
 <VideoLoader url="assets/vid/magicfall1.flv" name="video4"
  autoPlay="false" load="true" width="400" height="300" crop="false"
  scaleMode="proportionalOutside" />
</item>
<!-- Some other videos, not posted for simplicity, but their properties exactly same except names -->
</data>

 

 

If i run the program from Flash Builder, I've no problem, it is visible immediately. But if I Export Release Build and put that build to server, when i go to that web page i wait for 3-4 minutes until video content seen on the browser. The size of the video is 24.2 MB. Is that normal? By the way I'm using Version: 1.9.

Link to comment
Share on other sites

Hi,

 

I believe your problem has to with the fact an XMLLoader's onComplete event doesn't get fired until the XML has done loading AND all the loader assets in the xml that have load = true have loaded. So your code is waiting for the video to completely load before any of the actions in your completeHandler method take place.

 

If you want the FlexContentDisplay object to be visible as soon as it is created, look at the onInit event handler shortcut:

 

onInit : Function - A handler function for LoaderEvent.INIT events which are dispatched when the loader finishes loading the XML file, parses its contents, and creates any dynamic XML-driven loaders. If any dynamic loaders are created and have a load="true" attribute, they will begin loading at this point and the XMLLoader's COMPLETE will not be dispatched until the loaders have completed as well. Make sure your onInit function accepts a single parameter of type Event (flash.events.Event).

 

http://www.greensock.com/as/docs/tween/com/greensock/loading/XMLLoader.html

 

let us know if that helps.

Link to comment
Share on other sites

Another option is to set the VideoLoader's "bufferMode" attribute to true in the XML which would make the VideoLoader report its progress based solely on the buffering progress rather than the overall file loading progress.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...