nativescript-audio
nativescript-audio copied to clipboard
Background Mode Audio
Hello,
Background mode audio, even after setting a category is not working for me for either iOS or Android.
const playerOptions = {
audioFile: '~/audio/'+info.audio+".png",
loop: true,
autoplay: true
};
player
.initFromFile(playerOptions)
.then( function() {
if(player.ios){
const audioSession = AVAudioSession.sharedInstance();
audioSession.setCategoryError( AVAudioSessionCategoryPlayback );
player.play();
}
})
.catch(function(err) {
console.log('something went wrong...', err);
});
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
<string>fetch</string>
</array>
It's a bit different approach to do background audio like I think you're looking for entirely. And you'll actually need to use a different native player on iOS for streaming that won't block main thread. I've still not had any free time or work requirements to finish any work on this. I had this working in a private project years ago but being private couldn't OSS it at the time. I'd still like to find time to update the plugin here and add these options but I'm low on time unfortunately.
Hi! I did some changes to the ios version of the library to add this feature (audio streaming) and have a working version on my app. (Migrated from AVAudioPlayer to AVPlayer)
You can check the changes in the ios/player.ts https://github.com/mehyaa/nativescript-audioplay/pull/2
Was there any update with this at all? Or any further directions for both iOS and Android?