Package 

Class MediaPlayer

    • Constructor Detail

      • MediaPlayer

        MediaPlayer(ILibVLC ILibVLC)
        Create an empty MediaPlayer
        Parameters:
        ILibVLC - a valid libVLC
      • MediaPlayer

        MediaPlayer(IMedia media)
        Create a MediaPlayer from a Media
        Parameters:
        media - a valid Media object
    • Method Detail

      • detachViews

         void detachViews()

        Detach the video layout

      • updateVideoSurfaces

         void updateVideoSurfaces()

        Update the video surfaces, either to switch from one to another or to resize it

      • hasMedia

         synchronized boolean hasMedia()

        Is a media in use by this MediaPlayer

      • getMedia

        @Nullable() synchronized IMedia getMedia()

        Get the Media used by this MediaPlayer. This Media should be released with release.

      • play

         void play()

        Play the media

      • playAsset

         void playAsset(@NonNull() Context context, @NonNull() String assetFilename)

        Load an asset and starts playback

        Parameters:
        context - An application context, mandatory to access assets
        assetFilename - relative path of the asset in app assets folder
      • play

         void play(@NonNull() String path)

        Play a media via its mrl

        Parameters:
        path - Path of the media file to play
      • play

         void play(@NonNull() Uri uri)

        Play a media via its Uri

        Parameters:
        uri - Uri of the media to play
      • play

         void play(@NonNull() IMedia media)

        Starts playback from an already prepared Media

        Parameters:
        media - The IMedia to play
      • stop

         void stop()

        Stops the playing media

      • setVideoTitleDisplay

         void setVideoTitleDisplay(int position, int timeout)

        Set if, and how, the video title will be shown when media is played

        Parameters:
        position - see Position
      • getScale

         float getScale()

        Get the current video scaling factor

      • setScale

         void setScale(float scale)

        Set the video scaling factorThat is the ratio of the number of pixels on screen to the number of pixels in the originaldecoded video in each dimension. Zero is a special value; it will adjust the video to theoutput window/drawable (in windowed mode) or the entire screen.

        Parameters:
        scale - the scaling factor, or zero
      • setAspectRatio

         void setAspectRatio(String aspect)

        Set new video aspect ratio.

        Parameters:
        aspect - new video aspect-ratio or NULL to reset to default
      • updateViewpoint

         boolean updateViewpoint(float yaw, float pitch, float roll, float fov, boolean absolute)

        Update the video viewpoint information

        Parameters:
        yaw - View point yaw in degrees
        pitch - View point pitch in degrees
        roll - View point roll in degrees
        fov - Field of view in degrees (default 80.
        absolute - if true replace the old viewpoint with the new one.
      • setAudioOutput

         synchronized boolean setAudioOutput(String aout)

        Selects an audio output module.Any change will take effect only after playback is stopped andrestarted. Audio output cannot be changed while playing.By default, the "android_audiotrack" is selected. Starting Android 21, passthrough isenabled for encodings supported by the device/audio system.Calling this method will disable the encoding detection.

      • setAudioDigitalOutputEnabled

         synchronized boolean setAudioDigitalOutputEnabled(boolean enabled)

        Enable or disable Digital OutputWorks only with AudioTrack AudioOutput.If setAudioOutputDevice was previously called, this method won't have any effects.

        Parameters:
        enabled - true to enable Digital Output
      • forceAudioDigitalEncodings

         synchronized boolean forceAudioDigitalEncodings(Array<int> encodings)

        Convenient method for setAudioOutputDevice

        Parameters:
        encodings - list of encodings to play via passthrough (see AudioFormat.ENCODING_*),null to don't force any.
      • setAudioOutputDevice

         boolean setAudioOutputDevice(String id)

        Configures an explicit audio output device.Audio output will be moved to the device specified by the device identifier string.Available devices for the "android_audiotrack" module (the default) are"stereo": Up to 2 channels (compat mode)."pcm": Up to 8 channels."encoded": Up to 8 channels, passthrough for every encodings if available."encoded:ENCODING_FLAGS_MASK": passthrough for every encodings specified byENCODING_FLAGS_MASK. This extra value is a long that contains binary-shiftedAudioFormat.ENCODING_* values.Calling this method will disable the encoding detection (see setAudioOutput and setAudioDigitalOutputEnabled).

      • getChapters

         Array<MediaPlayer.Chapter> getChapters(int title)

        Get the full description of available chapters.

        Parameters:
        title - index of the title (if -1, use the current title)
      • setVideoTrack

         boolean setVideoTrack(int index)

        Set the video track.

      • setVideoTrackEnabled

         void setVideoTrackEnabled(boolean enabled)

        Set the enabled state of the video track

      • setAudioTrack

         boolean setAudioTrack(int index)

        Set the audio track.

      • getAudioDelay

         long getAudioDelay()

        Get the current audio delay.

      • setAudioDelay

         boolean setAudioDelay(long delay)

        Set current audio delay. The audio delay will be reset to zero each time the media changes.

        Parameters:
        delay - in microseconds.
      • getSpuTracksCount

         int getSpuTracksCount()

        Get the number of available spu (subtitle) tracks.

      • getSpuTrack

         int getSpuTrack()

        Get the current spu (subtitle) track.

      • setSpuTrack

         boolean setSpuTrack(int index)

        Set the spu (subtitle) track.

      • getSpuDelay

         long getSpuDelay()

        Get the current spu (subtitle) delay.

      • setSpuDelay

         boolean setSpuDelay(long delay)

        Set current spu (subtitle) delay. The spu delay will be reset to zero each time the media changes.

        Parameters:
        delay - in microseconds.
      • setEqualizer

         boolean setEqualizer(MediaPlayer.Equalizer equalizer)

        Apply new equalizer settings to a media player.The equalizer is first created by invoking create or createFromPreset}.It is possible to apply new equalizer settings to a media player whether the mediaplayer is currently playing media or not.Invoking this method will immediately apply the new equalizer settings to the audiooutput of the currently playing media if there is any.If there is no currently playing media, the new equalizer settings will be appliedlater if and when new media is played.Equalizer settings will automatically be applied to subsequently played media.To disable the equalizer for a media player invoke this method passing null.

      • addSlave

         boolean addSlave(int type, Uri uri, boolean select)

        Add a slave (or subtitle) to the current media player.

        Parameters:
        type - see IMedia.Slave.Type
        uri - a valid RFC 2396 Uri
      • record

         boolean record(String directory)

        Start/stop recording

        Parameters:
        directory - path of the recording directory or null to stoprecording
      • addSlave

         boolean addSlave(int type, String path, boolean select)

        Add a slave (or subtitle) to the current media player.

        Parameters:
        type - see IMedia.Slave.Type
        path - a local path
      • setRate

         native void setRate(float rate)

        Sets the speed of playback (1 being normal speed, 2 being twice as fast)

      • getRate

         native float getRate()

        Get the current playback speed

      • isPlaying

         native boolean isPlaying()

        Returns true if any media is playing

      • isSeekable

         native boolean isSeekable()

        Returns true if any media is seekable

      • pause

         native void pause()

        Pauses any playing media

      • getVolume

         native int getVolume()

        Gets volume as integer

      • setVolume

         native int setVolume(int volume)

        Sets volume as integer

        Parameters:
        volume - : Volume level passed as integer
      • getTime

         native long getTime()

        Gets the current movie time (in ms).

      • setTime

         long setTime(long time, boolean fast)

        Sets the movie time (in ms), if any media is being played.

        Parameters:
        time - : Time in ms.
        fast - : Prefer fast seeking or precise seeking
      • getPosition

         native float getPosition()

        Gets the movie position.

      • setPosition

         void setPosition(float pos, boolean fast)

        Sets the movie position.

        Parameters:
        pos - : movie position.
        fast - : Prefer fast seeking or precise seeking
      • getLength

         native long getLength()

        Gets current movie's length in ms.

      • setTitle

         native void setTitle(int title)
      • navigate

         native void navigate(int navigate)
      • nativeSetTime

         native long nativeSetTime(long time, boolean fast)