Thursday, March 12, 2009

How to Play Video in Flash in Slow Motion using NetStream

Not a long time ago I found an interesting FLV Player from the following company www.hitasoft.com and they offer a cool feature. You can playback video
using slow motion speed very handy when you playpback some sport.
So I asked myself how this could be handled in Flash.
This can be done using a new instance of Netstream or accessing Nestream
object directly from FLVPlayback.

var myConnection;
var myVideo;
my_video._alpha = 100;
playVideo = function () {
myConnection = new NetConnection();
myConnection.connect(null);
myVideo = new NetStream(myConnection);
myVideo.setBufferTime(5);
my_video.attachVideo(myVideo);
this.createEmptyMovieClip("movFLVAudio", this.getNextHighestDepth());
movFLVAudio.attachAudio(myVideo);
var snd1:Sound = new Sound(movFLVAudio);
snd1.setVolume(50);
myVideo.onMetaData = function(obj) {
_global.bufTime = obj.duration;
totalPlayTime = obj.duration;
trace(_global.bufTime);
};
myVideo.play("YOURFLV.flv");
myVideo.pause();
};
playVideo();



_global.seekSpeed = 1000;
// (number of milliseconds to pass before going advancing flv frame)
i = 0;
// starting second
function slowMotionTimer() {
i += 1;
// increment second
trace(i);
myVideo.seek(i);
// seek to i
}
sloMo = setInterval(slowMotionTimer, _global.seekSpeed);
// set an interval to call the above function.

No comments: