December 06, 2004

javascript controls of a quicktime movie (update)

so at first i thought i was just dumb. this is common to me on some level (see: will telling me i inhabit a special place in stupid space today).

but even after seeing that video was controlled by setting an int of second times framerate, i couldnt make the movie jump to the correct point.

this was a problem. for wed, i could put the iframe back in, but thats no good. i dont want to reload the movie every time. and i especially want to be able to scrub. (starttime being set in the embed tag literally makes the movie start from there, no matter where you drag the slider.)

so its an issue.

after poking around for hours and hours, i found a page on apple (who has convienently removed the section on scripting quicktime controls from their site) that states this is not how you set the time int.

instead, movies are set by seconds times 600. this constant rate of 600 seems totally arbitrary. and i had computed this already last night by trial and error.

the great part is that seconds times 600 works great for small movies. but on one of my test movies, which is 26 minutes long, it starts slipping frames around 8 or 10 minutes in.

this isnt good.

so i keep digging all day, trying to figure out whats going on.

i never find anything, so i go back to the drawing board and decide to compute the error into my function. another nice chunk of time and i have figured out the function you really want to jump in a movie.

this has been tested up to a movie 56 minutes long, it might change once i start testing longer files.

but the function looks like this (where timer is seconds, in an int, of the distance from the beginning you want to skip to):

function startmovie(timer) {
timer = timer * 600;

//to correct for error, add 1 frame every 400 seconds of video
timer = Math.round(timer + ((timer / 240000)*60));

document.screen.SetTime(timer);
}


now dont tell me that the math line isnt hot. i mean, thats some sexy math to tweak something that is just horribly designed. well done.

Posted by tripp at December 6, 2004 09:24 PM



Comments

Post a comment




Remember Me?