Open chris-praxis opened 2 years ago
AFAICS, that check just needs to to be removed. The rest of the code seems to support Android < 8 correctly.
I'm saying a version check needs to be added, and you're saying some check needs to be removed? I don't follow. Here's my change, simply wrapping some audio focus code in a version check...
if (android.os.Build.VERSION.SDK_INT >= 26) { const playbackAttributes = new android.media.AudioAttributes.Builder() .setUsage(options.usage) .setContentType(options.contentType) .build(); this._audioFocusRequest = new android.media.AudioFocusRequest.Builder(options.durationHint) .setAudioAttributes(playbackAttributes) .setAcceptsDelayedFocusGain(true) .setOnAudioFocusChangeListener(this._mOnAudioFocusChangeListener) .build(); }
Ohh.. looking at it again, I was wrong I guess. But a few lines earlier, there is the following: https://github.com/nstudio/nativescript-audio/blob/master/src/android/player.ts#L40-L42
So the additional check should not be necessary.
Crash happens on Android 7 where this API is not available. Code appears to be missing a if (android.os.Build.VERSION.SDK_INT >= 26) check.