Android Question ExoPlayer Audio detect?

cooperlegend

Active Member
Licensed User
Longtime User
Hi, I am using the ExoPlayer library and need a method to find out of the current video to play contains an audio track or not (because if it has I need to mute the streaming radio) if there a method of detecting if the media has audio or not?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
B4X:
Sub Player_TrackChanged
   Dim jo As JavaObject = player1
   Dim TrackGroups As JavaObject = jo.GetFieldJO("player").RunMethod("getCurrentTrackGroups", Null)
   For i = 0 To TrackGroups.GetField("length") - 1
       Dim TrackGroup As JavaObject = TrackGroups.RunMethod("get", Array(i))
       For j = 0 To TrackGroup.GetField("length") - 1
           Dim Format As JavaObject = TrackGroup.RunMethodJO("getFormat", Array(j))
           Dim mime As String = Format.GetField("sampleMimeType")
           Log(mime)
           If mime.StartsWith("audio") Then
               Log("audio track")
           End If
           
       Next
   Next
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…