You can seek into an embedded RealPlayer presentation using the SetPosition(); method, specifying the time in milliseconds.
So, if you want to cue forward to the ten second mark, you'd use the following code:
SetPosition(10000);
Interestingly enough, there are no fast forward or rewind JavaScript methods for the RealPlayer. However, using the SetPosition(); method, you can write your own. Of course, they're not true fast forward or rewind controls because you won't see or hear as you rewind, and you can't hold the button down, but they work nonetheless.
The following code assumes you have an embedded RealPlayer named "javareal" somewhere in the document:
function RewindRealMedia () {
// "rewind" the presentation five seconds each time the function is called
// first get the current position using GetPosition
var pos;
pos = document.javareal.GetPosition();
// then either subtract five seconds from the current position or set to
// zero if it's close to the beginning.
if (pos > 10000) {
pos = pos - 5000;
}
else {
pos = 0;
}
// use the new position variable to call SetPosition,
// which automatically plays from that point.
document.javareal.SetPosition(pos);
}
function FFRealMedia () {
// "fast-forward" the presentation five seconds when the function is called
var pos;
pos = document.javareal.GetPosition();
pos = pos + 5000;
// again, no stop or play necessary - just seek to next position.
document.javareal.SetPosition(pos);
}
Using these functions, you could use a button to call them using the following code:
<a href="javascript:void" OnClick="RewindRealMedia();">
<img src="rewindButton.gif"> </a>
Presto!
|