flv and contents preloader

  • deluxmilkman
  • Born
  • Born
  • deluxmilkman
  • Posts: 4

Post 3+ Months Ago

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
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

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).
  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1828
  • Loc: In the Great White North

Post 3+ Months Ago

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
  • deluxmilkman
  • Posts: 4

Post 3+ Months Ago

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 10 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
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.