Skip to content

Commit

Permalink
[APT-9564] Clean up deprecated methods in ExoplayerExt
Browse files Browse the repository at this point in the history
  • Loading branch information
kschults committed Dec 6, 2023
1 parent 4abdf58 commit 62f57db
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ import android.content.Context
import com.google.android.exoplayer2.C
import com.google.android.exoplayer2.ExoPlayer
import com.google.android.exoplayer2.RenderersFactory
import com.google.android.exoplayer2.SimpleExoPlayer
import com.google.android.exoplayer2.audio.AudioAttributes
import com.google.android.exoplayer2.audio.AudioCapabilities
import com.google.android.exoplayer2.audio.DefaultAudioSink
import com.google.android.exoplayer2.audio.DefaultAudioSink.DefaultAudioProcessorChain
import com.google.android.exoplayer2.audio.MediaCodecAudioRenderer
import com.google.android.exoplayer2.mediacodec.MediaCodecSelector
import com.google.android.exoplayer2.source.dash.manifest.DashManifest
Expand All @@ -27,6 +25,7 @@ internal fun ExoPlayer.hasProgressAvailable(): Boolean {
else -> m == null && !currentTimeline.isEmpty
}
}

/**
* Current position in relation to all audio files.
*/
Expand All @@ -43,7 +42,7 @@ internal fun ExoPlayer.playerDuration(): Milliseconds? = if (duration == C.TIME_
* We provide our own renderers factory so that Proguard can remove any non-audio rendering code.
*/
internal fun createExoplayerInstance(context: Context, attributes: AudioAttributes): ExoPlayer =
SimpleExoPlayer.Builder(context, createRenderersFactory(context))
ExoPlayer.Builder(context, createRenderersFactory(context))
.build().apply {
setAudioAttributes(attributes, true)
}
Expand All @@ -52,11 +51,12 @@ internal fun createRenderersFactory(context: Context): RenderersFactory =
RenderersFactory { eventHandler, _, audioRendererEventListener, _, _ ->
// Default audio sink taken from DefaultRenderersFactory. We need to provide it in order to enable offloading
// Note that we need to provide a new audio sink for each call - playback fails if we reuse the sink
val audioSink = DefaultAudioSink(
AudioCapabilities.getCapabilities(context),
DefaultAudioProcessorChain(),
false,
true,
DefaultAudioSink.OFFLOAD_MODE_DISABLED)
val audioSink = DefaultAudioSink.Builder()
.setAudioCapabilities(AudioCapabilities.getCapabilities(context))
.setAudioProcessorChain(DefaultAudioSink.DefaultAudioProcessorChain())
.setEnableFloatOutput(false)
.setEnableAudioTrackPlaybackParams(true)
.setOffloadMode(DefaultAudioSink.OFFLOAD_MODE_DISABLED)
.build()
arrayOf(MediaCodecAudioRenderer(context, MediaCodecSelector.DEFAULT, eventHandler, audioRendererEventListener, audioSink))
}

0 comments on commit 62f57db

Please sign in to comment.