AVPlayer可以在iPad上播放MP3文件

问题描述:

AVPlayer可以放置MP3文件吗?AVPlayer可以在iPad上播放MP3文件

它不在苹果的文档中列出MP3。

是的,它可以播放MP3。

尝试读取apple documentation here特别题为“的iOS硬件和软件音频编解码器”

enter image description here

难道ü尝试使用

[[AVAudioPlayer alloc]initWithContentsOfURL:fileUrl error:nil]; 

播放文件

下面是一个完整的示例部分。

myClass.h:

- @interface myClass : NSObject \<AVAudioPlayerDelegate\> ... 

myClass.m:

localPlayer = [[AVAudioPlayer alloc] 
    initWithContentsOfURL:newAudioURL error:nil]; [localPlayer 
    setDelegate:self]; 

    - (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)playedPlayer successfully:(BOOL)flag { 
     NSLog(@"releasing"); 
     [playedPlayer release]; 
     NSLog(@"released"); }