B4A Library addoMedia3 - AndroidX Media3 Exoplayer Wrapper

This library is wrapper for the new AndroidX Media3 Library which is based on Exoplayer You can still use my previous wrapper.
Since from now on the new updates and releases will be Published to AndroidX Media3 Library. so i migrate the whole wrapper to the new codebase.

Version 1.3.1 required aar.
Additional AAR 1.3.1

Functionality :
  • CreateUriSource
  • CreateSmoothStreamingSource
  • CreateHLSSource
  • CreateDashSource
  • CreateFileSource
  • CreateRtspStreamingSource
  • CreateRtmpStreamingSource
  • CreateUdpStreamingSource
  • clearMediaItems
  • CreateListSource
  • setReapeatMode
  • getIsPlaying
  • Prepare
  • Play
  • Pause
  • Release
  • getPosition
  • setPosition
  • getDuration
  • getVolume
  • setVolume
  • getCurrentMediaItemIndex
  • GetvideoFormatwidth
  • GetvideoFormatHeight
  • GetAudioTracksLanguages
  • GetVideoTrackSubtitles
  • preferedAudioLanguage
  • preferedtextLanguage
  • EnableSubtitles
  • PlaybackSpeed

DesignerProperties
  • Media3PlayerView
  • ResizeMode [FIT|FIXED_HEIGHT|FIXED_WIDTH]
  • UseController default is true
  • ShowBuffering [NEVER|PLAYING|ALWAYS] default is NEVER
  • ControllerTimeout default is 5000
Events :
  • Player_Ready
  • Player_Error
  • Player_Complete
  • Player_MetaData(metadataFields As Map)
  • IDLE
  • Buffering
Library and Example attached. Don't forget to download the required media3 aars, have a good day.

Updated to version 1.3

Added

  • TrackMetadata
  • PlaybackSpeed
B4X:
Sub Player_Ready
    addoPlayer.TrackMetadata
    Log("Ready")
End Sub

'example of calling th event

Sub Player_MetaData(metadataFields As Map)
    Log(metadataFields)
    Label1.Text = ""
    If metadataFields.ContainsKey("Title") Then
        Label1.Text = metadataFields.Get("Title")
    End If
    ' Handle the metadata fields here
    If metadataFields.ContainsKey("ArtworkData") Then
        Dim artworkData() As Byte = metadataFields.Get("ArtworkData")
        ' Create an InputStream from the byte array
        Dim inp As InputStream
        inp.InitializeFromBytesArray(artworkData, 0, artworkData.Length)
        ' Create a Bitmap from the InputStream
        Dim bitmap As Bitmap
        bitmap.Initialize2(inp)
        ImageView1.Bitmap = bitmap
        ImageView1.Visible = True
    End If
End Sub

Updated Media3 to the latest 1.3.1

Updated to version 1.4

  • Fixes an incompatibility between ExoPlayer and Firebase. Make sure to update the additional libs package.
updated to version 1.6
  • Updated the dependencies to be compatible with b4a 13+
  • removed PlayList replaced with CreateListSource
updated to version 1.7
  • Added a new view addoMedia3TexureView based on TextureView.
  • Added GetVideoTextLanguages2
  • Added GetAudioTracksLanguages2
  • Added SetTextLanguage2
  • SetAudioLanguage2
  • Added Event_GetVideoTextLanguages2(Subtitles As Map)
  • Added Event_Getaudiolanguages2(audiotracks As Map)
As mentioned in this thread there was issue on setting and retrieving the correct supported languages for audio and subtitles use GetVideoTextLanguages2 and GetAudioTracksLanguages2 to retrieve the correct language information.

The TextureView is a new view added to gives the ability to rotate the player as mentioned here. the down side of using textureview that the subtitle in videos will not be visible.

updated to version 1.8

in this update addoMedia3 and addoMedia3TexureView has a new method and event.

  • Added a new method takeScreenshot.
  • Added a new event OnScreenShot(screensrc() As Byte)

updated to version 1.9

  • Removed the internal dependencies so you can add them selectively as #AdditionalJar in b4a IDE
Example:
#Region Additional libs

#AdditionalJar: addoexo/media3-common-1.3.1.aar
#AdditionalJar: addoexo/media3-container-1.3.1.aar
#AdditionalJar: addoexo/media3-database-1.3.1.aar
#AdditionalJar: addoexo/media3-datasource-1.3.1.aar
#AdditionalJar: addoexo/media3-datasource-rtmp-1.3.1.aar
#AdditionalJar: addoexo/media3-decoder-1.3.1.aar
#AdditionalJar: addoexo/media3-exoplayer-1.3.1.aar
#AdditionalJar: addoexo/media3-exoplayer-dash-1.3.1.aar
#AdditionalJar: addoexo/media3-cast-1.3.1.aar
#AdditionalJar: addoexo/media3-exoplayer-hls-1.3.1.aar
#AdditionalJar: addoexo/media3-exoplayer-rtsp-1.3.1.aar
#AdditionalJar: addoexo/media3-exoplayer-smoothstreaming-1.3.1.aar
#AdditionalJar: addoexo/media3-extractor-1.3.1.aar
#AdditionalJar: addoexo/media3-ui-1.3.1.aar
#AdditionalJar: addoexo/rtmp-client-3.2.0.aar
#AdditionalJar: addoexo/guava-31.1-android-without-listenable.jar
#AdditionalJar: androidx.recyclerview:recyclerview
#AdditionalJar: androidx.customview:customview-poolingcontainer
#AdditionalJar: androidx.media:media
#AdditionalJar: com.google.guava:listenablefuture
#AdditionalJar: androidx.tracing:tracing-android
#AdditionalJar: androidx.collection:collection
#End Region

Example Updated to describe the usage of both views.

Important Note Additional aar files must be place in a folder with name addoexo.


I may add more features to this library..
 

Attachments

  • addoMedia3-V-1.9.zip
    35 KB · Views: 735
  • librtmp-client-for-android.zip
    167.5 KB · Views: 4
Last edited by a moderator:

Scantech

Well-Known Member
Licensed User
Longtime User
B4X:
#AdditionalJar: androidx.tracing:tracing-android
#AdditionalJar: androidx.collection:collection
These 2 jars are required to work with latest sdk 36
 

Lucian Gontila

Member
Licensed User
Longtime User
Hello! I have made an app that plays only an online radio station audio stream. The stream is loaded with .CreateUriSource(). Can you tell me please which of the #AdditionalJar can I exclude? Or maybe which is necessarly to be included? Which one of the list is shorter... :)
 

Addo

Well-Known Member
Licensed User
Longtime User
hey fellas long time no see. I have noticed that the old RTMP Client Library the Media3 uses which is located here is no longer friendly with the new requirements of Play store. therefore i have used the latest compiled aar which is uses the solution posted on the GitHub itself.

B4X:
  implementation("androidx.media3:media3-datasource-rtmp:1.6.1") {
    exclude("io.antmedia", "rtmp-client")
  }
  implementation("com.github.mcxinyu:LibRtmp-Client-for-Android:v3.2.0.m2")

the aar file attached in the first post you might need to exclude the "io.antmedia", "rtmp-client" as mentioned in the github solution.
 

byz

Active Member
Licensed User
hey fellas long time no see. I have noticed that the old RTMP Client Library the Media3 uses which is located here is no longer friendly with the new requirements of Play store. therefore i have used the latest compiled aar which is uses the solution posted on the GitHub itself.

B4X:
  implementation("androidx.media3:media3-datasource-rtmp:1.6.1") {
    exclude("io.antmedia", "rtmp-client")
  }
  implementation("com.github.mcxinyu:LibRtmp-Client-for-Android:v3.2.0.m2")

the aar file attached in the first post you might need to exclude the "io.antmedia", "rtmp-client" as mentioned in the github solution.
Can it be updated to the latest media3? It supports RTSP265
 

Scantech

Well-Known Member
Licensed User
Longtime User
I hope it fixes 16 KB memory page sizes required. I will try it. Thanks


1 message for version code 96

Error
Your app does not support 16 KB memory page sizes. Learn More
 
Last edited:

Scantech

Well-Known Member
Licensed User
Longtime User
Its fixed!

Remove from region and rtmp-client-3.2.0.aar in \Program Files\Anywhere Software\B4A\Libraries\addoexo\
B4X:
#AdditionalJar: addoexo/rtmp-client-3.2.0.aar

Add to region
B4X:
#AdditionalJar: addoexo/librtmp-client-for-android.aar
add the file librtmp-client-for-android.aar to :\Program Files\Anywhere Software\B4A\Libraries\addoexo\
You can't use both files.

I uploaded it to google console, the 16KB Page error is gone. That new librtmp-client-for-android.aar fixes it.
 
Last edited:
Top