Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[APT-9564] Clean up deprecated methods in ExoplayerExt #28

Merged
merged 1 commit into from
Dec 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see an equivalent of this in the new code. Is that intentional?

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))
}