kopia lustrzana https://github.com/ryukoposting/Signal-Android
Add audio focus handling to voice note playback.
rodzic
5f6b073cb6
commit
cba1caa5be
|
@ -41,7 +41,7 @@ class VoiceNotePlaybackController(
|
|||
}
|
||||
|
||||
player.playWhenReady = false
|
||||
player.setAudioAttributes(attributes, false)
|
||||
player.setAudioAttributes(attributes, true)
|
||||
|
||||
if (newStreamType == AudioManager.STREAM_VOICE_CALL) {
|
||||
player.playWhenReady = true
|
||||
|
|
|
@ -39,7 +39,7 @@ import java.util.stream.Collectors;
|
|||
/**
|
||||
* ExoPlayer Preparer for Voice Notes. This only supports ACTION_PLAY_FROM_URI
|
||||
*/
|
||||
final class VoiceNotePlaybackPreparer implements MediaSessionConnector.PlaybackPreparer {
|
||||
final class VoiceNotePlaybackPreparer implements MediaSessionConnector.PlaybackPreparer {
|
||||
|
||||
private static final String TAG = Log.tag(VoiceNotePlaybackPreparer.class);
|
||||
private static final Executor EXECUTOR = Executors.newSingleThreadExecutor();
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.google.android.exoplayer2.C
|
|||
import com.google.android.exoplayer2.DefaultLoadControl
|
||||
import com.google.android.exoplayer2.ForwardingPlayer
|
||||
import com.google.android.exoplayer2.SimpleExoPlayer
|
||||
import com.google.android.exoplayer2.audio.AudioAttributes
|
||||
import org.thoughtcrime.securesms.video.exo.SignalMediaSourceFactory
|
||||
|
||||
class VoiceNotePlayer @JvmOverloads constructor(
|
||||
|
@ -15,7 +16,9 @@ class VoiceNotePlayer @JvmOverloads constructor(
|
|||
DefaultLoadControl.Builder()
|
||||
.setBufferDurationsMs(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE)
|
||||
.build()
|
||||
).build()
|
||||
).build().apply {
|
||||
setAudioAttributes(AudioAttributes.Builder().setContentType(C.AUDIO_CONTENT_TYPE_MUSIC).setUsage(C.USAGE_MEDIA).build(), true)
|
||||
}
|
||||
) : ForwardingPlayer(internalPlayer) {
|
||||
|
||||
override fun seekTo(windowIndex: Int, positionMs: Long) {
|
||||
|
|
|
@ -43,7 +43,7 @@ class VoiceNotePlaybackControllerTest {
|
|||
|
||||
// THEN
|
||||
verify(player).playWhenReady = false
|
||||
verify(player).setAudioAttributes(expected, false)
|
||||
verify(player).setAudioAttributes(expected, true)
|
||||
verify(player).playWhenReady = true
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ class VoiceNotePlaybackControllerTest {
|
|||
|
||||
// THEN
|
||||
verify(player).playWhenReady = false
|
||||
verify(player).setAudioAttributes(expected, false)
|
||||
verify(player).setAudioAttributes(expected, true)
|
||||
verify(player, Mockito.never()).playWhenReady = true
|
||||
}
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue