AVAudioSession不会在iOS 7上播放

在iOS 6上,我可以设置AVAudioSession来播放mp3文件。 在iOS 7中运行Base时,这不再有效。 任何想法为什么这不起作用? 该应用程序从不崩溃......它只是不播放MP3。 我已验证此相同的代码和相同的网址适用于iOS 6应用程序。

错误是:

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;
}

代码:

- (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];   
}

尝试使用

NSURL *newURL = [NSURL fileURLWithPath:_entry.articleUrl];

代替

NSURL *newURL = [NSURL URLWithString:_entry.articleUrl];
链接地址: http://www.djcxy.com/p/74301.html

上一篇: AVAudioSession Won't Play On iOS 7

下一篇: Contour irregular data within polygon