Skip to content

Commit 33ca703

Browse files
david-allisonlukstbit
authored andcommitted
refactor(deps): replace androidx.media with media3
androidx.media:1.8.0 is deprecated
1 parent f219ab5 commit 33ca703

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

AnkiDroid/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,6 @@ dependencies {
418418
implementation libs.androidx.exifinterface
419419
implementation libs.androidx.fragment.ktx
420420
implementation libs.androidx.lifecycle.process
421-
implementation libs.androidx.media
422421
implementation libs.androidx.preference.ktx
423422
implementation libs.androidx.recyclerview
424423
implementation libs.androidx.sqlite.framework

AnkiDroid/src/main/java/com/ichi2/anki/cardviewer/SoundTagPlayer.kt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,18 @@
1717
package com.ichi2.anki.cardviewer
1818

1919
import android.content.Context
20-
import android.media.AudioAttributes
2120
import android.media.AudioManager
2221
import android.media.MediaPlayer
2322
import android.net.Uri
2423
import androidx.annotation.CheckResult
24+
import androidx.annotation.OptIn
2525
import androidx.annotation.VisibleForTesting
2626
import androidx.core.net.toUri
27-
import androidx.media.AudioFocusRequestCompat
28-
import androidx.media.AudioManagerCompat
27+
import androidx.media3.common.AudioAttributes
28+
import androidx.media3.common.C.AUDIO_CONTENT_TYPE_MUSIC
29+
import androidx.media3.common.audio.AudioFocusRequestCompat
30+
import androidx.media3.common.audio.AudioManagerCompat
31+
import androidx.media3.common.util.UnstableApi
2932
import com.ichi2.anki.AnkiDroidApp
3033
import com.ichi2.anki.CollectionManager.withCol
3134
import com.ichi2.anki.common.annotations.NeedsTest
@@ -39,6 +42,7 @@ import kotlin.coroutines.resume
3942
import kotlin.coroutines.resumeWithException
4043

4144
/** Player for (`[sound:...]`): [SoundOrVideoTag] */
45+
@OptIn(UnstableApi::class)
4246
@NeedsTest("CardSoundConfig.autoplay should mean that video also isn't played automatically")
4347
class SoundTagPlayer(
4448
private val soundUriBase: String,
@@ -49,7 +53,7 @@ class SoundTagPlayer(
4953
private val music =
5054
AudioAttributes
5155
.Builder()
52-
.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
56+
.setContentType(AUDIO_CONTENT_TYPE_MUSIC)
5357
.build()
5458

5559
/**
@@ -118,7 +122,7 @@ class SoundTagPlayer(
118122
} else {
119123
(soundUriBase + Uri.encode(tag.filename)).toUri()
120124
}
121-
setAudioAttributes(music)
125+
setAudioAttributes(music.platformAudioAttributes)
122126
setOnErrorListener { mp, what, extra ->
123127
Timber.w("Media error %d", what)
124128
abandonAudioFocus()

gradle/libs.versions.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ androidxExifinterface = "1.4.2"
4343
androidxFragmentKtx = "1.8.9"
4444
# https://developer.android.com/jetpack/androidx/releases/lifecycle
4545
androidxLifecycleProcess = "2.10.0"
46-
# https://developer.android.com/jetpack/androidx/releases/media
47-
androidxMedia = "1.7.1"
4846
# https://developer.android.com/jetpack/androidx/releases/media3
4947
androidxMedia3 = "1.10.0"
5048
# https://developer.android.com/jetpack/androidx/releases/preference
@@ -146,7 +144,6 @@ androidx-media3-ui = { module = "androidx.media3:media3-ui", version.ref = "andr
146144
androidx-media3-exoplayer-dash = { module = "androidx.media3:media3-exoplayer-dash", version.ref = "androidxMedia3" }
147145
androidx-media3-exoplayer = { module = "androidx.media3:media3-exoplayer", version.ref = "androidxMedia3" }
148146
androidx-preference-ktx = { module = "androidx.preference:preference-ktx", version.ref = "androidxPreferenceKtx" }
149-
androidx-media = { module = "androidx.media:media", version.ref = "androidxMedia" }
150147
androidx-uiautomator = { module = "androidx.test.uiautomator:uiautomator", version.ref = "androidxTestUiAutomator" }
151148
androidx-webkit = { module = "androidx.webkit:webkit", version.ref = "androidxWebkit" }
152149
androidx-viewpager2 = { module = "androidx.viewpager2:viewpager2", version.ref = "androidxViewpager2" }

0 commit comments

Comments
 (0)