View Full Version : Media player plugin: currentime/totaltime
02-11-2004, 08:19 PM
Right now im using the page timer at 1000ms to update the Media player object, however it is displaying the current and total time in a stupid seconds only format, does anyone have code to display in the 0:00/0:00 format?
Right now this is what i got:
length = MediaPlayer.GetLength("mediaplayer");
pos = MediaPlayer.GetCurrentPos("mediaplayer");
msg = string.format("%.2f/%.2f",pos,length);
And it displays
1.34343/223.1121 (seconds over seconds with a huge decimal) i would like something more like winamp.
02-13-2004, 09:13 AM
I use something along these lines (see below). As far as having the actions output in seconds-only format . . . while it makes it a little harder to output the time in a pleasing format, there are other instances where a 00:00 format would be impractical.
--What is the currently playing track?
currenttrack = CDAudio.GetTrack();
--What is the current position of the track?
current = CDAudio.GetCurrentPos();
--What is the total length of the current track?
length = CDAudio.GetTrackLength(currenttrack);
--Split the current position into minutes and seconds, no decimal
current_minutes = Math.Floor(current/60); --get the current position (minutes)
current_seconds = Math.Floor(current - (current_minutes*60)); --get the current position (seconds)
--Split the current length into minutes and seconds, no decimal
length_minutes = Math.Floor(length/60); --get the length (minutes)
length_seconds = Math.Floor(length - (length_minutes*60)); --get the length (seconds)
--If minutes is less than 10, add a preceding zero (current position)
if current_minutes < 10 then --format the minutes to 'always' double digit
current_minutes = "0" .. current_minutes;
--If seconds is less than 10, add a preceding zero (current position)
if current_seconds < 10 then --format the seconds to 'always' double digits
current_seconds = "0" .. current_seconds;
--if minutes is less than 10, add a preceding zero (length)
if length_minutes < 10 then --format the minutes to 'always' double digit
length_minutes = "0" .. length_minutes;
--if seconds is less than 10, add a preceding zero (length)
if length_seconds < 10 then --format the seconds to 'always' double digits
length_seconds = "0" .. length_seconds;
--set sTime to contain time in format 00:00 / 00:00
sTime = current_minutes .. ":" .. current_seconds .. " / " .. length_minutes .. ":" .. length_seconds;
02-13-2004, 09:32 AM
thanks desmond i will try that out.
02-16-2004, 03:45 PM
Great, great, great.
I just searced for a way to show the mediaplayer time in that format. I found it here. It works very well
Powered by vBulletin™ Version 4.0.6 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.