B4A Library ExoPlayer (media3) - video player

ExoPlayer is a powerful media player created by Google: https://developer.android.com/guide/topics/media/exoplayer

This version is based on Media3 ExoPlayer v1.2. It replaces ExoPlayer 2: https://www.b4x.com/android/forum/threads/exoplayer-mediaplayer-videoview-alternative.72652/#content
The underlying SDK isn't backward compatible so calls with JavaObject may not work without modifications.

1. Download the attached library and copy to the additional libraries folder.
2. Download the additional dependencies and copy to the additional libraries folder: https://www.b4x.com/android/files/exoplayer3_additional.zip

Usage instructions:
1. Add a SimpleExoPlayerView with the designer.
2. Declare and initialize a SimpleExoPlayer object.
3. Set the player:
SimpleExoPlayerView1.Player = Player
4. Create one or more sources with the various "create" methods and call Player.Prepare to load them.

Example is attached.


Note that you can use SMM to manage and load videos: [B4X] SimpleMediaManager (SMM) - framework for images, videos and more

This is a beta version.

v3.01 - Fixes a compatibility issue with Firebase libraries. The dependencies package was updated as well (step #2 above).


  • ExoPlayerExample.zip
    14.2 KB · Views: 256
  • ExoPlayer.zip
    9.3 KB · Views: 254
Last edited:


Well-Known Member
Licensed User
Longtime User
Is there exoplayer-additional_libs? I have only get the old version.


B4X founder
Staff member
Licensed User
Longtime User
You can use this:
Private Sub CreateUriSource(Uri As String) As Object
    Dim ctxt As JavaObject
    Dim DataSource As JavaObject = HttpDataSourceFactory.RunMethod("createDataSource", Null)

    DataSource.RunMethod("setRequestProperty", Array("header", "value")) 'set headers here

    Dim DataSourceFactory As JavaObject = ctxt.CreateEvent("androidx.media3.datasource.DataSource.Factory", "", DataSource)
    Dim ProgressiveMediaSourceFactory As JavaObject
    ProgressiveMediaSourceFactory.InitializeNewInstance("androidx.media3.exoplayer.source.ProgressiveMediaSource.Factory", Array(DataSourceFactory))
    Dim MediaItem As JavaObject
    Return ProgressiveMediaSourceFactory.RunMethod("createMediaSource", Array(MediaItem.RunMethod("fromUri", Array(Uri))))
End Sub