PDA

View Full Version : playing videos



davidjmorin
09-27-2007, 05:52 PM
hey all
i was wondering i am very new to java and ajax. How can i load a movie mov,mpeg,avi, etc. into the player without reloading the page? i dont want flash players. i know how to do it with that. any ideas or examples out there i can use? thanks

djr33
09-27-2007, 10:44 PM
Flash can be ugly, but this is one case where it has an advantage over any other method. It has the ability to precisely control video content, and... nothing else really does.

There are some limited ways to control quicktime and I believe real media plugins with Javascript. There may also be some more limited options with window media.
I think Quicktime has the most, of those.

However, you're not actually wanting to control the video, just which video. That's not so bad. (That information may be relevant soon, though.)

Here's the problem:
Reloading a video isn't like reloading a picture, or, especially, text content.

Videos are rarely under 1mb and that will take a while to download especially on slower connections.

So, no, you can't just change it seamlessly.

There is a workaround, though:
Load it beforehand.
This can be done two ways:
1) Load when requested-- first time it's loaded it will end up stored then you can switch back without problems
2) Load them all when the page loads

(1) wastes less bandwidth and can potentially be less for the user to download if they won't be watching every file; (2) will cause a significant delay loading files (and waste bandwidth), but will have no delays after that.

There have been a few discussions on the subject. Try a search. Might be a bit hard to find, but there's some useful info there.

Regardless of the above info, you could just change the src using javascript. ( = loading problems, though.)

I suggest, instead, using an ajax tabs type layout.

When switching tabs, just remember to mute the audio or pause the video playback. Then you should be fine. (And turn off autoplay.)

See this script for an example--
http://www.dynamicdrive.com/forums/showthread.php?t=22703