title: Audio Player using MediaPlayer class in JMF
body: <p>JMF provides a class <a href="http://docs.oracle.com/cd/E17802_01/j2se/javase/technologies/desktop/media/jmf/2.1.1/apidocs/javax/media/bean/playerbean/MediaPlayer.html#setMediaLocation%28java.lang.String%29" rel="nofollow"><code>MediaPlayer</code></a> which can be used as a full-featured player. However, I can't find a way to play an audio file. Some snippets of the code used.</p>
  
  <pre><code>import javax.media.bean.playerbean.MediaPlayer;
  
      // ....
      MediaPlayer mp = new MediaPlayer();
      mp.setMediaLocation(location of file);  // &lt;- syntax error!
      mp.start();
  </code></pre>
  
  <p>But it doesn't work. Eclipse shows this error: </p>
  
  <pre><code>Syntax error on token "setMediaLocation", Identifier expected after this token
  </code></pre>
  
  <p>..on <code>setMediaLocation()</code> method. </p>
  
  <p>Can someone tell me how to use <code>MediaPlayer</code> class to play audio file? and what is wrong in my coding?</p>