Chapter 22 Java Media Framework and Java Sound (Web server)
Sunday, August 26th, 2007Chapter 22 Java Media Framework and Java Sound (on CD) 1239 can play most JMF-supported media files with the possible exception of the latest versions of the formats. This application permits users to access files on the local computer that contain supported media types by clicking the Open File button. Clicking the Open Location button and specifying a media URL allows the user to access media from a media source, such as a capture device, a Web server, or a streaming source. A capture device (discussed in Section 22.3) reads media from audio and video devices such as microphones, CD players and cameras. A Real-Time Transport Protocol (RTP) stream is a stream of bytes sent over a network from a streaming server. An application buffers and plays the streaming media on the client computer. 1 // Fig. 22.1: SimplePlayer.java 2 // Opens and plays a media file from 3 // local computer, public URL, or an RTP session 4 5 // Java core packages 6 import java.awt.*; 7 import java.awt.event.*; 8 import java.io.*; 9 import java.net.*; 10 11 // Java extension packages 12 import javax.swing.*; 13 import javax.media.*; 14 15 public class SimplePlayer extends JFrame { 16 17 // Java media player 18 private Player player; 19 20 // visual content component 21 private Component visualMedia; 22 23 // controls component for media 24 private Component mediaControl; 25 26 // main container 27 private Container container; 28 29 // media file and media locations 30 private File mediaFile; 31 private URL fileURL; 32 33 // constructor for SimplePlayer 34 public SimplePlayer() 35 { 36 super( “Simple Java Media Player” ); 37 38 container = getContentPane(); 39 40 // panel containing buttons 41 JPanel buttonPanel = new JPanel(); Fig. 22.1 Playing media with interface Player(part 1 of
.
We recommend you use shared web hosting services, because many users agree that it is cheap, reliable and customer-satisfying webhost.