943,083 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Marked Solved
  • Views: 1240
  • Java RSS
Dec 5th, 2009
0

Media Streaming at Java application

Expand Post »
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
Java Syntax (Toggle Plain Text)
  1.  
  2. import java.awt.*;
  3. import java.awt.event.*;
  4. import java.io.*;
  5. import javax.swing.*;
  6. import javax.media.*;
  7. //import com.sun.media.protocol.rtsp.DataSource;
  8. import java.net.*;
  9.  
  10. public class MediaPlayerTest extends JFrame
  11. {
  12. private Player player;
  13. private File file;
  14.  
  15. public MediaPlayerTest()
  16. {
  17. super( "Demonstrating the Java Media Player" );
  18.  
  19. JButton openFile = new JButton( "Click to play" );
  20. openFile.addActionListener( new ActionListener()
  21. {
  22. public void actionPerformed( ActionEvent e )
  23. {
  24. createPlayer();
  25. }
  26. });
  27. getContentPane().add( openFile, BorderLayout.NORTH );
  28. setSize( 300, 82);
  29. show();
  30. }
  31. private void createPlayer()
  32. {
  33. removePreviousPlayer();
  34. try
  35. {
  36. //player = Manager.createPlayer(new URL("rtmp://mtalk.net.mm/oflaDemo/DarkKnight.flv"));
  37. player = Manager.createPlayer(new URL("http://www.mtalk.net.mm/images/song_for_u.mp3"));
  38. player.addControllerListener( new EventHandler() );
  39. player.start(); // start player
  40. }
  41. catch ( Exception e )
  42. {
  43. JOptionPane.showMessageDialog( this, "Invalid file or location", "Error loading file",
  44. JOptionPane.ERROR_MESSAGE );
  45. }
  46. }
  47.  
  48. private void removePreviousPlayer()
  49. {
  50. if ( player == null )
  51. return;
  52.  
  53. player.close();
  54.  
  55. Component visual = player.getVisualComponent();
  56. Component control = player.getControlPanelComponent();
  57.  
  58. Container c = getContentPane();
  59.  
  60. if ( visual != null )
  61. c.remove( visual );
  62.  
  63. if ( control != null )
  64. c.remove( control );
  65. }
  66.  
  67. public static void main(String args[])
  68. {
  69. MediaPlayer app = new MediaPlayer();
  70.  
  71. app.addWindowListener( new WindowAdapter()
  72. {
  73. public void windowClosing( WindowEvent e )
  74. {
  75. System.exit(0);
  76. }
  77. });
  78. }
  79.  
  80. // inner class to handler events from media player
  81. private class EventHandler implements ControllerListener
  82. {
  83. public void controllerUpdate( ControllerEvent e )
  84. {
  85. if ( e instanceof RealizeCompleteEvent )
  86. {
  87. Container c = getContentPane();
  88.  
  89. // load Visual and Control components if they exist
  90. Component visualComponent = player.getVisualComponent();
  91.  
  92. if ( visualComponent != null )
  93. c.add( visualComponent, BorderLayout.CENTER );
  94.  
  95. Component controlsComponent = player.getControlPanelComponent();
  96.  
  97. if ( controlsComponent != null )
  98. c.add( controlsComponent, BorderLayout.SOUTH );
  99.  
  100. c.doLayout();
  101. }
  102. }
  103. }
  104. }

But can't play from 'rtmp'. I am so newer at media streaming. Pls help me how will I do it.Thank in advance.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
Sandar Khin is offline Offline
18 posts
since Oct 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: making Sphinx4 apps with Ant
Next Thread in Java Forum Timeline: Java Character count





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC