I have used Exoplayer to play an audio stream. You can see the code below. I am not a professional Android dev, but I know that on android if you want something to run in the background you have to use services. I did not expect this player to play in the background, but it does. My question is. Is this enough will the player work fine in the background, does exoplayer handle bacground mode by default, or will the player be shut down after a while. So is it still necessary to make a service that runs in the background?
private fun setUpPlayer(){
val renderersFactory = DefaultRenderersFactory(this)
val trackSelector = DefaultTrackSelector()
exoPlayer = ExoPlayerFactory.newSimpleInstance(this, renderersFactory, trackSelector)
val userAgent = Util.getUserAgent(this, "FOOBAR")
val mediaSource = ExtractorMediaSource(Uri.parse(radioLink), DefaultDataSourceFactory(this, userAgent), DefaultExtractorsFactory(), null, null)
exoPlayer.prepare(mediaSource)
exoPlayer.playWhenReady = true
}