flv and contents preloader

  • deluxmilkman
  • Born
  • Born
  • No Avatar
  • Joined: Oct 28, 2007
  • Posts: 4
  • Status: Offline

Post October 28th, 2007, 7:33 am

I'm trying to play flv on frame 1 after both flv and contents on frame 2 are loaded.

how can I stop flv from playing before the contents are loaded?



AS on frame 1

Code: [ Select ]

stop();

var loadSize:Number = getBytesTotal();



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

myVideo.attachVideo(ns);


ns.play("flv3a.flv");

/********* flv preloader********/

this.createTextField("loaded_txt", this.getNextHighestDepth(), 0, 0, 160, 22);
var loaded_interval:Number = setInterval(checkBytesLoaded, 500, ns);
function checkBytesLoaded(my_ns:NetStream) {
  var pctLoaded:Number = Math.round(my_ns.bytesLoaded / my_ns.bytesTotal * 100);
  loaded_txt.text = Math.round(my_ns.bytesLoaded / 1000) + " of " + Math.round(my_ns.bytesTotal / 1000) + " KB loaded (" + pctLoaded + "%)";
 
 
/********* contents preloader ********/
 
  loaded = getBytesLoaded();

    var percentField:Number = Math.round(loaded / loadSize * 100);
    
    ////
    
    frameNum = Math.min(pctLoaded, percentField)
    
    
    
     loader.gotoAndStop(frameNum);
    
  if ( Math.min(pctLoaded, percentField) >= 100) {
    clearInterval(loaded_interval);
}
}


/********* cue point ********/



var ourListener:Object = new Object();
ourListener.cuePoint = function(eventObject:Object):Void{
    if(eventObject.info.name == "first"){
        play();

        }
}

myVideo.addEventListener("cuePoint",ourListener);
  1. stop();
  2. var loadSize:Number = getBytesTotal();
  3. var nc:NetConnection = new NetConnection;
  4. nc.connect(null);
  5. var ns:NetStream = new NetStream(nc);
  6. myVideo.attachVideo(ns);
  7. ns.play("flv3a.flv");
  8. /********* flv preloader********/
  9. this.createTextField("loaded_txt", this.getNextHighestDepth(), 0, 0, 160, 22);
  10. var loaded_interval:Number = setInterval(checkBytesLoaded, 500, ns);
  11. function checkBytesLoaded(my_ns:NetStream) {
  12.   var pctLoaded:Number = Math.round(my_ns.bytesLoaded / my_ns.bytesTotal * 100);
  13.   loaded_txt.text = Math.round(my_ns.bytesLoaded / 1000) + " of " + Math.round(my_ns.bytesTotal / 1000) + " KB loaded (" + pctLoaded + "%)";
  14.  
  15.  
  16. /********* contents preloader ********/
  17.  
  18.   loaded = getBytesLoaded();
  19.     var percentField:Number = Math.round(loaded / loadSize * 100);
  20.     
  21.     ////
  22.     
  23.     frameNum = Math.min(pctLoaded, percentField)
  24.     
  25.     
  26.     
  27.      loader.gotoAndStop(frameNum);
  28.     
  29.   if ( Math.min(pctLoaded, percentField) >= 100) {
  30.     clearInterval(loaded_interval);
  31. }
  32. }
  33. /********* cue point ********/
  34. var ourListener:Object = new Object();
  35. ourListener.cuePoint = function(eventObject:Object):Void{
  36.     if(eventObject.info.name == "first"){
  37.         play();
  38.         }
  39. }
  40. myVideo.addEventListener("cuePoint",ourListener);



Thank you
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post October 28th, 2007, 7:33 am

  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23403
  • Loc: Woodbridge VA
  • Status: Offline

Post October 29th, 2007, 7:44 am

Well, you can't get around putting the FLV on frame one because that's where it has to be. There's also no need to preload the FLV since it streams. My suggestion would be create a separate swf for the flv, call it for example flv3a.swf

Run your preloader on the content, then when you display the frame two content, load flv3a.swf on frame two on a new layer. That should serve the purpose of having them both display at the same time.

You may have to mess around with cuepoints on the FLV to stop it when you want it stopped (assuming that's the case).
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Joined: Jul 11, 2005
  • Posts: 1828
  • Loc: In the Great White North
  • Status: Offline

Post October 29th, 2007, 10:38 am

Another option is to set a few parameters of your flv player.

Code: [ Select ]
myVideo.autoPlay = false;
myVideo.contentPath = "pathtoyourflv.flv";
  1. myVideo.autoPlay = false;
  2. myVideo.contentPath = "pathtoyourflv.flv";


Now your player knows what to play but it won't just start playing automatically. Then when you know your other content is complete play the video.
Code: [ Select ]
  if ( Math.min(pctLoaded, percentField) >= 100) {

    clearInterval(loaded_interval);
    myVideo.play();

}
  1.   if ( Math.min(pctLoaded, percentField) >= 100) {
  2.     clearInterval(loaded_interval);
  3.     myVideo.play();
  4. }
  • deluxmilkman
  • Born
  • Born
  • No Avatar
  • Joined: Oct 28, 2007
  • Posts: 4
  • Status: Offline

Post October 30th, 2007, 8:02 am

you totally got what i wanted to do.
thanks alot.

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 41 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.