Class NativeMediaPlayer

  • All Implemented Interfaces:
    com.inmobi.media.videoPlayer.MediaPlayer

    
    public final class NativeMediaPlayer
     implements MediaPlayer
                        

    A class responsible for managing video playback in a native ad.

    This class handles the lifecycle of a video player, including loading, playback, pausing, and completion. It also manages the audio focus, viewability, and progress tracking of the video.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      Flow<VideoEvent> getMediaPlayerFlow() A SharedFlow emitting VideoEvents.
      ViewGroup inflate(List<String> urls) Inflates the media player and loads the video from the provided URLs.
      Unit start() Stops the video playback and related components.
      Unit stop() Stops the video playback and related components.
      Unit destroy() Destroys the media player and releases resources.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • inflate

         ViewGroup inflate(List<String> urls)

        Inflates the media player and loads the video from the provided URLs.

        Parameters:
        urls - The list of video URLs to load.
        Returns:

        The ViewGroup containing the inflated media player.

      • start

         Unit start()

        Stops the video playback and related components.

        This function stops the video progress tracker, detaches surface controller observers, and cancels any active coroutine jobs related to media playback.

      • stop

         Unit stop()

        Stops the video playback and related components.

        This function stops the video progress tracker, detaches surface controller observers, and cancels any active coroutine jobs related to media playback.

      • destroy

         Unit destroy()

        Destroys the media player and releases resources.