Android Question select audios or substitutes that are within the video with exoplayer

nedium

Active Member
Licensed User
Longtime User
Hello everyone and thank you for your help.

Looking a bit about the 'Exoplayer' library, I found the following code where it allows you to see the audio and subtitles that are in the video.

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


When using this code, I find the audio and subtitle tracks, but I don't know how to select any of the audio tracks (Audios of different languages) or the subtitles.
--
I know that 'exoplayer' has the option of being able to change the audio track or select subtitle and make it visible in the current player.

If anyone can help me or give me an idea of how to work with the 'exoplayer' library using Javaobject.

regards
 

nedium

Active Member
Licensed User
Longtime User
Hello

searching the internet I found an example of what I wanted in case I did not know how to express myself previously.

This would be an example of what I would like to add, that you can select any format or track that is within the video.



regards
 
Upvote 0

nedium

Active Member
Licensed User
Longtime User
Hello,

If it works for me with exoplayer in b4x I send a copy of the code I use.

B4X:
 If FirstTime Then
        player1.Initialize("player")
        Dim sources As List
        sources.Initialize
        
        sources.Add(player1.CreateUriSource("http://vod.tuxchannel.tv/peliculas/720/late%20night%202019.mkv"))
        
        player1.Prepare(player1.CreateListSource(sources))   
        
    End If
    Activity.LoadLayout("1")
    SimpleExoPlayerView1.Player = player1
    player1.Play
 
Upvote 0

nedium

Active Member
Licensed User
Longtime User
Hello,

I have been searching the internet regarding the subject, I found some exoplayer code to change the audio or subtitle, I would like to know how I can use this code in b4x

trackSelector.setParameters(
trackSelector
.buildUponParameters()
.setMaxVideoSizeSd()
.setPreferredAudioLanguage("deu"));


I do not know, if it is the right one for what I need but any help is good, greetings
 
Upvote 0

nedium

Active Member
Licensed User
Longtime User
Hello @mehdipass

have you verified that the video has several formats?
I think your code could help me change the audio or subtitles but I don't know how to do it, it would be something similar but with audio or subtitles

I think it does not work for you because if it does not exist, the format does not take it
 
Upvote 0

nedium

Active Member
Licensed User
Longtime User
Hello @mehdipass

Look at this new library that does respond to this previous thread.


 
Upvote 0
Top