【问题标题】:About MPMusicPlayerController and does AVAudioPlayer works in iPhoneSimulator?关于 MPMusicPlayerController 和 AVAudioPlayer 在 iPhoneSimulator 中是否有效?
【发布时间】:2010-01-26 11:15:44
【问题描述】:

来自(iPhone) Can I do AudioServicesPlaySystemSound Looping with scheduler?

MPMusicPlayerController 不起作用,因为它是关于 iPod 音乐库的,我无法向其中添加音乐文件,因为我正在玩 iPhone 游戏并且不与外部 iPod 库交互。

AVAudioPlayer 可以在 iPhoneSimulator 中使用吗?

【问题讨论】:

    标签: ios-simulator avaudioplayer mpmusicplayercontroller


    【解决方案1】:

    查看下面的代码,它是一个简单的 AVAudioPlayer 示例,它也可以在 iPhone 模拟器上工作..

    AVAudioPlayer *audioPlayer;

    NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/azan1.mp3", [[NSBundle mainBundle] resourcePath]]];
    
    NSError *error;
    audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
    audioPlayer.numberOfLoops = -1;
    
    [audioPlayer play];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-01
      • 2010-11-28
      • 1970-01-01
      • 2010-10-02
      • 2019-11-09
      相关资源
      最近更新 更多