IT. Expert System.

Android Reference

MediaMetadataRetriever


android.media

Class MediaMetadataRetriever



  • public class MediaMetadataRetriever
    extends Object
    MediaMetadataRetriever class provides a unified interface for retrieving frame and meta data from an input media file.
    • Field Detail

      • METADATA_KEY_CD_TRACK_NUMBER

        public static final int METADATA_KEY_CD_TRACK_NUMBER
        The metadata key to retrieve the numberic string describing the order of the audio data source on its original recording.
        See Also:
        Constant Field Values
      • METADATA_KEY_ALBUM

        public static final int METADATA_KEY_ALBUM
        The metadata key to retrieve the information about the album title of the data source.
        See Also:
        Constant Field Values
      • METADATA_KEY_ARTIST

        public static final int METADATA_KEY_ARTIST
        The metadata key to retrieve the information about the artist of the data source.
        See Also:
        Constant Field Values
      • METADATA_KEY_AUTHOR

        public static final int METADATA_KEY_AUTHOR
        The metadata key to retrieve the information about the author of the data source.
        See Also:
        Constant Field Values
      • METADATA_KEY_COMPOSER

        public static final int METADATA_KEY_COMPOSER
        The metadata key to retrieve the information about the composer of the data source.
        See Also:
        Constant Field Values
      • METADATA_KEY_DATE

        public static final int METADATA_KEY_DATE
        The metadata key to retrieve the date when the data source was created or modified.
        See Also:
        Constant Field Values
      • METADATA_KEY_GENRE

        public static final int METADATA_KEY_GENRE
        The metadata key to retrieve the content type or genre of the data source.
        See Also:
        Constant Field Values
      • METADATA_KEY_TITLE

        public static final int METADATA_KEY_TITLE
        The metadata key to retrieve the data source title.
        See Also:
        Constant Field Values
      • METADATA_KEY_YEAR

        public static final int METADATA_KEY_YEAR
        The metadata key to retrieve the year when the data source was created or modified.
        See Also:
        Constant Field Values
      • METADATA_KEY_DURATION

        public static final int METADATA_KEY_DURATION
        The metadata key to retrieve the playback duration of the data source.
        See Also:
        Constant Field Values
      • METADATA_KEY_NUM_TRACKS

        public static final int METADATA_KEY_NUM_TRACKS
        The metadata key to retrieve the number of tracks, such as audio, video, text, in the data source, such as a mp4 or 3gpp file.
        See Also:
        Constant Field Values
      • METADATA_KEY_WRITER

        public static final int METADATA_KEY_WRITER
        The metadata key to retrieve the information of the writer (such as lyricist) of the data source.
        See Also:
        Constant Field Values
      • METADATA_KEY_MIMETYPE

        public static final int METADATA_KEY_MIMETYPE
        The metadata key to retrieve the mime type of the data source. Some example mime types include: "video/mp4", "audio/mp4", "audio/amr-wb", etc.
        See Also:
        Constant Field Values
      • METADATA_KEY_ALBUMARTIST

        public static final int METADATA_KEY_ALBUMARTIST
        The metadata key to retrieve the information about the performers or artist associated with the data source.
        See Also:
        Constant Field Values
      • METADATA_KEY_DISC_NUMBER

        public static final int METADATA_KEY_DISC_NUMBER
        The metadata key to retrieve the numberic string that describes which part of a set the audio data source comes from.
        See Also:
        Constant Field Values
      • METADATA_KEY_COMPILATION

        public static final int METADATA_KEY_COMPILATION
        The metadata key to retrieve the music album compilation status.
        See Also:
        Constant Field Values
      • METADATA_KEY_HAS_AUDIO

        public static final int METADATA_KEY_HAS_AUDIO
        If this key exists the media contains audio content.
        See Also:
        Constant Field Values
      • METADATA_KEY_HAS_VIDEO

        public static final int METADATA_KEY_HAS_VIDEO
        If this key exists the media contains video content.
        See Also:
        Constant Field Values
      • METADATA_KEY_VIDEO_WIDTH

        public static final int METADATA_KEY_VIDEO_WIDTH
        If the media contains video, this key retrieves its width.
        See Also:
        Constant Field Values
      • METADATA_KEY_VIDEO_HEIGHT

        public static final int METADATA_KEY_VIDEO_HEIGHT
        If the media contains video, this key retrieves its height.
        See Also:
        Constant Field Values
      • METADATA_KEY_BITRATE

        public static final int METADATA_KEY_BITRATE
        This key retrieves the average bitrate (in bits/sec), if available.
        See Also:
        Constant Field Values
      • METADATA_KEY_TIMED_TEXT_LANGUAGES

        public static final int METADATA_KEY_TIMED_TEXT_LANGUAGES
        This key retrieves the language code of text tracks, if available. If multiple text tracks present, the return value will look like: "eng:chi"
        See Also:
        Constant Field Values
      • METADATA_KEY_IS_DRM

        public static final int METADATA_KEY_IS_DRM
        If this key exists the media is drm-protected.
        See Also:
        Constant Field Values
      • METADATA_KEY_LOCATION

        public static final int METADATA_KEY_LOCATION
        This key retrieves the location information, if available. The location should be specified according to ISO-6709 standard, under a mp4/3gp box "@xyz". Location with longitude of -90 degrees and latitude of 180 degrees will be retrieved as "-90.0000+180.0000", for instance.
        See Also:
        Constant Field Values
      • METADATA_KEY_VIDEO_ROTATION

        public static final int METADATA_KEY_VIDEO_ROTATION
        This key retrieves the video rotation angle in degrees, if available. The video rotation angle may be 0, 90, 180, or 270 degrees.
        See Also:
        Constant Field Values
    • Constructor Detail

      • MediaMetadataRetriever

        public MediaMetadataRetriever()
    • Method Detail

      • setDataSource

        public void setDataSource(String path)
                           throws IllegalArgumentException
        Sets the data source (file pathname) to use. Call this method before the rest of the methods in this class. This method may be time-consuming.
        Parameters:
        path - The path of the input media file.
        Throws:
        IllegalArgumentException - If the path is invalid.
      • setDataSource

        public void setDataSource(String uri,
                         Map<String,String> headers)
                           throws IllegalArgumentException
        Sets the data source (URI) to use. Call this method before the rest of the methods in this class. This method may be time-consuming.
        Parameters:
        uri - The URI of the input media.
        headers - the headers to be sent together with the request for the data
        Throws:
        IllegalArgumentException - If the URI is invalid.
      • setDataSource

        public void setDataSource(FileDescriptor fd,
                         long offset,
                         long length)
                           throws IllegalArgumentException
        Sets the data source (FileDescriptor) to use. It is the caller's responsibility to close the file descriptor. It is safe to do so as soon as this call returns. Call this method before the rest of the methods in this class. This method may be time-consuming.
        Parameters:
        fd - the FileDescriptor for the file you want to play
        offset - the offset into the file where the data to be played starts, in bytes. It must be non-negative
        length - the length in bytes of the data to be played. It must be non-negative.
        Throws:
        IllegalArgumentException - if the arguments are invalid
      • setDataSource

        public void setDataSource(FileDescriptor fd)
                           throws IllegalArgumentException
        Sets the data source (FileDescriptor) to use. It is the caller's responsibility to close the file descriptor. It is safe to do so as soon as this call returns. Call this method before the rest of the methods in this class. This method may be time-consuming.
        Parameters:
        fd - the FileDescriptor for the file you want to play
        Throws:
        IllegalArgumentException - if the FileDescriptor is invalid
      • setDataSource

        public void setDataSource(Context context,
                         Uri uri)
                           throws IllegalArgumentException,
                                  SecurityException
        Sets the data source as a content Uri. Call this method before the rest of the methods in this class. This method may be time-consuming.
        Parameters:
        context - the Context to use when resolving the Uri
        uri - the Content URI of the data you want to play
        Throws:
        IllegalArgumentException - if the Uri is invalid
        SecurityException - if the Uri cannot be used due to lack of permission.
      • extractMetadata

        public String extractMetadata(int keyCode)
        Call this method after setDataSource(). This method retrieves the meta data value associated with the keyCode. The keyCode currently supported is listed below as METADATA_XXX constants. With any other value, it returns a null pointer.
        Parameters:
        keyCode - One of the constants listed below at the end of the class.
        Returns:
        The meta data value associate with the given keyCode on success; null on failure.
      • getFrameAtTime

        public Bitmap getFrameAtTime(long timeUs,
                            int option)
        Call this method after setDataSource(). This method finds a representative frame close to the given time position by considering the given option if possible, and returns it as a bitmap. This is useful for generating a thumbnail for an input data source or just obtain and display a frame at the given time position.
        Parameters:
        timeUs - The time position where the frame will be retrieved. When retrieving the frame at the given time position, there is no guarantee that the data source has a frame located at the position. When this happens, a frame nearby will be returned. If timeUs is negative, time position and option will ignored, and any frame that the implementation considers as representative may be returned.
        option - a hint on how the frame is found. Use OPTION_PREVIOUS_SYNC if one wants to retrieve a sync frame that has a timestamp earlier than or the same as timeUs. Use OPTION_NEXT_SYNC if one wants to retrieve a sync frame that has a timestamp later than or the same as timeUs. Use OPTION_CLOSEST_SYNC if one wants to retrieve a sync frame that has a timestamp closest to or the same as timeUs. Use OPTION_CLOSEST if one wants to retrieve a frame that may or may not be a sync frame but is closest to or the same as timeUs. OPTION_CLOSEST often has larger performance overhead compared to the other options if there is no sync frame located at timeUs.
        Returns:
        A Bitmap containing a representative video frame, which can be null, if such a frame cannot be retrieved.
      • getFrameAtTime

        public Bitmap getFrameAtTime(long timeUs)
        Call this method after setDataSource(). This method finds a representative frame close to the given time position if possible, and returns it as a bitmap. This is useful for generating a thumbnail for an input data source. Call this method if one does not care how the frame is found as long as it is close to the given time; otherwise, please call getFrameAtTime(long, int).
        Parameters:
        timeUs - The time position where the frame will be retrieved. When retrieving the frame at the given time position, there is no guarentee that the data source has a frame located at the position. When this happens, a frame nearby will be returned. If timeUs is negative, time position and option will ignored, and any frame that the implementation considers as representative may be returned.
        Returns:
        A Bitmap containing a representative video frame, which can be null, if such a frame cannot be retrieved.
        See Also:
        getFrameAtTime(long, int)
      • getFrameAtTime

        public Bitmap getFrameAtTime()
        Call this method after setDataSource(). This method finds a representative frame at any time position if possible, and returns it as a bitmap. This is useful for generating a thumbnail for an input data source. Call this method if one does not care about where the frame is located; otherwise, please call getFrameAtTime(long) or getFrameAtTime(long, int)
        Returns:
        A Bitmap containing a representative video frame, which can be null, if such a frame cannot be retrieved.
        See Also:
        getFrameAtTime(long), getFrameAtTime(long, int)
      • getEmbeddedPicture

        public byte[] getEmbeddedPicture()
        Call this method after setDataSource(). This method finds the optional graphic or album/cover art associated associated with the data source. If there are more than one pictures, (any) one of them is returned.
        Returns:
        null if no such graphic is found.
      • release

        public void release()
        Call it when one is done with the object. This method releases the memory allocated internally.
      • finalize

        protected void finalize()
                         throws Throwable
        Description copied from class: Object
        Invoked when the garbage collector has detected that this instance is no longer reachable. The default implementation does nothing, but this method can be overridden to free resources.

        Note that objects that override finalize are significantly more expensive than objects that don't. Finalizers may be run a long time after the object is no longer reachable, depending on memory pressure, so it's a bad idea to rely on them for cleanup. Note also that finalizers are run on a single VM-wide finalizer thread, so doing blocking work in a finalizer is a bad idea. A finalizer is usually only necessary for a class that has a native peer and needs to call a native method to destroy that peer. Even then, it's better to provide an explicit close method (and implement Closeable), and insist that callers manually dispose of instances. This works well for something like files, but less well for something like a BigInteger where typical calling code would have to deal with lots of temporaries. Unfortunately, code that creates lots of temporaries is the worst kind of code from the point of view of the single finalizer thread.

        If you must use finalizers, consider at least providing your own ReferenceQueue and having your own thread process that queue.

        Unlike constructors, finalizers are not automatically chained. You are responsible for calling super.finalize() yourself.

        Uncaught exceptions thrown by finalizers are ignored and do not terminate the finalizer thread. See Effective Java Item 7, "Avoid finalizers" for more.

        Overrides:
        finalize in class Object
        Throws:
        Throwable


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 1557 / 96487356. Delta: 0.05237 с