Hi all
Plz help me about media streaming.I want to play files that transmit from 'rtmp' link at my java application program.I have a program that play from 'http' link.Code is here
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
import javax.media.*;
//import com.sun.media.protocol.rtsp.DataSource;
import java.net.*;
public class MediaPlayerTest extends JFrame
{
private Player player;
private File file;
public MediaPlayerTest()
{
super( "Demonstrating the Java Media Player" );
JButton openFile = new JButton( "Click to play" );
openFile.addActionListener( new ActionListener()
{
public void actionPerformed( ActionEvent e )
{
createPlayer();
}
});
getContentPane().add( openFile, BorderLayout.NORTH );
setSize( 300, 82);
show();
}
private void createPlayer()
{
removePreviousPlayer();
try
{
//player = Manager.createPlayer(new URL("rtmp://mtalk.net.mm/oflaDemo/DarkKnight.flv"));
player = Manager.createPlayer(new URL("http://www.mtalk.net.mm/images/song_for_u.mp3"));
player.addControllerListener( new EventHandler() );
player.start(); // start player
}
catch ( Exception e )
{
JOptionPane.showMessageDialog( this, "Invalid file or location", "Error loading file",
JOptionPane.ERROR_MESSAGE );
}
}
private void removePreviousPlayer()
{
if ( player == null )
return;
player.close();
Component visual = player.getVisualComponent();
Component control = player.getControlPanelComponent();
Container c = getContentPane();
if ( visual != null )
c.remove( visual );
if ( control != null )
c.remove( control );
}
public static void main(String args[])
{
MediaPlayer app = new MediaPlayer();
app.addWindowListener( new WindowAdapter()
{
public void windowClosing( WindowEvent e )
{
System.exit(0);
}
});
}
// inner class to handler events from media player
private class EventHandler implements ControllerListener
{
public void controllerUpdate( ControllerEvent e )
{
if ( e instanceof RealizeCompleteEvent )
{
Container c = getContentPane();
// load Visual and Control components if they exist
Component visualComponent = player.getVisualComponent();
if ( visualComponent != null )
c.add( visualComponent, BorderLayout.CENTER );
Component controlsComponent = player.getControlPanelComponent();
if ( controlsComponent != null )
c.add( controlsComponent, BorderLayout.SOUTH );
c.doLayout();
}
}
}
}
But can't play from 'rtmp'. I am so newer at media streaming. Pls help me how will I do it.Thank in advance.