JavaScript: FlowPlayer::getTime() |
Author: |
Message: |
Weyzza
Veteran Member
SoCal sunset > *
Posts: 1170 Reputation: 29
– / / –
Joined: May 2003
|
O.P. JavaScript: FlowPlayer::getTime()
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.
Registered 7853 days, 20 hours, 47 minutes, 34 seconds ago.
Happy Birthday, WDZ
|
|
04-03-2007 08:13 PM |
|
|
hmaster
Senior Member
Posts: 716 Reputation: 24
33 / /
Joined: Nov 2004
|
RE: JavaScript: FlowPlayer::getTime()
Have you defined flowplayer1?
My mistake didn't read the question properly.
This post was edited on 04-03-2007 at 08:47 PM by hmaster.
|
|
04-03-2007 08:43 PM |
|
|
Weyzza
Veteran Member
SoCal sunset > *
Posts: 1170 Reputation: 29
– / / –
Joined: May 2003
|
O.P. RE: JavaScript: FlowPlayer::getTime()
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
Or, maybe, I don't fully understand the scope
This post was edited on 04-03-2007 at 08:49 PM by Weyzza.
Registered 7853 days, 20 hours, 47 minutes, 34 seconds ago.
Happy Birthday, WDZ
|
|
04-03-2007 08:45 PM |
|
|
hmaster
Senior Member
Posts: 716 Reputation: 24
33 / /
Joined: Nov 2004
|
RE: JavaScript: FlowPlayer::getTime()
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.
This post was edited on 04-03-2007 at 08:52 PM by hmaster.
|
|
04-03-2007 08:49 PM |
|
|
Weyzza
Veteran Member
SoCal sunset > *
Posts: 1170 Reputation: 29
– / / –
Joined: May 2003
|
O.P. RE: RE: JavaScript: FlowPlayer::getTime()
Bah, you really need to read my post carefully
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.
Registered 7853 days, 20 hours, 47 minutes, 34 seconds ago.
Happy Birthday, WDZ
|
|
04-03-2007 09:04 PM |
|
|
WDZ
Former Admin
Posts: 7106 Reputation: 107
– / /
Joined: Mar 2002
|
RE: JavaScript: FlowPlayer::getTime()
You don't need to update it constantly... that would cause massive lag...
Just call the getTime() function once onload, then set a timer within the function...
setTimeout('getTime()', 1000);
|
|
04-03-2007 09:08 PM |
|
|
Weyzza
Veteran Member
SoCal sunset > *
Posts: 1170 Reputation: 29
– / / –
Joined: May 2003
|
O.P. RE: JavaScript: FlowPlayer::getTime()
OK,
Using your idea, it prints "0" in the beginning of the video now (which is good, because it didn't before ), but it does not update
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.
Registered 7853 days, 20 hours, 47 minutes, 34 seconds ago.
Happy Birthday, WDZ
|
|
04-03-2007 09:41 PM |
|
|
ShawnZ
Veteran Member
Posts: 3146 Reputation: 43
32 / /
Joined: Jan 2003
|
RE: JavaScript: FlowPlayer::getTime()
use setInterval, not setTimeout. (same parameters)
Spoiler: the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
|
|
04-03-2007 09:42 PM |
|
|
Weyzza
Veteran Member
SoCal sunset > *
Posts: 1170 Reputation: 29
– / / –
Joined: May 2003
|
O.P. RE: JavaScript: FlowPlayer::getTime()
Thanks, ShawnZ.
It works
Registered 7853 days, 20 hours, 47 minutes, 34 seconds ago.
Happy Birthday, WDZ
|
|
04-03-2007 09:47 PM |
|
|
|