Skip to content

liorazi/AVAudioSessionWorkaround

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 

Repository files navigation

AVAudioSessionWorkaround

This test project was made in order to test a workaround to an Apple's AVFoundation framework bug.

The bug was that you couldn't call AVAudioPlayer's call method in the AVAudioSession's InterruptionTypeEnded interruption.

The workaround that seemed to work is adding a small delay to that call using dispatch_after.

Today, 10/05/2016, I Submitted a radar to Apple about it, and here are its details: (#26182163)

Summary: While implementing AVAudioSession interruptions, in order to resume playback of a sound file after finishing a phone call, there is a problem calling the play method of the AVAudioPlayer inside the AVAudioSession's "InterruptionTypeEnded" interruption. It seems like the interruption does get called, but the player's call method doesn't run properly, and therefore the playback of the sound file doesn't get resumed.

Steps to Reproduce:

  1. Setup your app to use Background Mode - Audio
  2. Initialise an AVAudioPlayer (Category -> AVAudioSessionCategoryPlayback)
  3. Add Observer to handle AVAudioSession interruptions.
  4. Implement method that will handle interruptions: in the "InterruptionTypeEnded" case call the play method of AVAudioPlayer in order to resume playback
  5. On app load, play the soundfile you want.
  6. Initiate or answer a phone call, and then hangup.
  • I've created a test project for this issue written in Objective-C (Also did one in Swift which had the same problem) with a workaround of the problem - The solution was to add a delay to the player's play method using "dispatch_after"

It can be found here: https://github.com/liorazi/AVAudioSessionWorkaround

Expected Results: Sound file playback resumes after phone call ends.

Actual Results: Sound file playback stays paused after phone call ends.

Version: iOS 9.3.1

Configuration: iPhone 6S

About

AVAudioSession Interruptions test project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published