This is how I Initialize ExoPlayer:
I also need to add AudioFocus handling by ExoPlayer.
This is my Kotlin code from some other project:
in this line player.setAudioAttributes(audioAttributes, true), TRUE instruct ExoPlayer to handle audio focus.
How can I translate this two lines in B4a?
B4X:
Dim jopl As JavaObject
jopl.InitializeNewInstance(Application.PackageName & ".srvplayer$MySimpleExoPlayerWrapper", Null)
Player = jopl
Player.Initialize("Player")
#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, "UserAgent/1.0 (Linux;Android 10.0)");
}
}
#End If
This is my Kotlin code from some other project:
Java:
val audioAttributes = AudioAttributes.Builder().setUsage(C.USAGE_MEDIA).setContentType(C.CONTENT_TYPE_MUSIC).build()
player.setAudioAttributes(audioAttributes, true)
How can I translate this two lines in B4a?