<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!-- NewPage --> <html lang="en"> <head> <!-- Generated by javadoc (1.8.0_77) on Fri Apr 22 13:47:01 UTC 2016 --> <title>javafx.scene.media (JavaFX 8)</title> <meta name="date" content="2016-04-22"> <link rel="stylesheet" type="text/css" href="../../../stylesheet.css" title="Style"> <script type="text/javascript" src="../../../script.js"></script> </head> <body> <script type="text/javascript"><!-- try { if (location.href.indexOf('is-external=true') == -1) { parent.document.title="javafx.scene.media (JavaFX 8)"; } } catch(err) { } //--> </script> <noscript> <div>JavaScript is disabled on your browser.</div> </noscript> <!-- ========= START OF TOP NAVBAR ======= --> <div class="topNav"><a name="navbar.top"> <!-- --> </a> <div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div> <a name="navbar.top.firstrow"> <!-- --> </a> <ul class="navList" title="Navigation"> <li><a href="../../../overview-summary.html">Overview</a></li> <li class="navBarCell1Rev">Package</li> <li>Class</li> <li><a href="package-use.html">Use</a></li> <li><a href="package-tree.html">Tree</a></li> <li><a href="../../../deprecated-list.html">Deprecated</a></li> <li><a href="../../../index-all.html">Index</a></li> <li><a href="../../../help-doc.html">Help</a></li> </ul> <div class="aboutLanguage">JavaFX 8</div> </div> <div class="subNav"> <ul class="navList"> <li><a href="../../../javafx/scene/layout/package-summary.html">Prev Package</a></li> <li><a href="../../../javafx/scene/paint/package-summary.html">Next Package</a></li> </ul> <ul class="navList"> <li><a href="../../../index.html?javafx/scene/media/package-summary.html" target="_top">Frames</a></li> <li><a href="package-summary.html" target="_top">No Frames</a></li> </ul> <ul class="navList" id="allclasses_navbar_top"> <li><a href="../../../allclasses-noframe.html">All Classes</a></li> </ul> <div> <script type="text/javascript"><!-- allClassesLink = document.getElementById("allclasses_navbar_top"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } //--> </script> </div> <a name="skip.navbar.top"> <!-- --> </a></div> <!-- ========= END OF TOP NAVBAR ========= --> <div class="header"> <h1 title="Package" class="title">Package javafx.scene.media</h1> <div class="docSummary"> <div class="block">Provides the set of classes for integrating audio and video into Java FX Applications.</div> </div> <p>See: <a href="#package.description">Description</a></p> </div> <div class="contentContainer"> <ul class="blockList"> <li class="blockList"> <table class="typeSummary" border="0" cellpadding="3" cellspacing="0" summary="Interface Summary table, listing interfaces, and an explanation"> <caption><span>Interface Summary</span><span class="tabEnd"> </span></caption> <tr> <th class="colFirst" scope="col">Interface</th> <th class="colLast" scope="col">Description</th> </tr> <tbody> <tr class="altColor"> <td class="colFirst"><a href="../../../javafx/scene/media/AudioSpectrumListener.html" title="interface in javafx.scene.media">AudioSpectrumListener</a></td> <td class="colLast"> <div class="block">Audio spectrum callback interface.</div> </td> </tr> </tbody> </table> </li> <li class="blockList"> <table class="typeSummary" border="0" cellpadding="3" cellspacing="0" summary="Class Summary table, listing classes, and an explanation"> <caption><span>Class Summary</span><span class="tabEnd"> </span></caption> <tr> <th class="colFirst" scope="col">Class</th> <th class="colLast" scope="col">Description</th> </tr> <tbody> <tr class="altColor"> <td class="colFirst"><a href="../../../javafx/scene/media/AudioClip.html" title="class in javafx.scene.media">AudioClip</a></td> <td class="colLast"> <div class="block">An <code>AudioClip</code> represents a segment of audio that can be played with minimal latency.</div> </td> </tr> <tr class="rowColor"> <td class="colFirst"><a href="../../../javafx/scene/media/AudioEqualizer.html" title="class in javafx.scene.media">AudioEqualizer</a></td> <td class="colLast"> <div class="block">The <code>AudioEqualizer</code> class provides audio equalization control for a media player.</div> </td> </tr> <tr class="altColor"> <td class="colFirst"><a href="../../../javafx/scene/media/AudioTrack.html" title="class in javafx.scene.media">AudioTrack</a></td> <td class="colLast"> <div class="block">A <a href="../../../javafx/scene/media/Track.html" title="class in javafx.scene.media"><code>Track</code></a> that describes an audio track.</div> </td> </tr> <tr class="rowColor"> <td class="colFirst"><a href="../../../javafx/scene/media/EqualizerBand.html" title="class in javafx.scene.media">EqualizerBand</a></td> <td class="colLast"> <div class="block">The <code>EqualizerBand</code> class provides control for each band in the <a href="../../../javafx/scene/media/AudioEqualizer.html" title="class in javafx.scene.media"><code>AudioEqualizer</code></a>.</div> </td> </tr> <tr class="altColor"> <td class="colFirst"><a href="../../../javafx/scene/media/Media.html" title="class in javafx.scene.media">Media</a></td> <td class="colLast"> <div class="block">The <code>Media</code> class represents a media resource.</div> </td> </tr> <tr class="rowColor"> <td class="colFirst"><a href="../../../javafx/scene/media/MediaErrorEvent.html" title="class in javafx.scene.media">MediaErrorEvent</a></td> <td class="colLast"> <div class="block">An <a href="../../../javafx/event/Event.html" title="class in javafx.event"><code>Event</code></a> representing the occurrence of an error in handling media.</div> </td> </tr> <tr class="altColor"> <td class="colFirst"><a href="../../../javafx/scene/media/MediaMarkerEvent.html" title="class in javafx.scene.media">MediaMarkerEvent</a></td> <td class="colLast"> <div class="block">An <a href="../../../javafx/event/ActionEvent.html" title="class in javafx.event"><code>ActionEvent</code></a> representing a media marker.</div> </td> </tr> <tr class="rowColor"> <td class="colFirst"><a href="../../../javafx/scene/media/MediaPlayer.html" title="class in javafx.scene.media">MediaPlayer</a></td> <td class="colLast"> <div class="block">The <code>MediaPlayer</code> class provides the controls for playing media.</div> </td> </tr> <tr class="altColor"> <td class="colFirst"><a href="../../../javafx/scene/media/MediaView.html" title="class in javafx.scene.media">MediaView</a></td> <td class="colLast"> <div class="block">A <a href="../../../javafx/scene/Node.html" title="class in javafx.scene"><code>Node</code></a> that provides a view of <a href="../../../javafx/scene/media/Media.html" title="class in javafx.scene.media"><code>Media</code></a> being played by a <a href="../../../javafx/scene/media/MediaPlayer.html" title="class in javafx.scene.media"><code>MediaPlayer</code></a>.</div> </td> </tr> <tr class="rowColor"> <td class="colFirst"><a href="../../../javafx/scene/media/SubtitleTrack.html" title="class in javafx.scene.media">SubtitleTrack</a></td> <td class="colLast"> <div class="block">A <a href="../../../javafx/scene/media/Track.html" title="class in javafx.scene.media"><code>Track</code></a> that contains subtitle or captioning data to be rendered overlaying a video track.</div> </td> </tr> <tr class="altColor"> <td class="colFirst"><a href="../../../javafx/scene/media/Track.html" title="class in javafx.scene.media">Track</a></td> <td class="colLast"> <div class="block">A class representing a track contained in a media resource.</div> </td> </tr> <tr class="rowColor"> <td class="colFirst"><a href="../../../javafx/scene/media/VideoTrack.html" title="class in javafx.scene.media">VideoTrack</a></td> <td class="colLast"> <div class="block">A <a href="../../../javafx/scene/media/Track.html" title="class in javafx.scene.media"><code>Track</code></a> that describes a video track.</div> </td> </tr> </tbody> </table> </li> <li class="blockList"> <table class="typeSummary" border="0" cellpadding="3" cellspacing="0" summary="Enum Summary table, listing enums, and an explanation"> <caption><span>Enum Summary</span><span class="tabEnd"> </span></caption> <tr> <th class="colFirst" scope="col">Enum</th> <th class="colLast" scope="col">Description</th> </tr> <tbody> <tr class="altColor"> <td class="colFirst"><a href="../../../javafx/scene/media/MediaException.Type.html" title="enum in javafx.scene.media">MediaException.Type</a></td> <td class="colLast"> <div class="block">Enumeration describing categories of errors.</div> </td> </tr> <tr class="rowColor"> <td class="colFirst"><a href="../../../javafx/scene/media/MediaPlayer.Status.html" title="enum in javafx.scene.media">MediaPlayer.Status</a></td> <td class="colLast"> <div class="block">Enumeration describing the different status values of a <a href="../../../javafx/scene/media/MediaPlayer.html" title="class in javafx.scene.media"><code>MediaPlayer</code></a>.</div> </td> </tr> </tbody> </table> </li> <li class="blockList"> <table class="typeSummary" border="0" cellpadding="3" cellspacing="0" summary="Exception Summary table, listing exceptions, and an explanation"> <caption><span>Exception Summary</span><span class="tabEnd"> </span></caption> <tr> <th class="colFirst" scope="col">Exception</th> <th class="colLast" scope="col">Description</th> </tr> <tbody> <tr class="altColor"> <td class="colFirst"><a href="../../../javafx/scene/media/MediaException.html" title="class in javafx.scene.media">MediaException</a></td> <td class="colLast"> <div class="block">A <code>MediaException</code> describes a runtime error condition in a <a href="../../../javafx/scene/media/Media.html" title="class in javafx.scene.media"><code>Media</code></a>, <a href="../../../javafx/scene/media/MediaPlayer.html" title="class in javafx.scene.media"><code>MediaPlayer</code></a> or <a href="../../../javafx/scene/media/MediaView.html" title="class in javafx.scene.media"><code>MediaView</code></a>.</div> </td> </tr> </tbody> </table> </li> </ul> <a name="package.description"> <!-- --> </a> <h2 title="Package javafx.scene.media Description">Package javafx.scene.media Description</h2> <div class="block"><p>Provides the set of classes for integrating audio and video into Java FX Applications. The primary use for this package is media playback. There are three principal classes in the media package: <a href="../../../javafx/scene/media/Media.html" title="class in javafx.scene.media"><code>Media</code></a>, <a href="../../../javafx/scene/media/MediaPlayer.html" title="class in javafx.scene.media"><code>MediaPlayer</code></a>, and <a href="../../../javafx/scene/media/MediaView.html" title="class in javafx.scene.media"><code>MediaView</code></a>. </p> <h2>Contents</h2> <p> <ol> <li><a href="#SupportedMediaTypes">Supported Media Types</a></li> <li><a href="#SupportedProtocols">Supported Protocols</a></li> <li><a href="#SupportedMetadataTags">Supported Metadata Tags</a></li> <li><a href="#PlayingMediaInJavaFX">Playing Media in Java FX</a></li> </ol> </p> <a name="SupportedMediaTypes"/> <h3>Supported Media Types</h3> Java FX supports a number of different media types. A media type is considered to be the combination of a container format and one or more encodings. In some cases the container format might simply be an elementary stream containing the encoded data. <h4>Supported Encoding Types</h4> An encoding type specifies how sampled audio or video data are stored. Usually the encoding type implies a particular compression algorithm. The following table indicates the encoding types supported by Java FX Media. <p> <table border="1" summary="encoding types"> <tr><th>Encoding</th><th>Type</th><th>Description</th></tr> <tr><td>AAC</td><td>Audio</td><td>Advanced Audio Coding audio compression</td></tr> <tr><td>MP3</td><td>Audio</td> <td>Raw MPEG-1, 2, and 2.5 audio; layers I, II, and III; all supported combinations of sampling frequencies and bit rates. Note: File must contain at least 3 MP3 frames.</td> </tr> <tr><td>PCM</td><td>Audio</td><td>Uncompressed, raw audio samples</td></tr> <tr><td>H.264/AVC</td><td>Video</td><td>H.264/MPEG-4 Part 10 / AVC (Advanced Video Coding) video compression</td></tr> <tr><td>VP6</td><td>Video</td><td>On2 VP6 video compression</td></tr> </table> </p> <h4>Supported Container Types</h4> A container type specifies the file format used to store the encoded audio, video, and other media data. Each container type is associated with one or more MIME types, file extensions, and file signatures (the initial bytes in the file). The following table indicates the combination of container and encoding types supported by Java FX Media. <p> <table border="1" summary="container and encoding types combination"> <tr><th>Container</th><th>Description</th><th>Video Encoding</th> <th>Audio Encoding</th><th>MIME Type</th><th>File Extension</th></tr> <tr><td>AIFF</td><td>Audio Interchange File Format</td><td>N/A</td> <td>PCM</td><td>audio/x-aiff</td><td>.aif, .aiff</td></tr> <tr><td>FXM, FLV</td><td>FX Media, Flash Video</td><td>VP6</td> <td>MP3</td><td>video/x-javafx, video/x-flv</td><td>.fxm, .flv</td></tr> <tr><td>HLS (*)</td><td>MP2T HTTP Live Streaming (audiovisual)</td><td>H.264/AVC</td> <td>AAC</td><td>application/vnd.apple.mpegurl, audio/mpegurl</td><td>.m3u8</td></tr> <tr><td>HLS (*)</td><td>MP3 HTTP Live Streaming (audio-only)</td><td>N/A</td> <td>MP3</td><td>application/vnd.apple.mpegurl, audio/mpegurl</td><td>.m3u8</td></tr> <tr><td>MP3</td><td>MPEG-1, 2, 2.5 raw audio stream possibly with ID3 metadata v2.3 or v2.4</td> <td>N/A</td><td>MP3</td><td>audio/mpeg</td><td>.mp3</td></tr> <tr><td>MP4</td><td>MPEG-4 Part 14</td><td>H.264/AVC</td> <td>AAC</td><td>video/mp4, audio/x-m4a, video/x-m4v</td><td>.mp4, .m4a, .m4v</td></tr> <tr><td>WAV</td><td>Waveform Audio Format</td><td>N/A</td> <td>PCM</td><td>audio/x-wav</td><td>.wav</td></tr> </table> <br/>(*) HLS is a protocol rather than a container type but is included here to aggregate similar attributes. </p> <a name="SupportedProtocols"/> <h3>Supported Protocols</h3> <p> <table border="1" summary="supported protocols"> <tr><th>Protocol</th><th>Description</th><th>Reference</th></tr> <tr> <td>FILE</td> <td>Protocol for URI representation of local files</td> <td><a href="https://docs.oracle.com/javase/8/docs/api/java/net/URI.html">java.net.URI</a></td> </tr> <tr> <td>HTTP</td> <td>Hypertext transfer protocol for representation of remote files</td> <td><a href="https://docs.oracle.com/javase/8/docs/api/java/net/URI.html">java.net.URI</a></td> </tr> <td>HTTPS</td> <td>Hypertext transfer protocol secure for representation of remote files</td> <td><a href="https://docs.oracle.com/javase/8/docs/api/java/net/URI.html">java.net.URI</a></td> </tr> <tr> <tr> <td>JAR</td> <td>Representation of media entries in files accessible via the FILE, HTTP or HTTPS protocols</td> <td><a href="https://docs.oracle.com/javase/8/docs/api/java/net/JarURLConnection.html">java.net.JarURLConnection</a></td> </tr> <tr> <td>HTTP Live Streaming (HLS)</td> <td>Playlist-based media streaming via HTTP or HTTPS</td> <td><a href="http://tools.ietf.org/html/draft-pantos-http-live-streaming">Internet-Draft: HTTP Live Streaming</a></td> </tr> </table> <br/> </p> <p> <h4>MPEG-4 Playback via HTTP</h4> It is recommended that MPEG-4 media to be played over HTTP or HTTPS be formatted such that the headers required to decode the stream appear at the beginning of the file. Otherwise, playback might stall until the entire file is downloaded. </p> <p> <h4>HTTP Live Streaming (HLS)</h4> HLS playback handles sources with these characteristics: <ul> <li>On-demand and live playlists.</li> <li>Elementary MP3 audio streams (audio/mpegurl) and multiplexed MP2T streams (application/vnd.apple.mpegurl) with one AAC audio and one H.264/AVC video track.</li> <li>Playlists with integer or float duration.</li> </ul> Sources which do not conform to this basic profile are not guaranteed to be handled. The playlist contains information about the streams comprising the source and is downloaded at the start of playback. Switching between alternate streams, bit rates, and video resolutions is handled automatically as a function of network conditions. </p> <a name="SupportedMetadataTags"/> <h3>Supported Metadata Tags</h3> A media container may also include certain metadata which describe the media in the file. The Java FX Media API makes the metadata available via the <a href="../../../javafx/scene/media/Media.html#getMetadata--"><code>Media.getMetadata()</code></a> method. The keys in this mapping are referred to as <i>tags</i> with the tags supported by Java FX Media listed in the following table. Note that which tags are available for a given media source depend on the metadata actually stored in that source, i.e., not all tags are guaranteed to be available. <p> <table border="1" summary="metadata keys and tags"> <tr><th> Container </th><th> Tag (type String) </th><th> Type </th><th> Description </th></tr> <tr><td> FXM, FLV </td><td> audio codec </td><td> java.lang.String </td><td>The encoder used for the audio track.</td></tr> <tr><td> FXM, FLV </td><td> duration </td><td> javafx.util.Duration </td><td>The duration of the media.</td></tr> <tr><td> FXM, FLV </td><td> video codec </td><td> java.lang.String </td><td>The encoder used for the video track.</td></tr> <tr><td> FXM, FLV </td><td> width </td><td> java.lang.Integer </td><td>The width in pixels of the video track.</td></tr> <tr><td> FXM, FLV </td><td> height </td><td> java.lang.Integer </td><td>The height in pixels of the video track.</td></tr> <tr><td> FXM, FLV </td><td> framerate </td><td> java.lang.Double </td><td>The video frame rate in frames per second.</td></tr> <tr><td> FXM, FLV </td><td> creationdate </td><td> java.lang.String </td><td>The date when the video was created.</td></tr> <tr><td> FXM, FLV, MP3 </td><td> raw metadata </td><td> Map<String,ByteBuffer> </td><td>The raw metadata according to the appropriate media specification. The key "ID3" maps to MP3 ID3v2 metadata and "FLV" to the FLV onMetadata marker content.</td></tr> <tr><td> MP3 </td><td> album artist </td><td> java.lang.String </td><td>The artist for the overall album, possibly "Various Artists" for compilations.</td></tr> <tr><td> MP3 </td><td> album </td><td> java.lang.String </td><td>The name of the album.</td></tr> <tr><td> MP3 </td><td> artist </td><td> java.lang.String </td><td>The artist of the track.</td></tr> <tr><td> MP3 </td><td> comment-N </td><td> java.lang.String </td><td>A comment where N is a 0-relative index. Comment format: ContentDescription[lng]=Comment </td></tr> <tr><td> MP3 </td><td> composer </td><td> java.lang.String </td><td>The composer of the track.</td></tr> <tr><td> MP3 </td><td> year </td><td> java.lang.Integer </td><td>The year the track was recorded.</td></tr> <tr><td> MP3 </td><td> disc count </td><td> java.lang.Integer </td><td>The number of discs in the album.</td></tr> <tr><td> MP3 </td><td> disc number </td><td> java.lang.Integer </td><td>The 1-relative index of the disc on which this track appears.</td></tr> <tr><td> MP3 </td><td> duration </td><td> javafx.util.Duration </td><td>The duration of the track.</td></tr> <tr><td> MP3 </td><td> genre </td><td> java.lang.String </td><td>The genre of the track, for example, "Classical," "Darkwave," or "Jazz."</td></tr> <tr><td> MP3 </td><td> image </td><td> javafx.scene.image.Image </td><td>The album cover.</td></tr> <tr><td> MP3 </td><td> title </td><td> java.lang.String </td><td>The name of the track.</td></tr> <tr><td> MP3 </td><td> track count </td><td> java.lang.Integer </td><td>The number of tracks on the album.</td></tr> <tr><td> MP3 </td><td> track number </td><td> java.lang.Integer </td><td>The 1-relative index of this track on the disc.</td></tr> </table> </p> <p> <a name="PlayingMediaInJavaFX"/> <h3>Playing Media in Java FX</h3> <h4>Basic Playback</h4> <p> The basic steps required to play media in Java FX are: <ol> <li>Create a <a href="../../../javafx/scene/media/Media.html" title="class in javafx.scene.media"><code>Media</code></a> object for the desired media source.</li> <li>Create a <a href="../../../javafx/scene/media/MediaPlayer.html" title="class in javafx.scene.media"><code>MediaPlayer</code></a> object from the <code>Media</code> object.</li> <li>Create a <a href="../../../javafx/scene/media/MediaView.html" title="class in javafx.scene.media"><code>MediaView</code></a> object.</li> <li>Add the <code>MediaPlayer</code> to the <code>MediaView</code>.</li> <li>Add the <code>MediaView</code> to the scene graph.</li> <li>Invoke <a href="../../../javafx/scene/media/MediaPlayer.html#play--"><code>MediaPlayer.play()</code></a>.</li> </ol> The foregoing steps are illustrated by the sample code in the <code>MediaView</code> class documentation. Some things which should be noted are: <ul> <li>One <code>Media</code> object may be shared among multiple <code>MediaPlayer</code>s. <li>One <code>MediaPlayer</code> may be shared amoung multiple <code>MediaView</code>s. <li>Media may be played directly by a <code>MediaPlayer</code> without creating a <code>MediaView</code> although a view is required for display.</li> <li>Instead of <code>MediaPlayer.play()</code>, <a href="../../../javafx/scene/media/MediaPlayer.html#setAutoPlay-boolean-"><code>MediaPlayer.setAutoPlay(true)</code></a> may be used to request that playing start as soon as possible.</li> <li><code>MediaPlayer</code> has several operational states defined by <a href="../../../javafx/scene/media/MediaPlayer.Status.html" title="enum in javafx.scene.media"><code>MediaPlayer.Status</code></a>. <li>Audio-only media may instead be played using <a href="../../../javafx/scene/media/AudioClip.html" title="class in javafx.scene.media"><code>AudioClip</code></a> (recommended for low latency playback of short clips).</li> </ul> </p> <h4>Error Handling</h4> <p> Errors using Java FX Media may be either synchronous or asynchronous. In general synchronous errors will manifest themselves as a Java <code>Exception</code> and asynchronous errors will cause a Java FX property to be set. In the latter case either the <code>error</code> property may be observed directly, an <code>onError</code> callback registered, or possibly both.</p> <p>The main sources of synchronous errors are <a href="../../../javafx/scene/media/Media.html#Media-java.lang.String-"><code>Media()</code></a> and <a href="../../../javafx/scene/media/MediaPlayer.html#MediaPlayer-javafx.scene.media.Media-"><code>MediaPlayer()</code></a>. The asynchronous error properties are <a href="../../../javafx/scene/media/Media.html#errorProperty--"><code>Media.error</code></a> and <a href="../../../javafx/scene/media/MediaPlayer.html#errorProperty--"><code>MediaPlayer.error</code></a>, and the asynchronous error callbacks <a href="../../../javafx/scene/media/Media.html#onErrorProperty--"><code>Media.onError</code></a>, <a href="../../../javafx/scene/media/MediaPlayer.html#onErrorProperty--"><code>MediaPlayer.onError</code></a>, and <a href="../../../javafx/scene/media/MediaView.html#onErrorProperty--"><code>MediaView.onError</code></a>.</p> <p> Some errors might be duplicated. For example, a <code>MediaPlayer</code> will propagate an error that it encounters to its associated <code>Media</code>, and a <code>MediaPlayer</code> to all its associated <code>MediaView</code>s. As a consequence, it is possible to receive multiple notifications of the occurrence of a given error, depending on which properties are monitored. </p> <p>The following code snippet illustrates error handling with media: <code><pre> String source; Media media; MediaPlayer mediaPlayer; MediaView mediaView; try { media = new Media(source); if (media.getError() == null) { media.setOnError(new Runnable() { public void run() { // Handle asynchronous error in Media object. } }); try { mediaPlayer = new MediaPlayer(media); if (mediaPlayer.getError() == null) { mediaPlayer.setOnError(new Runnable() { public void run() { // Handle asynchronous error in MediaPlayer object. } }); mediaView = new MediaView(mediaPlayer); mediaView.setOnError(new EventHandler<MediaErrorEvent>() { public void handle(MediaErrorEvent t) { // Handle asynchronous error in MediaView. } }); } else { // Handle synchronous error creating MediaPlayer. } } catch (Exception mediaPlayerException) { // Handle exception in MediaPlayer constructor. } } else { // Handle synchronous error creating Media. } } catch (Exception mediaException) { // Handle exception in Media constructor. } </pre></code> </p> </p></div> </div> <!-- ======= START OF BOTTOM NAVBAR ====== --> <div class="bottomNav"><a name="navbar.bottom"> <!-- --> </a> <div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div> <a name="navbar.bottom.firstrow"> <!-- --> </a> <ul class="navList" title="Navigation"> <li><a href="../../../overview-summary.html">Overview</a></li> <li class="navBarCell1Rev">Package</li> <li>Class</li> <li><a href="package-use.html">Use</a></li> <li><a href="package-tree.html">Tree</a></li> <li><a href="../../../deprecated-list.html">Deprecated</a></li> <li><a href="../../../index-all.html">Index</a></li> <li><a href="../../../help-doc.html">Help</a></li> </ul> <div class="aboutLanguage">JavaFX 8</div> </div> <div class="subNav"> <ul class="navList"> <li><a href="../../../javafx/scene/layout/package-summary.html">Prev Package</a></li> <li><a href="../../../javafx/scene/paint/package-summary.html">Next Package</a></li> </ul> <ul class="navList"> <li><a href="../../../index.html?javafx/scene/media/package-summary.html" target="_top">Frames</a></li> <li><a href="package-summary.html" target="_top">No Frames</a></li> </ul> <ul class="navList" id="allclasses_navbar_bottom"> <li><a href="../../../allclasses-noframe.html">All Classes</a></li> </ul> <div> <script type="text/javascript"><!-- allClassesLink = document.getElementById("allclasses_navbar_bottom"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } //--> </script> </div> <a name="skip.navbar.bottom"> <!-- --> </a></div> <!-- ======== END OF BOTTOM NAVBAR ======= --> <p class="legalCopy"><small><small><a href="https://docs.oracle.com/javase/8/docs/legal/cpyr.html">Copyright</a> (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.</small></small></p> </body> </html>