Shoutbox

JavaScript: FlowPlayer::getTime() - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: JavaScript: FlowPlayer::getTime() (/showthread.php?tid=73283)

JavaScript: FlowPlayer::getTime() by Weyzza on 04-03-2007 at 08:13 PM

I have a question related to JavaScript in general.

I see in the tutorial that users can get the playing time of the video that is playing using getTime().

<a href="javascript: getTime()">Get time</a> <input type="text" id="time" />

Basically, it calls the FlowPlayer's getTime() routine everytime a user clicks the link, then output it to the field.
My question is, how to keep executing getTime() while the video is running?

I have tried while(true) getTime();, but it didn't work.

code:
function getTime() {
    var time = flowPlayer1.getTime();
    var timeField = document.getElementById("time");
    timeField.value = time;
}

Thank you.
RE: JavaScript: FlowPlayer::getTime() by hmaster on 04-03-2007 at 08:43 PM

Have you defined flowplayer1?
My mistake didn't read the question properly.


RE: JavaScript: FlowPlayer::getTime() by Weyzza on 04-03-2007 at 08:45 PM

I have.
However, I did that in a separate .js file.
But I don't think I need to re-initialize it again.

If I haven't, <a href="javascript: getTime()">Get time</a> <input type="text" id="time" /> would not work :p

Or, maybe, I don't fully understand the scope :p


RE: JavaScript: FlowPlayer::getTime() by hmaster on 04-03-2007 at 08:49 PM

You just want it to keep executing getTime();?

code:
x = 1;
while(x == 1) {
getTime();
}
You can also add when the video is finished not to execute.
code:
x = 1;
while(x == 1) {
     if(flowplayer1.stopped == true) { *
          x = 0;
     } else {
          getTime();
     }
}

* Not the correct code but you get the idea.
RE: RE: JavaScript: FlowPlayer::getTime() by Weyzza on 04-03-2007 at 09:04 PM

Bah, you really need to read my post carefully :p

quote:
Originally posted by hmaster
You just want it to keep executing getTime();?
code:
x = 1;
while(x == 1) {
getTime();
}

I have said I did
code:
while(true) getTime();
and it didn't work.
quote:
You can also add when the video is finished not to execute.
code:
x = 1;
while(x == 1) {
     if(flowplayer1.stopped == true) { *
          x = 0;
     } else {
          getTime();
     }
}

Apparently, there's routine for checking if the video is stopped.
But getTime() will simply return 0 (seconds) if the video is stopped.
RE: JavaScript: FlowPlayer::getTime() by WDZ on 04-03-2007 at 09:08 PM

:-/ You don't need to update it constantly... that would cause massive lag... :p

Just call the getTime() function once onload, then set a timer within the function...

setTimeout('getTime()', 1000);


RE: JavaScript: FlowPlayer::getTime() by Weyzza on 04-03-2007 at 09:41 PM

OK,

Using your idea, it prints "0" in the beginning of the video now (which is good, because it didn't before :tongue:), but it does not update :sad:

I don't think I have told the idea of this whole thing.
I want to get access to the time counter from FlowPlayer to JavaScript.
The only way I can think of is by constantly monitoring the time.
For example, at 1m 35s, I want to insert something to the page using JavaScript, etc.


RE: JavaScript: FlowPlayer::getTime() by ShawnZ on 04-03-2007 at 09:42 PM

use setInterval, not setTimeout. (same parameters)


RE: JavaScript: FlowPlayer::getTime() by Weyzza on 04-03-2007 at 09:47 PM

Thanks, ShawnZ.
It works :p