Open northout-silky opened 3 years ago
@gauravk95
@gauravk95 i am waiting too
@northout-silky Did you handle RECORD_AUDIO permission?
Give permission in manifest and then while installing
Give permission in manifest
<uses-permission android:name="android.permission.RECORD_AUDIO" />
Request permission in runtime
Solution: private val PERMISSION_REQUEST_CODE = 100
fun checkPermission(): Boolean {
val result = ContextCompat.checkSelfPermission(
binding.root.context as Activity,
android.Manifest.permission.RECORD_AUDIO
)
return result == PackageManager.PERMISSION_GRANTED
}
fun requestPermission() {
ActivityCompat.requestPermissions(
binding.root.context as Activity,
arrayOf(Manifest.permission.RECORD_AUDIO),
PERMISSION_REQUEST_CODE
)
}
in your Android onCreate function call the below function requestPermission() if (checkPermission()) { //get the AudioSessionId from your MediaPlayer and pass it to the visualizer val audioSessionId: Int? = MediaPlayerMix.mPlayer?.audioSessionId if (audioSessionId != -1) audioSessionId?.let { binding.blast.setAudioSessionId(it) } }
Getting “Cannot initialize Visualizer engine, error: -3” when trying to use Visualizer with ExoPlayer