Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion AnkiDroid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,6 @@ dependencies {
implementation libs.androidx.exifinterface
implementation libs.androidx.fragment.ktx
implementation libs.androidx.lifecycle.process
implementation libs.androidx.media
implementation libs.androidx.preference.ktx
implementation libs.androidx.recyclerview
implementation libs.androidx.sqlite.framework
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,18 @@
package com.ichi2.anki.cardviewer

import android.content.Context
import android.media.AudioAttributes
import android.media.AudioManager
import android.media.MediaPlayer
import android.net.Uri
import androidx.annotation.CheckResult
import androidx.annotation.OptIn
import androidx.annotation.VisibleForTesting
import androidx.core.net.toUri
import androidx.media.AudioFocusRequestCompat
import androidx.media.AudioManagerCompat
import androidx.media3.common.AudioAttributes
import androidx.media3.common.C.AUDIO_CONTENT_TYPE_MUSIC
import androidx.media3.common.audio.AudioFocusRequestCompat
import androidx.media3.common.audio.AudioManagerCompat
import androidx.media3.common.util.UnstableApi
import com.ichi2.anki.AnkiDroidApp
import com.ichi2.anki.CollectionManager.withCol
import com.ichi2.anki.common.annotations.NeedsTest
Expand All @@ -39,6 +42,7 @@ import kotlin.coroutines.resume
import kotlin.coroutines.resumeWithException

/** Player for (`[sound:...]`): [SoundOrVideoTag] */
@OptIn(UnstableApi::class)
@NeedsTest("CardSoundConfig.autoplay should mean that video also isn't played automatically")
class SoundTagPlayer(
private val soundUriBase: String,
Expand All @@ -49,7 +53,7 @@ class SoundTagPlayer(
private val music =
AudioAttributes
.Builder()
.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
.setContentType(AUDIO_CONTENT_TYPE_MUSIC)
.build()

/**
Expand Down Expand Up @@ -118,7 +122,7 @@ class SoundTagPlayer(
} else {
(soundUriBase + Uri.encode(tag.filename)).toUri()
}
setAudioAttributes(music)
setAudioAttributes(music.platformAudioAttributes)
setOnErrorListener { mp, what, extra ->
Timber.w("Media error %d", what)
abandonAudioFocus()
Expand Down
3 changes: 0 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ androidxExifinterface = "1.4.2"
androidxFragmentKtx = "1.8.9"
# https://developer.android.com/jetpack/androidx/releases/lifecycle
androidxLifecycleProcess = "2.10.0"
# https://developer.android.com/jetpack/androidx/releases/media
androidxMedia = "1.7.1"
# https://developer.android.com/jetpack/androidx/releases/media3
androidxMedia3 = "1.10.0"
# https://developer.android.com/jetpack/androidx/releases/preference
Expand Down Expand Up @@ -146,7 +144,6 @@ androidx-media3-ui = { module = "androidx.media3:media3-ui", version.ref = "andr
androidx-media3-exoplayer-dash = { module = "androidx.media3:media3-exoplayer-dash", version.ref = "androidxMedia3" }
androidx-media3-exoplayer = { module = "androidx.media3:media3-exoplayer", version.ref = "androidxMedia3" }
androidx-preference-ktx = { module = "androidx.preference:preference-ktx", version.ref = "androidxPreferenceKtx" }
androidx-media = { module = "androidx.media:media", version.ref = "androidxMedia" }
androidx-uiautomator = { module = "androidx.test.uiautomator:uiautomator", version.ref = "androidxTestUiAutomator" }
androidx-webkit = { module = "androidx.webkit:webkit", version.ref = "androidxWebkit" }
androidx-viewpager2 = { module = "androidx.viewpager2:viewpager2", version.ref = "androidxViewpager2" }
Expand Down
Loading