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.

Setup:
1. Download the attached library and copy to the additional libraries folder. ExoPlayer is an internal library, starting with B4A v13.4.
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:
B4X:
SimpleExoPlayerView1.Player = Player
4. Create one or more sources with the various "create" methods and call Player.Prepare to load them.

Example is attached.

1703503333084.png


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


Updates:
v3.11 - Added missing dependency (androidx.core:core-ktx)
v3.10 - Updated dependencies. Requires B4A v13.4+ with an updated SDK. This is an internal library now.
v3.02 - Updated dependencies.
v3.01 - Fixes a compatibility issue with Firebase libraries. The dependencies package was updated as well (step #2 above).
 

Attachments

  • ExoPlayerExample.zip
    14.2 KB · Views: 1,447
  • ExoPlayer.zip
    9.3 KB · Views: 85
Last edited:

Toley

Active Member
Licensed User
Longtime User
@Erel Sorry to insist but I was finally able to install it on my Samsung phone running Android 15 and it crash when I press the configuration button and after when I press anywhere. I join a little video to show it. I am almost sure I have followed the installation instructions correctly but maybe it's on my side. Disabling the button could be an acceptable solution since I intent to use it as a GUI for a medical device and the size and model of the tablet is fixed (not a store app).
 

Attachments

  • 20250805_1806138063.zip
    380.3 KB · Views: 86

Abubakar123

New Member
I ran the sample. It compiles and loads onto the device but when line 21 in B4xMainPage is executed the app crashes with error:
Error occurred on line: 21 (B4XMainPage)
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)

if i stop execution in dubug mode on line 21 all is well.

B4A ver. 13.4

I followed the instructions in the first post to get it going.
Any ideas?
Thanks!


fixed it.
files in this post are older.

found the correct ones here: https://www.b4x.com/android/forum/threads/exoplayer-mediaplayer-videoview-alternative.72652/#content
for anyone else using older duplicate files. If you're passionate about editing and looking for an excellent video editing app, give this one a try
Capcut mod apk
Thanks for the update, and glad you figured it out! That kind of crash usually points to a mismatch in library versions or outdated files, so it makes sense. Always good to double-check you're using the latest files from the original post or repo.
 
Top