Re: [Flashcoders] changing video playback speed with timer listeners

2009-04-06 Thread Paul Andrews
A quick look on google looks promising: 
http://www.flashcomguru.com/index.cfm/2005/8/2/slowmo


Paul
- Original Message - 
From: "Carl Welch" 

To: "Flash Coders List" 
Sent: Monday, April 06, 2009 10:47 PM
Subject: [Flashcoders] changing video playback speed with timer listeners



Hi,

I need to build a function that changes the playback speed of a FLV. I  am 
trying to make it so every time you hit the "+" key the FLV plays a 
little faster, and when you hit the "-" key, it plays a little slower.


From what I've read, there is nothing built in. Someone suggested 
building a timer script to seek a frame forward or back. So, I've done 
that, but when I hit the keys its just creating a new timer and not 
killing the old on, leaving me with a bunch of timer firing off at 
varying times. How can I "KILL" the timer so I can create a new one  with 
a new timerspeed?


any clues? thank you! My sorry looking code is below:



var myTimerActive:int = 0;
var videoSpeed:int = 5000;
var videoSpeedVAR:int = 10;
var timerTimes:int = 0;

// hitting + or - will call videoPlaybackTimer(fastslow)

function videoPlaybackTimer(fastslow) {

if(fastslow == "faster"){
videoSpeed = videoSpeed+videoSpeedVAR;
}else{
videoSpeed = videoSpeed-videoSpeedVAR;
}
videoSEEK.text = timerTimes+" / videoSpeed: "+videoSpeed;

var myTimer:Timer = new Timer(videoSpeed);
myTimer.addEventListener(TimerEvent.TIMER, timerHandler);

myTimerActive = 1;
myTimer.start();
timerTimes++
}

function timerHandler(event:TimerEvent):void {
stream.seek(stream.time+.1);
stream.pause();
}



--
Carl Welch
http://www.carlwelch.com
http://blog.jointjam.com
carlwelchdes...@gmail.com
805.403.4819





___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders 


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] changing video playback speed with timer listeners

2009-04-06 Thread Glen Pike

Hi,

   If you remove the timer listener, stop the timer and make your timer 
a variable outside your function, you can recreate a new one...  The key 
is removing the event listener before you "kill" the timer instance - 
it's good practice, especially for AS3 :)


   See the code below - it was not too bad!
  
   I am not sure how easy it is to skip through the FLV - it looks 
possible, but might end up looking funny - the problem being is that you 
are trying to play an FLV, but also asking it to seek - you will need to 
make sure that your "pause()" does not stop it from playing too.  
Because of the encoding of FLV's using keyframes in inbetween frames, 
you might end up with funny looking results, but it could work - don't know.


   HTH

   Glen
  
//Put your timer variable outside the function.  If you are coding on a 
frame in Flash, make sure you have a "stop()" at the end of the code.

var myTimer:Timer = null;

function videoPlaybackTimer(fastslow) {

   if(fastslow == "faster"){
   videoSpeed = videoSpeed+videoSpeedVAR;
   }else{
   videoSpeed = videoSpeed-videoSpeedVAR;
   }
   videoSEEK.text = timerTimes+" / videoSpeed: "+videoSpeed;
  
   //Add a check to see if you have a timer already:

   if(null != myTimer) {
  myTimer.removeEventListener(TimerEvent.TIMER, timerHandler);
  myTimer = null;
   }
   //Then you can safely create a new Timer and not worry about the old 
one...
   myTimer = new Timer(videoSpeed);
  
   myTimer.addEventListener(TimerEvent.TIMER, timerHandler);


   myTimerActive = 1;
   myTimer.start();
   timerTimes++
}

  


--

Glen Pike
01326 218440
www.glenpike.co.uk 

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


[Flashcoders] changing video playback speed with timer listeners

2009-04-06 Thread Carl Welch

Hi,

I need to build a function that changes the playback speed of a FLV. I  
am trying to make it so every time you hit the "+" key the FLV plays a  
little faster, and when you hit the "-" key, it plays a little slower.


From what I've read, there is nothing built in. Someone suggested  
building a timer script to seek a frame forward or back. So, I've done  
that, but when I hit the keys its just creating a new timer and not  
killing the old on, leaving me with a bunch of timer firing off at  
varying times. How can I "KILL" the timer so I can create a new one  
with a new timerspeed?


any clues? thank you! My sorry looking code is below:



var myTimerActive:int = 0;
var videoSpeed:int = 5000;
var videoSpeedVAR:int = 10;
var timerTimes:int = 0;

// hitting + or - will call videoPlaybackTimer(fastslow)

function videoPlaybackTimer(fastslow) {

if(fastslow == "faster"){
videoSpeed = videoSpeed+videoSpeedVAR;
}else{
videoSpeed = videoSpeed-videoSpeedVAR;
}
videoSEEK.text = timerTimes+" / videoSpeed: "+videoSpeed;

var myTimer:Timer = new Timer(videoSpeed);  

myTimer.addEventListener(TimerEvent.TIMER, timerHandler);

myTimerActive = 1;
myTimer.start();
timerTimes++
}

function timerHandler(event:TimerEvent):void {
stream.seek(stream.time+.1);
stream.pause();
}



--
Carl Welch
http://www.carlwelch.com
http://blog.jointjam.com
carlwelchdes...@gmail.com
805.403.4819





___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders