|
-
Help with display elapsed time for flv
Hey guys,
I'm new to using video with flash( so bare with);
I'm using version flash 8 pro;
I've been using the series goto and learn (which is great!);
One thing I would like to add is elapsed time for the flv, here is the flv file(ignore the video it's just a test);
http://www.chrissandersdesign.com/night1.flv
Right now I have two dynamic text boxes setup to display the time
the first is called - time_txt
the second is called - length_txt
I'm just not sure how of the right script to use to display how far into the video the user is and what the total length of the video is. I would like to contuine building on the goto and learn series.
Here is the code I'm using from that series:
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
theVideo.attachVideo(ns);
ns.play("http://www.chrissandersdesign.com/night1.flv");
rewindButton.onRelease = function(){
ns.seek(0);
}
playButton.onRelease = function(){//plays and pauses the movie
ns.pause();
}
var videoInterval = setInterval(videoStatus, 100);
var amountLoaded:Number;
var duration:Number;
ns["onMetaData"] = function(obj) {
duration = obj.duration;
}
function videoStatus() {
amountLoaded = ns.bytesLoaded / ns.bytesTotal;
loader.loadbar._width = amountLoaded * 274;
loader.scrub._x = ns.time / duration * 274;
}
var scrubInterval;
loader.scrub.onPress = function() {
clearInterval(videoInterval);
scrubInterval = setInterval(scrubit,10);
this.startDrag(false,0,this._y,274,this._y);
}
loader.scrub.onRelease = loader.scrub.onReleaseOutside = function() {
clearInterval(scrubInterval);
videoInterval = setInterval(videoStatus,100);
this.stopDrag();
}
function scrubit() {
ns.seek(Math.floor((loader.scrub._x/274)*duration));
}
Thank You
Chris
Last edited by sledneck; 06-15-2007 at 01:32 PM.
Reason: should ask for help
-
Maybe I put to much on here. What I really need help with is showing the total length of the flv. So people can see how long the video is.
-
I found a solution for myself: Here's what ended up working for me, it's a combination of different stuff. If you look in the comments you see that I added where it's from and how it was used Hope this helps someone else
//Code from goto and learn tutorials from Lee Brimelow http://www.gotoandlearn.com/download.php
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
theVideo.attachVideo(ns);
ns.play("http://www.chrissandersdesign.com/video/P1010001.flv");
rewindButton.onRelease = function(){
ns.seek(0);
}
//plays and pauses the movie
playButton.onRelease = function(){
ns.pause();
}
var videoInterval = setInterval(videoStatus, 100);
var amountLoaded:Number;
var duration:Number;
// set the MetaData also gives you the total FLV time
ns.onMetaData = function(infoObject:Object) {
duration = infoObject.duration;
FLVduration = infoObject["duration"];
var minutes2:Number = Math.floor(FLVduration/60);
var seconds2 = Math.floor(FLVduration%60);
if (seconds2<10) {
seconds2 = "0"+seconds2;
}
//Dynamic textbox used called totalTimeText to display the FLV
totalTimeText.text = +minutes2+":"+seconds2;
}
function videoStatus() {
amountLoaded = ns.bytesLoaded / ns.bytesTotal;
loader.loadbar._width = amountLoaded * 274;
loader.scrub._x = ns.time / duration * 274;
}
var scrubInterval;
loader.scrub.onPress = function() {
clearInterval(videoInterval);
scrubInterval = setInterval(scrubit,10);
this.startDrag(false,0,this._y,274,this._y);
}
loader.scrub.onRelease = loader.scrub.onReleaseOutside = function() {
clearInterval(scrubInterval);
videoInterval = setInterval(videoStatus,100);
this.stopDrag();
}
function scrubit() {
ns.seek(Math.floor((loader.scrub._x/274)*duration));
}
// Used with Flash Timecode Class(you can download the Class file here as well just below the code sample)
//I got code below from Lee Brimelow http://theflashblog.com/?p=15
var tc:Timecode = new Timecode(ns);
timecode_txt.autoSize = true;
timecode_txt.selectable = false;
this.onEnterFrame = function() {
//Dynamic text box called timecode_txt this gives you the elapsed time
timecode_txt.text = tc.getTimecode();
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|