Multimedia‎ > ‎

Audio Player


In JavaFX audio has first-class support.  The API to playback audio is located in package javafx.scene.media.  You use two classes to achieve media playback
  • Media - loads or downloads (from remote location) the media source
  • MediaPlayer - plays back the media source and provides control over playback cycle 

The following shows you how to playback an MP3 file:

def mediaSource = "http://streaming.oracle.com/ebn/podcasts/media/8576726_Nandini_Ramani_030210.mp3";

def player = MediaPlayer {
    media:Media{
        source:mediaSource
    }
}

player.play();
The materials on this website represent a small sample of content loosely based on the book JavaFX Application Development Cookbook.  The book offers far more content with over 80 recipes covering a range of topics from basics to advanced concepts.  

Buy the Book

You can get your copy of the book directly from the publisher. Click here to order!