Play audio from internet -http connection-

Hi friends,
I have made an audio player using jmf as part of my project.It can play files from local machine as well as local network in my company. But i don't know how to play audio files like wav,mp3 from internet using http connection as described by tristanlee85. Can anyone explain me how to accomplish this.
The code where i tried to
access http connection is given below.
But it is not working.I know Streaming is necessary. But how to do it in jmf. What imports are needed.Please guide me
Manu
import javax.media.*;
import java.text.DecimalFormat;
import java.awt.*;
import java.awt.FileDialog;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import java.io.*;
import java.net.*;
import java.util.*;
<APPLET CODE=PlayerApplet.class
WIDTH=320 HEIGHT=300>
</APPLET>
class nwa extends WindowAdapter
     frameclass frame;
     Player player;
     public nwa(frameclass frame,Player player)
      this.player=player;
      this.frame=frame;
     public void windowClosing (WindowEvent e)
      //User selected close from System menu.
      //Call dispose to invoke windowClosed.
      frame.dispose ();
      public void windowClosed (WindowEvent e)
          if (player != null)
               player.stop();
            player.close ();
               player.deallocate();
      System.exit (0);
class frameclass extends JFrame
Player player;
     frameclass(Player player)
     nwa n=new nwa(this,player);
     this.addWindowListener(n);                    
public class PlayerApplet extends JApplet
           implements ActionListener,ControllerListener,ItemListener, KeyListener
           Player player=null;
           frameclass frame=new frameclass(player);
             Component vc, cc;
             Container f;
             JProgressBar volumeBar;
             JButton fastRewind;
          JButton fastForward;
          JButton play;
          int sizeIncrease = 2;
          boolean invokedStop = false;
          /** Big */
          int progressFontSize=30;
             boolean first = true, loop = false;
             String currentDirectory;
             public void init()
                      f=frame.getContentPane();
                     JMenu m = new JMenu ("File");
                     JMenuItem mi = new JMenuItem ("Open...");
                     mi.addActionListener (this);
                     m.add (mi);
                     m.addSeparator ();
                     mi = new JMenuItem ("URL");
                     mi.addActionListener (this);
                     m.add (mi);
                     m.addSeparator ();
                     JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem ("Loop", false);
                     cbmi.addItemListener (this);
                     m.add (cbmi);
                     m.addSeparator ();
                     mi = new JMenuItem ("Exit");
                     mi.addActionListener (this);
                     m.add (mi);
                     JMenuBar mb = new JMenuBar ();
                     mb.add (m);
                     frame.setJMenuBar (mb);
                     setSize (500, 500);
                       JPanel p = new JPanel(new GridLayout(1,0,5,5));
                    p.setBorder(new EmptyBorder(3,5,5,5) );
                    fastRewind = new JButton("<html><body><font size=+"+ sizeIncrease+ "><<");
                    fastRewind.setToolTipText("Fast Rewind");
                    fastRewind.addActionListener( new ActionListener(){
                         public void actionPerformed(ActionEvent ae) {
                              if (player!=null) {
                                   invokedStop = false;
                                   skipBack();
                              } else {
                                   JOptionPane.showMessageDialog(play,
                                   new JLabel("Open a sound file first!"));
                    fastRewind.addKeyListener(this);
                    p.add(fastRewind);
                    JButton stop = new JButton("<html><body><font size=+"+ sizeIncrease+ ">��");
                    stop.setToolTipText("Stop");
                    stop.addActionListener( new ActionListener(){
                              public void actionPerformed(ActionEvent ae) {
                                   invokedStop = true;
                                   sp();
                    stop.addKeyListener(this);
                    p.add(stop);
                    play = new JButton("<html><body><font size=+"+ sizeIncrease+ ">>");
                    play.setToolTipText("Play");
                    play.addActionListener( new ActionListener()
                              public void actionPerformed(ActionEvent ae) {
                                   if (player!=null) {
                                        invokedStop = false;
                                        player.setRate(1);
                                        st();
                                   } else {
                                        JOptionPane.showMessageDialog(play,
                                        new JLabel("Open a sound file first!"));
          play.addKeyListener(this);
          p.add(play);
          fastForward = new JButton("<html><body><font size=+"+ sizeIncrease+ ">>>");
          fastForward.setToolTipText("Fast Forward");
          fastForward.addActionListener( new ActionListener(){
               public void actionPerformed(ActionEvent ae) {
                    if (player!=null) {
                         invokedStop = false;
                         skipForward();
                    } else {
                         JOptionPane.showMessageDialog(play,
                         new JLabel("Open a sound file first!"));
          fastForward.addKeyListener(this);
          p.add(fastForward);
          frame.getContentPane().add(p,BorderLayout.CENTER);
          frame.setVisible (true);
          frame.pack();
          frame.setResizable(false);
  public void stop(){
  sp();
  public void destroy(){
   player.stop();
    player.deallocate();
  public void actionPerformed (ActionEvent e)
          if (e.getActionCommand().equals("Exit"))
                         // Call dispose to invoke windowClosed.
                         player.stop();
                         player.close();
                         player.deallocate();
                         frame.dispose ();
                              return;
// Play file from local machine
          if (e.getActionCommand().equals("Open..."))
                         FileDialog fd = new FileDialog (frame, "Open File",
                                     FileDialog.LOAD);
                          fd.setDirectory (currentDirectory);
                          fd.show ();
                          // If user cancelled, exit.
                          if (fd.getFile() == null)
                         return;
                          currentDirectory = fd.getDirectory ();
                               if (player != null){
                                   player.close ();
                                   player.deallocate();
                     try
              player = Manager.createPlayer (new MediaLocator
                                           ("file:" +
                                           fd.getDirectory() +
                                           fd.getFile()));
                          catch (java.io.IOException e2)
                        System.out.println ("file not found :"+e2);
                        return;
                          catch (NoPlayerException e2)
                        System.out.println ("Could not find a player.");
                        return;
                if (player == null)
               System.out.println ("Trouble creating a player.");
               return;
                first = false;
                frame.setTitle (fd.getFile ().toString());
                player.addControllerListener (this);
                player.prefetch ();
               return;
// Play file from internet
if (e.getActionCommand().equals("URL"))
                          if (player != null){
                                   player.close ();
                                   player.deallocate();
               try
                    URL url = new URL ("http://www.plastikhosting.net/uploads/tristanlee85/music/02-hellyeah-you_wouldnt_know.mp3");
                MediaLocator mediaLocator = new MediaLocator (url);
                    player = Manager.createPlayer (mediaLocator);
               catch (java.io.IOException e2)
              System.out.println ("file not found :"+e2);
              return;
                catch (NoPlayerException e2)
              System.out.println ("Could not find a player.");
              return;
                if (player == null)
               System.out.println ("Trouble creating a player.");
               return;
      first = false;
      player.addControllerListener (this);
      player.prefetch ();
          player.start ();
          return;
   public void controllerUpdate (ControllerEvent e)
      if (e instanceof ControllerClosedEvent)
          if (vc != null)
              frame.getContentPane().remove (vc);
              vc = null;
          if (cc != null)
              frame.getContentPane().remove (cc);
              cc = null;
          return;
      if (e instanceof EndOfMediaEvent)
          if (loop)
              player.setMediaTime (new Time (0));
              player.start ();
          return;
      if (e instanceof PrefetchCompleteEvent)
          player.start();
          return;
      if (e instanceof RealizeCompleteEvent)
        if (vc != null)
              remove (vc);
              vc = null;
          if (cc != null)
              remove (cc);
              cc = null;
          vc = player.getVisualComponent ();
          if (vc != null)
              frame.getContentPane().add(vc,BorderLayout.NORTH);
          cc = player.getControlPanelComponent ();
          if (cc != null){
                   frame.getContentPane().add (cc, BorderLayout.SOUTH);
                 frame.setVisible(true);
                 frame.pack();
                  return;
public void keyReleased(KeyEvent ke) {
public void keyTyped(KeyEvent ke) {
/*public void keyReleased(KeyEvent ke) {
int keycode = ke.getKeyCode();
          if (keycode==KeyEvent.VK_LEFT) {
               skipBack();
          } else if (keycode==KeyEvent.VK_RIGHT) {
               skipForward();
     /*public void keyTyped(KeyEvent ke) {
     int keycode = ke.getKeyCode();
          if (keycode==KeyEvent.VK_LEFT) {
               skipBack();
          } else if (keycode==KeyEvent.VK_RIGHT) {
               skipForward();
     public void keyPressed(KeyEvent ke) {
          int keycode = ke.getKeyCode();
          if (keycode==KeyEvent.VK_LEFT) {
               skipBack();
          } else if (keycode==KeyEvent.VK_RIGHT) {
               skipForward();
          }else if (keycode==KeyEvent.VK_UP) {
               st();
          }else if (keycode==KeyEvent.VK_DOWN) {
               sp();
public void skipForward() {
Time settime;
double secs=5;
double playersecs = player.getMediaTime().getSeconds();
double duration = player.getDuration().getSeconds();
          if((playersecs+secs) < duration){
                  settime = new javax.media.Time(playersecs + secs);
                  player.setMediaTime(settime);
          }else {
                    player.setMediaTime(new Time(duration));
public void skipBack() {
          double secs1=5;
          double secs2=0;
          double playersecs1 = player.getMediaTime().getSeconds();
          Time settime1;
          if((playersecs1 - secs1) > secs2){
                  settime1 = new javax.media.Time(playersecs1 - secs1);
                  player.setMediaTime(settime1);
          }else {
                    player.setMediaTime(new Time(0));
     public void st() {
     player.start();
     public void sp() {
     player.stop();
   public void itemStateChanged (ItemEvent e)
      loop = !loop;
}

Thank u Thompson For your kind reply. I got the problem solved. It was the the problem of Untrusted Applet as u said.Now i Have signed my applet and this appletplayer plays audio only from the server from where this applet comes and from the localmachine also.Now it is playing fine from the server.
But i have another problem , If i am asking that in the wrong forum plz forgive, I will ask it it in applet forum also.
Problem is , I have implemented a joystick with this player. The idea is to combine this player with a text editor so that user can hear audio at the same time he can type in the editor what he hear and he can rewind and forward using joystick(It is actually a footswitch controller) with his leg. This driver i got from Source forgenet works fine in my localmachine and localnetwork also.But i have to install .DLL file in every client machine. This should be avoided.When a client having no jmf and joystick in his machine tries to run this applet through the browser the required Joystick driver and jmf must be installed in client computer also.
By signing the applet and using ARCHIVE keyword i think jmf part will be ok but what about joystick driver.How i could install it in client machine.Playerapplet throws jjstck.dll not found exception
plz guide me
manu

Similar Messages

  • Play music from internet over aiport express connected speakers

    I am playing my Itunes music via Airport Express over connected speakers successfully. Is it also possible to play music from internet over these airport express connected speakers? For example playing the sounds of a video over the speakers which are connected to the Airport Express? Thx in advance for any helpfull suggestions.

    Does Airfoil do what you want?
    (48253)

  • I have a docking station to charge and play audio from my ipod touch 3rd gen.  Just bought a new ipod touch 5 th gen.  Is there a converter/ adapter available so I can continue to use my dock?

    I have a docking station to charge and play audio from my ipod touch 3rd gen.  Is there an adapter available for the ipod touch 5th gen so that I can keep using the old dock?

    Lightning  Adopters
    One of these adopters/cables should work:
    http://store.apple.com/us/product/MD824ZM/A/lightning-to-30-pin-adapter-02-m?fno de=45
    http://store.apple.com/us/product/MD823ZM/A/lightning-to-30-pin-adapter?fnode=45

  • Cannot hear audio from internet video. Can hear DVD. Help!

    Cannot hear audio from internet video.  Can hear DVD.  I don't know what I changed in msconfig start up.

    Hi,
    The first thing I would suggest is to run through the guide by Daniel_Potyrala on the link below to completely uninstall and then reinstall the Flash Player Plug-in.
    http://h30434.www3.hp.com/t5/Notebook-Display-and-Video/The-solution-to-most-problems-with-the-Flash...
    Regards,
    DP-K
    ****Click the White thumb to say thanks****
    ****Please mark Accept As Solution if it solves your problem****
    ****I don't work for HP****
    Microsoft MVP - Windows Experience

  • How do I play audio from my headphone jack and internal speakers?

    How do I play audio from my headphone jack and internal speakers at the same time ? I have a splitter for my audio jack so that when i connect up my second monitor I can have it so it also plays audio as well as anything else i have connected into the jack but how do i let the internal speakers emit sound at the same time?

    Hello,
    If you mean the internal speakers in your Mac, you can't play audio through them at the same time you have anything plugged into the headphone jack. When you plug something into the headphone jack, it disconnects the internal speakers.

  • Satellite L-50 can't play audio from multiple sources

    I can't play audio from multiple sources. This is very annoying when I have 2 youtube videos playing, if I start playing something on the media player, there is no sound on media player, it's the same when I have 2 media players open and 1 youtube video playing, youtube video doesn't have sound..
    I already have all the latest drivers, last DTS driver update was in 2014, sound update this year's february..
    25/02/14
    DTS Studio Sound
    DTS Inc.
    Windows 8.1 - 64 Bit
    1.01.2700
     I don't know if this makes sense, but I got newer DTS sound driver which I found, It's not my laptop model, but they all seem to be the same - v1.1.88.0 
    I uninstalled DTS software and still had the same problem, so it's not affecting sound driver in any way..
    10/02/15
    Sound Driver
    Integrated Device Technology Inc.
    Windows 8.1 - 64 Bit
    6.10.6491.0
    IDT audio driver has newer release date, but the driver version is the same as the 2013 one..
    Why are toshiba releaseing old driver as 'NEW' ?
    2nd is my speakers advanced settings, nothing changed when I disabled "Allow applications to take exclusive control of this device"
    Attachments:
    audio.png ‏6 KB
    test2.png ‏7 KB
    specs.png ‏16 KB

    Can you check the full model and part number from the laptop?
    - Peter

  • Satellite L50-A-19N can't play audio from multiple sources

    I can't play audio from multiple sources. This is very annoying when I have 2 youtube videos playing, if I start playing something on the media player, there is no sound on media player, it's the same when I have 2 media players open and 1 youtube video playing, youtube video doesn't have sound..
    It goes away when I plug out my headphones..
    I already have all the latest drivers, last DTS driver update was in 2014, sound update this year's february..
    25/02/14
    DTS Studio Sound
    DTS Inc.
    Windows 8.1 - 64 Bit
    1.01.2700
    I don't know if this makes sense, but I got newer DTS sound driver which I found, It's not my laptop model, but they all seem to be the same - v1.1.88.0
    I uninstalled DTS software and still had the same problem, so it's not affecting sound driver in any way..
    10/02/15
    Sound Driver
    Integrated Device Technology Inc.
    Windows 8.1 - 64 Bit
    6.10.6491.0
    IDT audio driver has newer release date, but the driver version is the same as the 2013 one..
    Why are toshiba releaseing old driver as 'NEW' ?
    2nd is my speakers advanced settings, nothing changed when I disabled "Allow applications to take exclusive control of this device"

    I see that the option called “give exclusive mode applications priority” has been checked.
    Usually different applications and programs can access the sound card simultaneously.
    For example: you can hear the sound in game, while you can run your own music via an external player.
    This is prevented with these options “give exclusive mode applications priority”.
    Maybe you should disable (uncheck) this option to prevent the different applications for using this exclusive mode stream.
    I did it for my DAC. I set the DAC for exclusive mode. Once my audio playback software starts to play music, no other software is able to share the DAC.
    However, I use Win 7 and Realtek sound driver… It’s another configuration.
    So it’s not known to me if your issue is related Win 8.1 system or maybe limitation of sound driver… it could be also possible that one of your sound applications don’t allow multiple sound streaming.

  • IPhone 4S keeps playing audio from a video file that is no longer on my phone.

    If I'm listening to music and try to change tracks or pause with the earbud buttons the music fades out and starts playing audio from a video file. It will only play about 3-4 seconds and then stop. This also will happen when double clicking the home button to try and change tracks. When I do that the track skipping buttons won't work and there's no title for the short bit of audio that plays. The only way to get music to start playing again is to go into music and press play again. The music I had been listening to is sitting there paused. The audio from the mystery video file still sometimes plays even when you're in music and the only way you would know is the little play icon at the top right part of the screen. I have removed every video off of my phone and it still does it. This is really frustrating.

    Sounds like a bad battery.  You'll need to bring the phone into Apple for evaluation.
    I'm sure you've been using your phone as designed and properly backing up your data, so you should have minimal, if any data loss should the phone need to be replaced.

  • Using a first gen iPad.  Video and audio from internet sites simply stopped working all of a sudden.  Any suggestions?  Thanks.

    Using a first gen iPad.  Video and audio from internet sites simply stopped working all of a sudden.  Any suggestions?  Thanks.

    1)access the router web ui
    2)go to the Mac Address Clone subtab , enable it and click "Clone" . Save the settings
    3)do a power cycle
    4)check whether the router gets an internet ip add now ..

  • Is it possible to play audio from video in the background while using a different app?

    I would like to be ale to play audio from a video file in videos (or av player hd) in the background whie using a diffent app in my iPad 2. (ie watching a video while taking notes on the content or highlighting an e-textbook).
    Is this possible? Either through the original iPad functionality or by downloading a separate app?
    Thanks,
    mji

    Is it important that the music come from a video, or are you just looking to listen to music in the background, while doing something else.  If the later, you can certainly play music from the Music App, Pandora, or iHeart Radio, etc., and with the music playing, tap your home button to go to your home page and open anything else you want and the music will continue.
    I don't have any videos to try out right now, but you try the same thing out and if the music continues, it works.  If it doesn't, it doesn't.

  • 5G Plays Audio From Movies But No Video

    I can play audio from all the movies downloaded to my Ipod, but it plays no video. I purchased some music videos from itunes, still the same problem. Any help would be great.
    Thanks
    Gateway   Windows XP  

    Are you watching on the iPod or TV? Is TV output on or off?
    2.0GHZ G5/533MHz G4 DeskTop/400MHz G4 PB   Mac OS X (10.4.3)  

  • In-ear headphones playing audio from one side only

    My apple in-ear headphones only play audio from one side.  I've tried replacing the cap and mesh; and also tested the headphones on different devices and still get the same problem.  Any advice?

    Probably time to have them replaced.
    B-rock

  • HT4072 Can I play audio from movies in the DVD player using iTunes or Airplay?

    I would like to play audio from movies in the MacBook DVD player using iTunes or Airplay? Is this possible?

    Is it important that the music come from a video, or are you just looking to listen to music in the background, while doing something else.  If the later, you can certainly play music from the Music App, Pandora, or iHeart Radio, etc., and with the music playing, tap your home button to go to your home page and open anything else you want and the music will continue.
    I don't have any videos to try out right now, but you try the same thing out and if the music continues, it works.  If it doesn't, it doesn't.

  • How can I play music through safari specifically youtube on my Mac book pro over soundlink to my bose wireless speaker I can only play audio from itunes at present? HELP PLEASE!

    How can I play music through safari specifically youtube on my Mac book pro over soundlink to my bose wireless speaker I can only play audio from itunes at present? HELP PLEASE!

    Should be able to go into your sound preferences and choose your output device, you can also try downloading Airfoil and try that, it's a pretty cool app.

  • Recorded Meeting plays audio from connect url but offline does not

    Hello,
    I recorded my meeting using audio from telephone conference (which is a nice new feature for 7.5 if not using one of the supported phone conferencing systems).  When I play the recording from the adobe connect site URL (or choose edit) the audio plays.  When I do a "make offline" it creates the presentation only with no audio.  Is this a limitation that I did not read about or am I doing something wrong?
    thank you

    use this code "Component control = player.getVisualComponent(); "
    instead of this code " Component control = player.getControlPanelComponent();"
    But if you want show both of them, modify as following
    Component control1 = player.getControlPanelComponent();
    Component control2 = player.getVisualComponent();
    then add the two control (control1 & control2 ) to your JFrame panel

Maybe you are looking for

  • How to handle BLOB field in receiver JDBC adapter into ABAP table

    Dear Experts, I am working in a synchronous scenario with Sender ABAP Proxy to Oracle Database as receiver via SAP PO 7.4.I will be calling a stored procedure view with fields ID, NAME,Age,*** and BLOB (Image binary). 1. The response from Oracle Data

  • Tests with Speech-to-Text transcription in PPro CS5

    As a follow up to my earlier thread about the apparently reworked or, at least, enhanced speech transcription capability in PPro CS5, I just conducted a few tests to see if it is indeed any better than what we had come to expect of it from CS4. The r

  • Camera for mac mini

    I am looking for a camera that will work with Photo Booth on a Mac Mini, OS X 10.8.2, 2.5 GHz i5, 4GB.  I have the IceCam2, but that does not work with moving backgrounds (e.g., rollercoaster).

  • Change "to equal" to "to be greater than" in Wait for Field to equal Value"

    In Sharepoint Designer 2010, in the workflow Action "Wait for Field to equal Value", I could change the "to equal" to "to be greater than". I can't find how to do this in SPD 2013. Can someone please help? Thank you!

  • Displaying Screen After the Add Button is pressed and the document is saved

    Hi All, I am trying to the Display the Landed Cost screen after the Goods Receipt PO has been added and Saved. My code below: <b>If pVal.ItemUID = "1" And pVal.FormTypeEx = "143" And pVal.FormMode = SAPbouiCOM.BoFormMode.fm_ADD_MODE And pVal.BeforeAc