T
torbs
How can I get JMF to read a rtsp stream and displaying the content in a
player.
I have modified the code in JMF's documentation, but the documentation
for rtsp is not very good. I need to find a way to read rtsp streams.
I have tried Quicktime for Java, but I would really like to find a way
to display content that every platform can read.
I have installed the ffmpeg mpeg 4 codec for jmf.
Tor
CODE:
import java.applet.*;
import java.awt.*;
import java.net.*;
import javax.media.*;
public class PlayerApplet extends Applet implements ControllerListener
{
Player player = null;
public void init() {
setLayout(new BorderLayout());
String mediaFile =
"rtsp://lillestroem.uio.no/div/imk/strekktekst/320/L1M2.mp4";
try {
MediaLocator mrl= new MediaLocator(mediaFile);
player = Manager.createPlayer(mrl);
player.addControllerListener(this);
}
catch (Exception e) {
System.err.println("Got exception "+e);
}
}
public void start() {
player.start();
}
public void stop() {
player.stop();
player.deallocate();
}
public void destroy() {
player.close();
}
public synchronized void controllerUpdate(ControllerEvent event) {
if (event instanceof RealizeCompleteEvent) {
Component comp;
if ((comp = player.getVisualComponent()) != null)
add ("Center", comp);
if ((comp = player.getControlPanelComponent()) != null)
add ("South", comp);
validate();
}
}
}
player.
I have modified the code in JMF's documentation, but the documentation
for rtsp is not very good. I need to find a way to read rtsp streams.
I have tried Quicktime for Java, but I would really like to find a way
to display content that every platform can read.
I have installed the ffmpeg mpeg 4 codec for jmf.
Tor
CODE:
import java.applet.*;
import java.awt.*;
import java.net.*;
import javax.media.*;
public class PlayerApplet extends Applet implements ControllerListener
{
Player player = null;
public void init() {
setLayout(new BorderLayout());
String mediaFile =
"rtsp://lillestroem.uio.no/div/imk/strekktekst/320/L1M2.mp4";
try {
MediaLocator mrl= new MediaLocator(mediaFile);
player = Manager.createPlayer(mrl);
player.addControllerListener(this);
}
catch (Exception e) {
System.err.println("Got exception "+e);
}
}
public void start() {
player.start();
}
public void stop() {
player.stop();
player.deallocate();
}
public void destroy() {
player.close();
}
public synchronized void controllerUpdate(ControllerEvent event) {
if (event instanceof RealizeCompleteEvent) {
Component comp;
if ((comp = player.getVisualComponent()) != null)
add ("Center", comp);
if ((comp = player.getControlPanelComponent()) != null)
add ("South", comp);
validate();
}
}
}