Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Background Mode Audio #160

Open
LucyTurtle opened this issue Dec 11, 2019 · 3 comments
Open

Background Mode Audio #160

LucyTurtle opened this issue Dec 11, 2019 · 3 comments

Comments

@LucyTurtle
Copy link

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>
@bradmartin
Copy link
Collaborator

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.

@pabloacastillo
Copy link

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
mehyaa/nativescript-audioplay#2

@liamcharmer
Copy link

Was there any update with this at all? Or any further directions for both iOS and Android?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants