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

No sound in simulator (iOS) #200

Open
sc00 opened this issue May 27, 2023 · 3 comments
Open

No sound in simulator (iOS) #200

sc00 opened this issue May 27, 2023 · 3 comments

Comments

@sc00
Copy link

sc00 commented May 27, 2023

Hey folks,

according to the console, my audio track is being played successfully:

reference back to player: <AVAudioPlayer: 0x600002c8c840>
whether song play completed successfully: true

I hear no sound in simulator (iOs) though. Device volume is set to 100%. Sound in other apps works. I tried multiple files of different types (mp3, wav).

Any leads?

@skopekreep
Copy link

To second the above report, I also do not get sound from the iOS simulator, but it is working properly in connected physical test devices. I have just started on this project again after some time, so I cannot say when the simulator stopped working, but I am certain it did a couple years ago when I last used the plugin. I was able to play sound on a video in the simulator, so it is not a configuration or volume issue. Thank you for looking into this when you have a moment.

Details:
iPhone 14 Pro Max Simulator
iOS 16.2
"nativescript-audio": "^6.2.6",

@kmahelona
Copy link

I can get sound to come out of the simulator if I play AND record at the same time! On my iPhone, I can only get sound coming out of my airpods. If I use the speaker for playback for the iphone, no sound comes out. I suspect there's an issue with routing.

I also see this error popping up,

  setCategoryError: null, <Reference: 0x6000007dce90>

not sure if it's related.

@kmahelona
Copy link

This is the problem in the ios/player.js

               if (options.audioMixing) {
                    audioSession.setCategoryWithOptionsError(AVAudioSessionCategoryAmbient, 1);
                }
                else {
                    audioSession.setCategoryWithOptionsError(AVAudioSessionCategoryAmbient, 2);
                }

if you comment out those lines it will fix the problem.

You can see the docs for the ambient mixing, https://developer.apple.com/documentation/avfaudio/avaudiosessioncategoryambient. Presumably some people will want that feature, but if you set audioMixing: false the player still loads up the Ambient category. I'm not sure if that logic is correct because I'm not sure what the 1 or 2 they pass to the setCategoryWithOptionsError does.

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

3 participants