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 ...

Get QuickTime for Java: A Developer's Notebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.