/*
* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javafx.scene.media;
import com.sun.media.jfxmedia.MetadataParser;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.FileNotFoundException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javafx.application.Platform;
import javafx.beans.NamedArg;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.ObjectPropertyBase;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.collections.ObservableMap;
import javafx.scene.image.Image;
import javafx.util.Duration;
import com.sun.media.jfxmedia.locator.Locator;
import javafx.beans.property.ReadOnlyIntegerProperty;
import javafx.beans.property.ReadOnlyIntegerWrapper;
import javafx.beans.property.ReadOnlyObjectProperty;
import javafx.beans.property.ReadOnlyObjectWrapper;
import com.sun.media.jfxmedia.events.MetadataListener;
import com.sun.media.jfxmedia.track.VideoResolution;
/**
* The Media
class represents a media resource. It is instantiated
* from the string form of a source URI. Information about the media such as
* duration, metadata, tracks, and video resolution may be obtained from a
* Media
instance. The media information is obtained asynchronously
* and so not necessarily available immediately after instantiation of the class.
* All information should however be available if the instance has been
* associated with a {@link MediaPlayer} and that player has transitioned to
* {@link MediaPlayer.Status#READY} status. To be notified when metadata or
* {@link Track}s are added, observers may be registered with the collections
* returned by {@link #getMetadata()}and {@link #getTracks()}, respectively.
The same Media
object may be shared among multiple
* MediaPlayer
objects. Such a shared instance might manage a single
* copy of the source media data to be used by all players, or it might require a
* separate copy of the data for each player. The choice of implementation will
* not however have any effect on player behavior at the interface level.
error
is non-null
, then the media could not
* be loaded and is not usable. If {@link #onErrorProperty onError} is non-null
,
* it will be invoked when the error
property is set.
*
* @see MediaException
*/
private ReadOnlyObjectWrappernull
if there is no error.
*/
public final MediaException getError() {
return error == null ? null : error.get();
}
public ReadOnlyObjectPropertynull
if none is defined.
*/
public final Runnable getOnError() {
return onError == null ? null : onError.get();
}
public ObjectPropertyObservableList
of tracks contained in this media object.
* A Media
object can contain multiple tracks, such as a video track
* with several audio track. This list is unmodifiable: the contents cannot
* be changed.
* @see Track
*/
private ObservableList