mirror of
https://github.com/ultrasonic/ultrasonic
synced 2025-02-17 04:00:39 +01:00
Set AudioAttributes in LocalMediaPlayer
This commit is contained in:
parent
e63f24242b
commit
f27212f263
@ -360,7 +360,7 @@ class LocalMediaPlayer(
|
|||||||
secondaryProgress = -1 // Ensure seeking in non StreamProxy playback works
|
secondaryProgress = -1 // Ensure seeking in non StreamProxy playback works
|
||||||
|
|
||||||
setPlayerState(PlayerState.IDLE)
|
setPlayerState(PlayerState.IDLE)
|
||||||
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC)
|
setAudioAttributes(mediaPlayer)
|
||||||
|
|
||||||
var dataSource = file.path
|
var dataSource = file.path
|
||||||
if (partial) {
|
if (partial) {
|
||||||
@ -433,6 +433,15 @@ class LocalMediaPlayer(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun setAudioAttributes(player: MediaPlayer) {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
|
player.setAudioAttributes(AudioFocusHandler.getAudioAttributes())
|
||||||
|
} else {
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
|
player.setAudioStreamType(AudioManager.STREAM_MUSIC)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
private fun setupNext(downloadFile: DownloadFile) {
|
private fun setupNext(downloadFile: DownloadFile) {
|
||||||
try {
|
try {
|
||||||
@ -446,11 +455,17 @@ class LocalMediaPlayer(
|
|||||||
}
|
}
|
||||||
nextMediaPlayer = MediaPlayer()
|
nextMediaPlayer = MediaPlayer()
|
||||||
nextMediaPlayer!!.setWakeMode(context, PowerManager.PARTIAL_WAKE_LOCK)
|
nextMediaPlayer!!.setWakeMode(context, PowerManager.PARTIAL_WAKE_LOCK)
|
||||||
|
|
||||||
|
setAudioAttributes(nextMediaPlayer!!)
|
||||||
|
|
||||||
|
|
||||||
|
// This has nothing to do with the MediaSession, it is used to associate
|
||||||
|
// the equalizer or visualizer with the player
|
||||||
try {
|
try {
|
||||||
nextMediaPlayer!!.audioSessionId = mediaPlayer.audioSessionId
|
nextMediaPlayer!!.audioSessionId = mediaPlayer.audioSessionId
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
nextMediaPlayer!!.setAudioStreamType(AudioManager.STREAM_MUSIC)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nextMediaPlayer!!.setDataSource(file.path)
|
nextMediaPlayer!!.setDataSource(file.path)
|
||||||
setNextPlayerState(PlayerState.PREPARING)
|
setNextPlayerState(PlayerState.PREPARING)
|
||||||
nextMediaPlayer!!.setOnPreparedListener {
|
nextMediaPlayer!!.setOnPreparedListener {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user