On iOS 6, I have been able to set up an AVAudioSession to play mp3 files. While running with Base set at iOS 7, this no longer works. Any ideas why this won't work? The app never crashes...it just doesn't play the mp3. I have verified this same code and same URL works on iOS 6 apps.
Errors are:
ERROR: 185: Error creating aggregate audio device: 'what'
WARNING: 219: The input device is 0x31; 'AppleHDAEngineInput:1B,0,1,0:1'
WARNING: 223: The output device is 0x28; 'AppleHDAEngineOutput:1B,0,1,1:0'
ERROR: 398: error 'what'
_itemFailedToPlayToEnd: {
kind = 1;
new = 2;
old = 0;
}
The code:
- (void)viewDidLoad {
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
NSError *setCategoryError = nil;
[audioSession setCategory:AVAudioSessionCategoryPlayback error:&setCategoryError];
if (setCategoryError) { /* handle the error condition */ }
NSError *activationError = nil;
[audioSession setActive:YES error:&activationError];
if (activationError) { /* handle the error condition */ }
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[self becomeFirstResponder];
NSURL *newURL = [NSURL URLWithString:_entry.articleUrl];
self.player = [[MPMoviePlayerController alloc] initWithContentURL: newURL];
[player prepareToPlay];
player.allowsAirPlay = YES;
player.scalingMode = MPMovieScalingModeAspectFit;
player.view.frame = self.view.frame;
[self.view addSubview: player.view];
[self.player setFullscreen:YES animated:YES];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(movieFinishedCallback:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(exitedFullscreen:)
name:MPMoviePlayerDidExitFullscreenNotification
object:player];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(playbackStateChanged:)
name:MPMoviePlayerPlaybackStateDidChangeNotification
object:player];
[player play];
[super viewDidLoad];
}
Try using
NSURL *newURL = [NSURL fileURLWithPath:_entry.articleUrl];
instead of
NSURL *newURL = [NSURL URLWithString:_entry.articleUrl];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With