pull/1296/head
gedoor 3 years ago
parent c4162fca01
commit 0d895548df
  1. 15
      app/src/main/java/io/legado/app/service/AudioPlayService.kt

@ -49,9 +49,15 @@ class AudioPlayService : BaseService(),
var url: String = "" var url: String = ""
} }
private lateinit var audioManager: AudioManager private val audioManager: AudioManager by lazy {
private lateinit var mFocusRequest: AudioFocusRequestCompat getSystemService(Context.AUDIO_SERVICE) as AudioManager
private lateinit var exoPlayer: SimpleExoPlayer }
private val mFocusRequest: AudioFocusRequestCompat by lazy {
MediaHelp.getFocusRequest(this)
}
private val exoPlayer: SimpleExoPlayer by lazy {
SimpleExoPlayer.Builder(this).build()
}
private var title: String = "" private var title: String = ""
private var subtitle: String = "" private var subtitle: String = ""
private var mediaSessionCompat: MediaSessionCompat? = null private var mediaSessionCompat: MediaSessionCompat? = null
@ -65,9 +71,6 @@ class AudioPlayService : BaseService(),
super.onCreate() super.onCreate()
isRun = true isRun = true
upNotification() upNotification()
audioManager = getSystemService(Context.AUDIO_SERVICE) as AudioManager
mFocusRequest = MediaHelp.getFocusRequest(this)
exoPlayer = SimpleExoPlayer.Builder(this).build()
exoPlayer.addListener(this) exoPlayer.addListener(this)
initMediaSession() initMediaSession()
initBroadcastReceiver() initBroadcastReceiver()

Loading…
Cancel
Save