Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 08-28-2007, 01:16 AM   #1
jevans
Masked Member
 
jevans's Avatar
 
Join Date: Dec 2001
Location: Canada
Posts: 257
Default Display FLV time.

I am following Lee Brimlows FLV player tutorial with success but would like to add the time played and or remaining time to the player. I really haven't got a clue how to go about it.

Here is my actionscript. I assume making a textfield will be required if anyone can lend a little support with this I'd appreciate it.

Code:
stop();
var nc:NetConnection = new NetConnection();
nc.connect(null);

var ns:NetStream = new NetStream(nc);

ns.setBufferTime(30);
ns.onStatus = function(info){
	if(info.code == "NetStream.Buffer.Full"){ 
	bufferClip._visible = false;
}
    if(info.code == "NetStream.Buffer.Empty"){ 
	bufferClip._visible = true;
}
    if(info.code == "NetStream.Play.Stop"){ 
             bufferClip._visible = 0;
}
}

theVideo.attachVideo(ns);

ns.play("my_movie.flv");

rewindButton.onRelease = function() {
	ns.seek(0);
}

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 * 210;
	loader.scrub._x = ns.time / duration * 210;
}
	
var scrubInterval;

loader.scrub.onPress = function(){
	clearInterval(videoInterval);
	scrubInterval = setInterval(scrubit,10);
	this.startDrag(false,0,this._y,210,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/210)*duration));
}
Thanks for your time, Jason.
jevans is offline   Reply With Quote
Old 08-28-2007, 02:53 AM   #2
atomic
Banned by AS.org Staff
 
Join Date: Jan 2007
Location: Montréal, Québec
Posts: 14,073
Default

Add the following...

...
theVideo.attachVideo(ns);

ns.play("my_movie.flv");

var time_interval:Number = setInterval(checkTime, 500, ns);
function checkTime(myVideo_ns:NetStream) {
var ns_seconds:Number = myVideo_ns.time;
var minutes:Number = Math.floor(ns_seconds/60);
var seconds = Math.floor(ns_seconds%60)
if (seconds<10) {
seconds = ("0"+seconds);
}
time_txt.text = minutes+":"+seconds;
};

...

Of course you'll need to set up a time_txt textfield to display it...

Last edited by atomic; 08-28-2007 at 02:57 AM.
atomic is offline   Reply With Quote
Old 08-28-2007, 03:59 PM   #3
jevans
Masked Member
 
jevans's Avatar
 
Join Date: Dec 2001
Location: Canada
Posts: 257
Default Thanks

Atomic,

It is people like you that make the world a better place .

Seriously thanks for that, you have saved me allot of time messing around. Very much appreciated.

Regards, Jason.
jevans is offline   Reply With Quote
Old 08-28-2007, 07:18 PM   #4
atomic
Banned by AS.org Staff
 
Join Date: Jan 2007
Location: Montréal, Québec
Posts: 14,073
Default

Grrrrrrrrrreat!

If you want to display the total time also, just say so, I'll provide code for that as well...
atomic is offline   Reply With Quote
Old 08-28-2007, 09:04 PM   #5
jevans
Masked Member
 
jevans's Avatar
 
Join Date: Dec 2001
Location: Canada
Posts: 257
Default

Well what the hay! why not. Actually only if you have the time. Would I be pushing my luck to ask for volume slider code.

Seriously thanks again.
jevans is offline   Reply With Quote
Old 08-29-2007, 02:37 AM   #6
atomic
Banned by AS.org Staff
 
Join Date: Jan 2007
Location: Montréal, Québec
Posts: 14,073
Default

To display duration... Yet another textfield...

ActionScript Code:
ns.onMetaData = function(metadata) {     duration = metadata.duration;     var dur_seconds:Number = duration;     var minutes_dspl = Math.floor(dur_seconds/60);     var seconds_dspl = Math.floor(dur_seconds%60);     if (minutes_dspl<10) {         minutes_dspl = ("0"+minutes_dspl);     }     if (seconds_dspl<10) {         seconds_dspl = ("0"+seconds_dspl);     }     duration_txt.text = minutes_dspl+":"+seconds_dspl; };

As for sound control, I'd need to see your .fla and your slider's code to help you out on that one...
atomic is offline   Reply With Quote
Old 09-12-2007, 05:18 PM   #7
jevans
Masked Member
 
jevans's Avatar
 
Join Date: Dec 2001
Location: Canada
Posts: 257
Default

Hello again Atomic,

The code you gave me works great!!!. Except for one small problem. I am loading swfs with my flv's into a higher level then my main movie.

When I load the first movie the time code works beautifully works beautifully. When I unload the first movie and load up an entirely different movie the time code blinks and jumps from 0 to 1 over and over.

You may have to jump back and forth from movie to movie to see what I am talking about.

http://www.knowledgenetwork.ca/temp/base.html

Any idea what might be causing such a problem?

Thanks again for your time, Jason.
jevans is offline   Reply With Quote
Old 09-12-2007, 06:59 PM   #8
atomic
Banned by AS.org Staff
 
Join Date: Jan 2007
Location: Montréal, Québec
Posts: 14,073
Default

Could it be some clearInterval problem?

Would have to look at your .fla.

Maybe I can decompile it...
atomic is offline   Reply With Quote
Old 09-12-2007, 08:05 PM   #9
jevans
Masked Member
 
jevans's Avatar
 
Join Date: Dec 2001
Location: Canada
Posts: 257
Default

Hey atomic,

Here are the FLA's, I could email the flv's if required.

I appreciate any light you might be able to shed here.

Thanks, Jason.
Attached Files
File Type: zip base.zip (108.1 KB, 433 views)
jevans is offline   Reply With Quote
Old 09-12-2007, 08:46 PM   #10
atomic
Banned by AS.org Staff
 
Join Date: Jan 2007
Location: Montréal, Québec
Posts: 14,073
Default

Yeah... Working on it! I've decompiled your .swfs and got the FLV's from the site...

It definately has to do with clearing the interval...
atomic is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
display elapsed time learning22 ActionScript 1.0 (and below) 2 03-12-2008 09:44 PM
Total FLV Time Question Ascendancy ActionScript 2.0 2 08-19-2007 07:43 PM
FLV Start time? Can I start it playing 2 secs in? ladyb314 ActionScript 2.0 3 05-15-2007 06:11 PM
display at a certain time devil_online ActionScript 1.0 (and below) 1 02-03-2005 11:41 PM
Display Current Time - The Eternal Question artane ActionScript 1.0 (and below) 11 08-25-2003 07:05 PM


All times are GMT. The time now is 03:57 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.