playback: broadcast audiofx session on play/pause
Broadcast the audiofx session when playing/pausing rather than starting and stopping. This is apparently the more correct way to do this. Resolves #391.
This commit is contained in:
parent
59818471d6
commit
969ceb4ea7
2 changed files with 24 additions and 22 deletions
13
CHANGELOG.md
13
CHANGELOG.md
|
@ -2,15 +2,18 @@
|
||||||
|
|
||||||
## dev
|
## dev
|
||||||
|
|
||||||
#### What's Fixed
|
|
||||||
- Fixed MP4-AAC files not playing due to an accidental audio extractor
|
|
||||||
deletion
|
|
||||||
- Fix "format" not appearing in song properties view
|
|
||||||
|
|
||||||
#### What's Improved
|
#### What's Improved
|
||||||
- Accept `REPLAYGAIN_*` adjustment information on OPUS files alongside
|
- Accept `REPLAYGAIN_*` adjustment information on OPUS files alongside
|
||||||
`R128_*` adjustments.
|
`R128_*` adjustments.
|
||||||
- List updates are now consistent across the app
|
- List updates are now consistent across the app
|
||||||
|
- Search view now trims search queries
|
||||||
|
- Audio effect (equalizer) session is now broadcast when playing/pausing
|
||||||
|
rather than on start/stop.
|
||||||
|
|
||||||
|
#### What's Fixed
|
||||||
|
- Fixed MP4-AAC files not playing due to an accidental audio extractor
|
||||||
|
deletion
|
||||||
|
- Fix "format" not appearing in song properties view
|
||||||
|
|
||||||
## 3.0.3
|
## 3.0.3
|
||||||
|
|
||||||
|
|
|
@ -226,11 +226,7 @@ class PlaybackService :
|
||||||
// No song, stop playback and foreground state.
|
// No song, stop playback and foreground state.
|
||||||
logD("Nothing playing, stopping playback")
|
logD("Nothing playing, stopping playback")
|
||||||
player.stop()
|
player.stop()
|
||||||
if (openAudioEffectSession) {
|
|
||||||
// Make sure to close the audio session when we stop playback.
|
|
||||||
broadcastAudioEffectAction(AudioEffect.ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION)
|
|
||||||
openAudioEffectSession = false
|
|
||||||
}
|
|
||||||
stopAndSave()
|
stopAndSave()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -238,15 +234,6 @@ class PlaybackService :
|
||||||
logD("Loading ${song.rawName}")
|
logD("Loading ${song.rawName}")
|
||||||
player.setMediaItem(MediaItem.fromUri(song.uri))
|
player.setMediaItem(MediaItem.fromUri(song.uri))
|
||||||
player.prepare()
|
player.prepare()
|
||||||
|
|
||||||
if (!openAudioEffectSession) {
|
|
||||||
// Android does not like it if you start an audio effect session without having
|
|
||||||
// something within your player buffer. Make sure we only start one when we load
|
|
||||||
// a song.
|
|
||||||
broadcastAudioEffectAction(AudioEffect.ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION)
|
|
||||||
openAudioEffectSession = true
|
|
||||||
}
|
|
||||||
|
|
||||||
player.playWhenReady = play
|
player.playWhenReady = play
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,9 +250,21 @@ class PlaybackService :
|
||||||
|
|
||||||
override fun onEvents(player: Player, events: Player.Events) {
|
override fun onEvents(player: Player, events: Player.Events) {
|
||||||
super.onEvents(player, events)
|
super.onEvents(player, events)
|
||||||
if (events.contains(Player.EVENT_PLAY_WHEN_READY_CHANGED) && player.playWhenReady) {
|
if (events.contains(Player.EVENT_PLAY_WHEN_READY_CHANGED)) {
|
||||||
// Mark that we have started playing so that the notification can now be posted.
|
if (player.playWhenReady) {
|
||||||
hasPlayed = true
|
// Mark that we have started playing so that the notification can now be posted.
|
||||||
|
hasPlayed = true
|
||||||
|
if (!openAudioEffectSession) {
|
||||||
|
// Convention to start an audioeffect session on play/pause rather than
|
||||||
|
// start/stop
|
||||||
|
broadcastAudioEffectAction(AudioEffect.ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION)
|
||||||
|
openAudioEffectSession = true
|
||||||
|
}
|
||||||
|
} else if (openAudioEffectSession) {
|
||||||
|
// Make sure to close the audio session when we stop playback.
|
||||||
|
broadcastAudioEffectAction(AudioEffect.ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION)
|
||||||
|
openAudioEffectSession = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Any change to the analogous isPlaying, isAdvancing, or positionMs values require
|
// Any change to the analogous isPlaying, isAdvancing, or positionMs values require
|
||||||
|
|
Loading…
Reference in a new issue