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.2.0 required aar.
Additional AAR 1.2.0

Functionality :
  • CreateUriSource
  • CreateSmoothStreamingSource
  • CreateHLSSource
  • CreateDashSource
  • CreateFileSource
  • CreateRtspStreamingSource
  • CreateRtmpStreamingSource
  • CreateUdpStreamingSource
  • PlayList
  • clearMediaItems
  • CreateListSource[Deprecated].
  • 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.2.0

I may add more features to this library..
 

Attachments

  • addoMedia3-V-1.3.zip
    19 KB · Views: 94
Last edited:

byz

Member
Licensed User
hi, thanks your great work。could you add a function to play by index for CreateListSource?
and another question:when play by CreateListSource the complete event are one or list?
 

Addo

Well-Known Member
Licensed User
Version 1.3
  • Updated Media3 to latest version 1.2.0
  • Removed CreateListSource Method since ConcatenatingMediaSource is deprecated in version 1.2.0.
  • Added a new method PlayList to adapt the new mechanism to play a list of mediasources in the new version.
  • Added a new method clearMediaItems.
Example Updated as well.
its required to redownload the AAR files from the link in the first post.
 
Last edited:
Top