Android Question ExoPlayer Audio detect?

Discussion in 'Android Questions' started by cooperlegend, Aug 13, 2019 at 9:30 AM.

  1. cooperlegend

    cooperlegend Active Member Licensed 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?
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Code:
    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
     
  3. cooperlegend

    cooperlegend Active Member Licensed User

    Perfect, many thanks :)
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice