Class Media

    • Constructor Detail

      • Media

        public Media​(ILibVLC ILibVLC,
                     String path)
        Create a Media from libVLC and a local path starting with '/'.
        Parameters:
        ILibVLC - a valid libVLC
        path - an absolute local path
      • Media

        public Media​(ILibVLC ILibVLC,
                     Uri uri)
        Create a Media from libVLC and a Uri
        Parameters:
        ILibVLC - a valid libVLC
        uri - a valid RFC 2396 Uri
      • Media

        public Media​(ILibVLC ILibVLC,
                     FileDescriptor fd)
        Create a Media from libVLC and a FileDescriptor
        Parameters:
        ILibVLC - a valid LibVLC
        fd - file descriptor object
      • Media

        public Media​(ILibVLC ILibVLC,
                     AssetFileDescriptor afd)
        Create a Media from libVLC and an AssetFileDescriptor
        Parameters:
        ILibVLC - a valid LibVLC
        afd - asset file descriptor object
      • Media

        protected Media​(IMediaList ml,
                        int index)
        Parameters:
        ml - Should not be released and locked
        index - index of the Media from the MediaList
    • Method Detail

      • onEventNative

        protected IMedia.Event onEventNative​(int eventType,
                                             long arg1,
                                             long arg2,
                                             float argf1,
                                             @Nullable
                                             String args1)
        Called when libvlc send events.
        Parameters:
        eventType - event type
        arg1 - first argument
        arg2 - second argument
        argf1 - first float argument
        Returns:
        Event that will be dispatched to listeners
      • getUri

        public Uri getUri()
        Get the MRL associated with the Media.
        Specified by:
        getUri in interface IMedia
      • getDuration

        public long getDuration()
        Get the duration of the media.
        Specified by:
        getDuration in interface IMedia
      • getState

        public int getState()
        Get the state of the media.
        Specified by:
        getState in interface IMedia
        See Also:
        IMedia.State
      • subItems

        public MediaList subItems()
        Get the subItems MediaList associated with the Media. This Media should be alive (not released).
        Specified by:
        subItems in interface IMedia
        Returns:
        subItems as a MediaList. This MediaList should be released with IVLCObject.release().
      • parse

        public boolean parse​(int flags)
        Parse the media synchronously with a flag. This Media should be alive (not released).
        Specified by:
        parse in interface IMedia
        Parameters:
        flags - see IMedia.Parse
        Returns:
        true in case of success, false otherwise.
      • parse

        public boolean parse()
        Parse the media and local art synchronously. This Media should be alive (not released).
        Specified by:
        parse in interface IMedia
        Returns:
        true in case of success, false otherwise.
      • parseAsync

        public boolean parseAsync​(int flags,
                                  int timeout)
        Parse the media asynchronously with a flag. This Media should be alive (not released). To track when this is over you can listen to IMedia.Event.ParsedChanged event (only if this methods returned true).
        Specified by:
        parseAsync in interface IMedia
        Parameters:
        flags - see IMedia.Parse
        timeout - maximum time allowed to preparse the media. If -1, the default "preparse-timeout" option will be used as a timeout. If 0, it will wait indefinitely. If > 0, the timeout will be used (in milliseconds).
        Returns:
        true in case of success, false otherwise.
      • parseAsync

        public boolean parseAsync​(int flags)
        Specified by:
        parseAsync in interface IMedia
      • parseAsync

        public boolean parseAsync()
        Parse the media and local art asynchronously. This Media should be alive (not released).
        Specified by:
        parseAsync in interface IMedia
        See Also:
        parseAsync(int)
      • isParsed

        public boolean isParsed()
        Returns true if the media is parsed This Media should be alive (not released).
        Specified by:
        isParsed in interface IMedia
      • getType

        public int getType()
        Get the type of the media
        Specified by:
        getType in interface IMedia
      • getTrackCount

        public int getTrackCount()
        Get the Track count.
        Specified by:
        getTrackCount in interface IMedia
      • getMeta

        public String getMeta​(int id)
        Get a Meta.
        Specified by:
        getMeta in interface IMedia
        Parameters:
        id - see IMedia.Meta
        Returns:
        meta or null if not found
      • getMeta

        public String getMeta​(int id,
                              boolean force)
        Get a Meta.
        Specified by:
        getMeta in interface IMedia
        Parameters:
        id - see IMedia.Meta
        force - force the native call to be done
        Returns:
        meta or null if not found
      • setHWDecoderEnabled

        public void setHWDecoderEnabled​(boolean enabled,
                                        boolean force)
        Add or remove hw acceleration media options
        Specified by:
        setHWDecoderEnabled in interface IMedia
        Parameters:
        enabled - if true, hw decoder will be used
        force - force hw acceleration even for unknown devices
      • setDefaultMediaPlayerOptions

        public void setDefaultMediaPlayerOptions()
        Enable HWDecoder options if not already set
        Specified by:
        setDefaultMediaPlayerOptions in interface IMedia
      • addOption

        public void addOption​(String option)
        Add an option to this Media. This Media should be alive (not released).
        Specified by:
        addOption in interface IMedia
        Parameters:
        option - ":option" or ":option=value"
      • addSlave

        public void addSlave​(IMedia.Slave slave)
        Add a slave to the current media. A slave is an external input source that may contains an additional subtitle track (like a .srt) or an additional audio track (like a .ac3). This function must be called before the media is parsed (via parseAsync(int)} or before the media is played (via MediaPlayer.play())
        Specified by:
        addSlave in interface IMedia
      • getSlaves

        @Nullable
        public IMedia.Slave[] getSlaves()
        Get a media's slave list The list will contain slaves parsed by VLC or previously added by addSlave(Slave). The typical use case of this function is to save a list of slave in a database for a later use.
        Specified by:
        getSlaves in interface IMedia
      • getStats

        @Nullable
        public IMedia.Stats getStats()
        Get the stats related to the playing media
        Specified by:
        getStats in interface IMedia
      • onReleaseNative

        protected void onReleaseNative()
        Called when native object is released (refcount is 0). This is where you must release native resources.
      • retain

        public final boolean retain()
        Increment internal ref count of the native object.
        Specified by:
        retain in interface IVLCObject<T extends AbstractVLCEvent>
        Returns:
        true if media is retained
      • release

        public final void release()
        Release the native object if ref count is 1. After this call, native calls are not possible anymore. You can still call others methods to retrieve cached values. For example: if you parse, then release a media, you'll still be able to retrieve all Metas or Tracks infos.
        Specified by:
        release in interface IVLCObject<T extends AbstractVLCEvent>
      • finalize

        protected void finalize()
        Overrides:
        finalize in class Object
      • setEventListener

        protected void setEventListener​(AbstractVLCEvent.Listener<T> listener,
                                        Handler handler)
        Set an event listener and an executor Handler
        Parameters:
        listener - see AbstractVLCEvent.Listener
        handler - Handler in which events are sent. If null, a handler will be created running on the main thread
      • getInstance

        public long getInstance()