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

playReturningError failure #259

Closed
developer-poplar opened this issue May 6, 2023 · 6 comments · Fixed by #280
Closed

playReturningError failure #259

developer-poplar opened this issue May 6, 2023 · 6 comments · Fixed by #280
Assignees
Labels

Comments

@developer-poplar
Copy link

developer-poplar commented May 6, 2023

On ios devices, playReturningError is invalid when the audio is interrupted by another app,I'm using SFBAudioPlayer

@sbooth sbooth self-assigned this May 6, 2023
@sbooth
Copy link
Owner

sbooth commented May 7, 2023

Do you observe the same behavior in the simulator? I tried to reproduce the problem with SimplePlayer-iOS in the simulator but didn't observe the issue.

@developer-poplar
Copy link
Author

Sorry, I can't simulate audio termination in the emulator at the moment,But I found something new. When playReturningError was called again after the termination, it worked, but with a long delay, about 60 seconds

@developer-poplar
Copy link
Author

After the re-test, if interrupted by an incoming call,is ok. This problem will occur only when the audio is interrupted by other apps,for instance Apple Music

@8kdesign
Copy link

Encountered the same issue with interruption. It stops being able to play after I switch to TikTok and come back to my app.

@developer-poplar
Copy link
Author

Encountered the same issue with interruption. It stops being able to play after I switch to TikTok and come back to my app.

I used a maybe not very good method to solve this problem, but it worked. I recorded the playback progress in real time in the child thread, flagged any external audio interruptions, and when I needed to play again, I reset SFBAudioPlayer and called seekToPosition to the recorded point in time

@sbooth
Copy link
Owner

sbooth commented Dec 3, 2023

I believe this is caused by AVAudioEngine stopping automatically when the audio session is interrupted. This leaves the player in an inconsistent state internally. Observing AVAudioSessionInterruptionNotification in the player and pausing/restarting appropriately seems to fix the issue.

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

Successfully merging a pull request may close this issue.

3 participants