|
|
@ -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() |
|
|
|