title: JavaFX can't play audio
body: <p>I am working on a music player.  The player works correct on my Windows host, but when I try to run the code on a virtual (VirtualBox) Ubuntu 12 VM I get the following error: </p>
  
  <pre><code>Exception in thread "JavaFX Application Thread" MediaException: UNKNOWN : com.sun.media.jfxmedia.MediaException: Could not create player! : com.sun.media.jfxmedia.MediaException: Could not create player!
      at javafx.scene.media.MediaException.exceptionToMediaException(MediaException.java:146)
      at javafx.scene.media.MediaPlayer.init(MediaPlayer.java:511)
      at javafx.scene.media.MediaPlayer.&lt;init&gt;(MediaPlayer.java:414)
      at musicmaniac.PlayerPane.playSong(PlayerPane.java:142)
      at musicmaniac.PlayerPane.playSelectedSong(PlayerPane.java:180)
      at musicmaniac.SongsPane.lambda$addSongsToVBox$0(SongsPane.java:114)
      at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
      at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
      at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
      at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
      at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
      at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
      at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
      at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
      at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
      at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
      at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
      at javafx.event.Event.fireEvent(Event.java:198)
      at javafx.scene.Scene$MouseHandler.process(Scene.java:3757)
      at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
      at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
      at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
      at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:380)
      at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:294)
      at java.security.AccessController.doPrivileged(Native Method)
      at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$354(GlassViewEventHandler.java:416)
      at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
      at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:415)
      at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
      at com.sun.glass.ui.View.notifyMouse(View.java:937)
      at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
      at com.sun.glass.ui.gtk.GtkApplication.lambda$null$49(GtkApplication.java:139)
      at java.lang.Thread.run(Thread.java:745)
   Caused by: com.sun.media.jfxmedia.MediaException: Could not create player!
      at com.sun.media.jfxmediaimpl.NativeMediaManager.getPlayer(NativeMediaManager.java:274)
      at com.sun.media.jfxmedia.MediaManager.getPlayer(MediaManager.java:118)
      at javafx.scene.media.MediaPlayer.init(MediaPlayer.java:467)
      ... 36 more
  </code></pre>
  
  <p>This is the code that I am running:</p>
  
  <pre><code>/**
   * Plays the passed song and queues the next song.
   * @param song The song to be played
   * @param playSong if the song should start playing. False means the song will be paused.
   */
  private void playSong(Song song, boolean playSong) {   
      // stop current player
      if (mediaPlayer != null) {
          mediaPlayer.stop();
      }
  
  
      Media media = new Media(new File(song.getPath()).toURI().toString());
      mediaPlayer = new MediaPlayer(media);
  
      // Set the song as playing or paused
      if (playSong) {
          mediaPlayer.play();
         Image playImg = new Image(MusicManiac.class.getResourceAsStream("/resources/img/pause.png"));
          playButton.setImage(playImg);
      } else {
          mediaPlayer.pause();
      }
  
      // Set the next song to be played
      mediaPlayer.setOnEndOfMedia(new Runnable() {
          @Override
          public void run() {
              nextSong();
          }
      });
  
      songLabel.setText(song.getName() + "  --  " + song.getArtist());
  }
  </code></pre>
  
  <p>Is there something wrong with my code or is it the VM/Ubuntu?  BTW I checked and it is running on Java8 so that's not the problem.</p>