3

I'm currently using an AVQueuePlayer to play mono mp3 files that are downloaded from a URL. The audio sounds fine when it plays on the speakers, but when I put on headphones, the audio only comes out on one side.

What is the simplest way to ensure that the AVPlayer plays mono audio files on both channels?

loadedion
  • 2,217
  • 19
  • 41

1 Answers1

2

As Andreas Zöllner states in his answer:

You can easily add an MTAudioProcessingTap to your existing AVPlayer item and copy the selected channels samples to the other channel during your process callback function. Here is a great tutorial explaining the basics:

http://chritto.wordpress.com/2013/01/07/processing-avplayers-audio-with-mtaudioprocessingtap/

The CODE:

NSURL *assetURL = [[NSBundle mainBundle] URLForResource:@"skyfall" withExtension:@"m4a"];
assert(assetURL);

// Create the AVAsset
AVAsset *asset = [AVAsset assetWithURL:assetURL];
assert(asset);

// Create the AVPlayerItem
AVPlayerItem *playerItem = [AVPlayerItem playerItemWithAsset:asset];
assert(playerItem);

assert([asset tracks]); assert([[asset tracks] count]);

self.player = [AVPlayer playerWithPlayerItem:playerItem]; assert(self.player);

[self.player play];

Community
  • 1
  • 1
Rajeev Barnwal
  • 1,349
  • 11
  • 14
  • Thanks, I took a look at the blog (which appears to be the only form of documentation on Taps) and it looked like a possible route, but the feature was added in iOS6 and my app needs to target iOS5, so that's a bit problematic. – loadedion Aug 01 '13 at 23:04