override fun onBind(intent: Intent?): IBinder? {
return mBinder
}
@Synchronized
private fun startRecordingInternal(recorderConfig: RecorderConfig) {
val willStartRecorderResult =
RecorderResultBuilder.aRecorderResult().withRecorderFile(recorderConfig.recorderFile)
.withRecorderId(recorderConfig.recorderId).build()
if (ContextCompat.checkSelfPermission(
this@RecorderService,
android.Manifest.permission.RECORD_AUDIO
)
!= PackageManager.PERMISSION_GRANTED
) {
logD(“Record audio permission not granted, can’t record”)
notifyCallBack {
it.onException(
“Record audio permission not granted, can’t record”,
willStartRecorderResult
)
}
return
}
if (ContextCompat.checkSelfPermission(
this@RecorderService,
android.Manifest.permission.WRITE_EXTERNAL_STORAGE
)
!= PackageManager.PERMISSION_GRANTED
) {
logD(“External storage permission not granted, can’t save recorded”)
notifyCallBack {
it.onException(
“External storage permission not granted, can’t save recorded”,
willStartRecorderResult
)
}
return
}
if (isRecording()) {
val weight = recorderConfig.weight
if (weight < currentWeight) {
logD(“Recording with weight greater than in recording”)
notifyCallBack {
it.onException(
“Recording with weight greater than in recording”,
willStartRecorderResult
)
}
return
}
if (weight > currentWeight) {
//只要权重大于当前权重,立即停止当前。
stopRecordingInternal()
}
if (weight == currentWeight) {
if (recorderConfig.recorderId == currentRecorderResult.recorderId) {
<