How to switch audio output between the two buds of headphones

819 views Asked by At

My application demands a functionality that sound has to come through only one side of headphones based on the user choice. i.e either sound can play from left side of head phone or right side of the phone, but not from the two sides at a time.

I want to know that how to switch the audio output of an iOS device between the two sides/buds of the headphones connected to the device.How can i achieve this.Please share your suggestions and ideas.

Thanks in advance.

1

There are 1 answers

0
Amresh Kumar On

If you're using AVAudioPlayer to play the audio, you can use the pan property of the same to adjust the volume of each channel.

pan

The audio player’s stereo pan position.
@property float pan
Discussion By setting this property you can position a sound in the stereo field. A value of –1.0 is full left, 0.0 is center, and 1.0 is full right. Availability Available in iOS 4.0 and later. Declared In AVAudioPlayer.h

Or if you want more control over the audio playback, you can use AudioQueueServices described here, along with the sample code.