Forum Moderators: open

Message Too Old, No Replies

Javascript and quicktime

fast-forwording...

         

electricocean

3:21 am on Jun 13, 2005 (gmt 0)

10+ Year Member



Hi, is there a way to fast-forward a quicktime movie w/ javascript(fast-forward to a number of seconds defined)?

I got this code from the apple website:

int GetTime()
void SetTime(int time)

I don't really get that tho

thanks,
eleictricocean

RonPK

5:46 pm on Jun 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Let's say your movie is called mymovie, so you have <object [bla bla] id="myMovie">

and you have added a control where you can enter the point in time to jump to, like this

<form>
<input type="button" name="goto" value="Go To"
onclick="SkipTo(document.myMovie, document.forms[0].nSec.value);"/><input type="text" name="nSec">
</form>

then what you need is a javascript function that reads the movie's frame rate and multiplies that with the number of seconds entered. QT uses its own timescale; use the method GetTimeScale() to read it. The method SetTime() will make the player jump to the given place in the movie, calculated in QT timescale.

function SkipTo(myObj, nSec) { 
myObj.SetTime(myObj.GetTimeScale() * nSec);
}

If you want the player to skip a given number of secs, you'll need the GetTime() method:

function SkipTo(myObj, nSec) { 
myObj.SetTime(myObj.GetTime() + myObj.GetTimeScale() * nSec);
}

HTH

electricocean

9:25 pm on Jun 13, 2005 (gmt 0)

10+ Year Member



Thanks RonPK.

I think i am using the second function becuase that fast forwards to a certain number of seconds given. The number of secons would be in php like so:

$fast_forward = $_GET['time'];

would I need to to add that in any of the code that you gave me?

thanks,
electricocean

RonPK

6:14 am on Jun 14, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There are several ways to insert the value from PHP, one is to put the number of seconds in the button:

<input type="button" name="goto" value="Go To"  
onclick="SkipTo(document.myMovie, <?php
echo (isset($_GET['time']) && is_numeric($_GET['time'])) ?
$_GET['time'] : 5 ;
?>);">

electricocean

11:07 pm on Jun 14, 2005 (gmt 0)

10+ Year Member



Thank you so much, I will go and try it.

electricocean

electricocean

11:38 pm on Jun 14, 2005 (gmt 0)

10+ Year Member



Ok I am trying it right now but I am really confuzed w/ the php.

whats is the '? $_GET['time'] : 5 ;' part?

if you could explain tit hat would be great

electricocean

11:56 pm on Jun 14, 2005 (gmt 0)

10+ Year Member



i think i ge it. fastword to then giv seconds else fastword to 5 seconds.... if it is that can i change it to 0?

electricocean

electricocean

1:05 am on Jun 15, 2005 (gmt 0)

10+ Year Member



For some reason it now the frames per second is $_GET['time'] and it starts from the beggining if i changed 5 to 0

I was also how many browsers can use this code?

electricocean

RonPK

7:37 am on Jun 15, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yeah, it's a shorthand for if .. else

condition [b]?[/b] if true, return this [b]:[/b] else return something else ;

I've tested the script in IE 6, FF 1.0.4 and Opera 8, all on Windows.

electricocean

10:16 pm on Jun 15, 2005 (gmt 0)

10+ Year Member



O thats great. I am using safari on a mac...

RonPK

10:45 pm on Jun 15, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Give it a try; I promise you won't be disappointed ;)

just tested it in Safari 312

electricocean

11:50 pm on Jun 16, 2005 (gmt 0)

10+ Year Member



Hi,

I have been trying 'window.onload' becuase i wanted the movie to skip to that place automatically... it didn't work. Now I tried that submit butto and still nothing happrns....

Here's my code:

<script language="javascript=">
function SkipTo(myObj, nSec) {
myObj.SetTime(myObj.GetTime() + myObj.GetTimeScale() * nSec);
}</script>

<input type="button" name="goto" value="Go To"
onclick="SkipTo(document.movieSlug, <?php
echo (isset($_GET['time']) && is_numeric($_GET['time']))?
$_GET['time'] : 5 ;
?>);">

<?php
$src = $_GET["src"];

$filename = ${src};
print "<OBJECT CLASSID=\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\" CODEBASE=\"http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0\" id=\"movieSlug\">";
print "<PARAM name=\"SRC\" VALUE=\"{$filename}\">";
print "<PARAM name=\"AUTOPLAY\" VALUE=\"true\">";
print "<PARAM name=\"CONTROLLER\" VALUE=\"true\">";
print "<PARAM name=\"enablejavascript\" VALUE=\"true\">";
print "<embed src=\"{$filename}\" type=\"video/quicktime\" AUTOPLAY=\"true\" PLUGINSPAGE=\"http://www.apple.com/quicktime/download\" enablejavascript=\"true\">";
print "</embed></OBJECT>";
?>

and heres my link:

http://csebvideo.cs.funpic.org/?id=play_movie.php&src=http://images.apple.com/movies/wb/charliechocolat#*$!/charliechocolate-tlr_i320.mov&time=22
//To fastworwrd 22 seconds as a test

note: for some reason the movie is cut off ina perfect square and missing stuff and the controller will not show up... I don't why thats happening

electricocean

7:00 am on Jun 17, 2005 (gmt 0)

10+ Year Member



ooops... the code is wrong $filename should be $src... I copied ti wrong

electricocean

RonPK

7:25 am on Jun 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What if you add name="movieSlug" to the embed tag?

electricocean

11:48 pm on Jun 17, 2005 (gmt 0)

10+ Year Member



I tried that... still nothing. can the javascript be inside the body of a page? my page has include files that change with '$pageid=$_GET['path'];'. So the the movie player is an include and i don't know if that causes anything.

Thanks,
electricocean