2013-03-31 5 views
1

Я хотел бы знать, почему мой AVPlayer падает, когда я хочу, чтобы он воспроизводил «некоторые» песни.Ошибка AVPlayer во время воспроизведения MP3

Song #1

Song #2

То есть, как я играю эти песни:

AVPlayerItem *item = [[AVPlayerItem alloc] initWithURL:[NSURL URLWithString:@"http://www.iwheelbuy.com/Player/Test/1.mp3"]]; 
AVPlayer *player = [[AVPlayer alloc] init]; 
[player replaceCurrentItemWithPlayerItem:item]; 
[player setRate:1.0f]; 

У меня есть некоторые наблюдатели Кво, один из них замечает AVPlayer status и когда я пытаюсь играть одну из них песни он дает мне ошибку:

Domain=AVFoundationErrorDomain Code=-11800 
UserInfo=0x1cdc3be0 {NSLocalizedDescription=..., NSUnderlyingError=0x1cdc14c0 
"The operation couldn’t be completed. (OSStatus error -303.)" 

Есть ли способ играть в эти песни? Любая помощь приветствуется.

EDIT: мне удалось сделать эти песни хорошо играть

__block AVPlayer *currentPlayerBlock = _currentPlayer; 
__block NSURL *urlBlock = url; 
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{ 
    AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:urlBlock options:nil]; 
    AVPlayerItem *item = [[AVPlayerItem alloc] initWithAsset:asset]; 
    dispatch_sync(dispatch_get_main_queue(), ^{ 
     [currentPlayerBlock replaceCurrentItemWithPlayerItem:item]; 
     [currentPlayerBlock setRate:1.0f]; 
    }); 
}); 

ответ

1
__block AVPlayer *currentPlayerBlock = _currentPlayer; 
__block NSURL *urlBlock = url; 
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{ 
    AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:urlBlock options:nil]; 
    AVPlayerItem *item = [[AVPlayerItem alloc] initWithAsset:asset]; 
    dispatch_sync(dispatch_get_main_queue(), ^{ 
     [currentPlayerBlock replaceCurrentItemWithPlayerItem:item]; 
     [currentPlayerBlock setRate:1.0f]; 
    }); 
}); 

Таким образом, он работает

Смежные вопросы