LoginSignup
0
0

More than 3 years have passed since last update.

ExoPlayerで再生中にイヤホンやbluetoothが外れた際に停止させるには

Posted at

単発です 備忘録として

環境

build.gradle
def exoplayer_version = "2.11.6"
implementation "com.google.android.exoplayer:exoplayer:$exoplayer_version"

実装

sample.kt
private var player: SimpleExoPlayer? = null

// 中略

player?.setHandleAudioBecomingNoisy(true)

※ SimpleExoPlayerのinit処理部分は省略しています
※ バージョン2.11.0からある模様です

自前で実装するとなるとACTION_AUDIO_BECOMING_NOISY intentをブロードキャストし処理する必要があるのでたったのこれだけですむとはとても便利ですね

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0