Android Question ExoPlayer 2 User-agent

Lucas Eduardo

Active Member
Licensed User
Hello, i'm tring to use 2 differents user agent in differents causes. I tried this code, but did'n work.
B4X:
Sub US1
    #if Java
        import anywheresoftware.b4a.keywords.B4AApplication;
        import android.content.pm.PackageManager.NameNotFoundException;
        import anywheresoftware.b4a.objects.SimpleExoPlayerWrapper;
        import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
        public static class MySimpleExoPlayerWrapper extends SimpleExoPlayerWrapper {
        @Override
        public DefaultDataSourceFactory createDefaultDataFactory() {
             return new DefaultDataSourceFactory(BA.applicationContext, "user agent 1");
           }
        }

        #End If   
End Sub

Sub US2
    #if Java
        import anywheresoftware.b4a.keywords.B4AApplication;
        import android.content.pm.PackageManager.NameNotFoundException;
        import anywheresoftware.b4a.objects.SimpleExoPlayerWrapper;
        import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
        public static class MySimpleExoPlayerWrapper extends SimpleExoPlayerWrapper {
        @Override
        public DefaultDataSourceFactory createDefaultDataFactory() {
             return new DefaultDataSourceFactory(BA.applicationContext, "user agent 2");
           }
        }
       
        #End If   
End Sub


Sub Activity_Create(FirstTime As Boolean)
   
    If principal.numero >= 70 Then

        US1
       
        Dim joJ As JavaObject
        joJ.InitializeNewInstance(Application.PackageName & ".abreplayer$MySimpleExoPlayerWrapper", Null)
        player3 = joJ
       
    Else
           
        US2
       
        Dim joJ As JavaObject
        joJ.InitializeNewInstance(Application.PackageName & ".abreplayer$MySimpleExoPlayerWrapper", Null)
        player1 = joJ
           
    End If

Is there a way to use 2 differents user agents?
 
Top