O'Reilly logo

QuickTime for Java: A Developer's Notebook by Chris Adamson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Playing Movies from URLs

Along with loading movies from disk, QuickTime can also load them from URLs, and is pretty smart about network latency.

How do I do that?

Example 2-6 shows a totally new class, BasicQTURLController.java. This is a significant rethinking of the earlier BasicQTController class. This example creates a GUI from an empty “dummy” movie, then asks the user for a URL, gets a Movie from that, and replaces the dummy movie. By getting the movie last, it tempts fate to see how well QTJ can deal with loading a movie over the network.

Example 2-6. Loading and playing a movie from a URL

package com.oreilly.qtjnotebook.ch02; import quicktime.*; import quicktime.std.*; import quicktime.app.view.*; import quicktime.std.movies.*; import quicktime.std.movies.media.*; import quicktime.io.*; import com.oreilly.qtjnotebook.ch01.QTSessionCheck; import java.awt.*; public class BasicQTURLController extends Frame { QTComponent qc; public BasicQTURLController ( ) throws QTException { super ("Basic QT DataRef/Controller"); Movie dummyMovie = new Movie( ); qc = QTFactory.makeQTComponent (dummyMovie); Component c = qc.asComponent( ); add (c); pack( ); } public static void main (String[ ] args) { try { QTSessionCheck.check( ); BasicQTURLController f = new BasicQTURLController ( ); String url = javax.swing.JOptionPane.showInputDialog (f, "Enter URL"); DataRef dr = new DataRef (url); Movie m = Movie.fromDataRef (dr, StdQTConstants.newMovieActive); MovieController mc = new MovieController ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required