播放.caf文件:在模拟器中工作正常但在iPhone中没有 [英] playing a .caf file: works fine in simulator but not in iPhone

查看:134
本文介绍了播放.caf文件:在模拟器中工作正常但在iPhone中没有的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作录音机。重新编码和播放在模拟器上工作正常。但在iPhone上它不起作用。 (我按照 iPhoneOSPrmingmingGuide / AudioandVideoTechnologies

I'm building a voice recorder. Recoding and playing works fine on simulator. But on iphone it doesn't work. (I followed the exact steps as mentioned in iPhoneOSProgrammingGuide/AudioandVideoTechnologies)

    printf("%s(player)\n",[[self.soundFileURL absoluteString] UTF8String]);

    AVAudioPlayer *newPlayer =
    [[AVAudioPlayer alloc] initWithContentsOfURL: self.soundFileURL error: nil];

    if([self.soundFileURL isFileURL]){
        printf("isFileURL\n");
    }

    self.player = newPlayer;
    [newPlayer release];

    [player prepareToPlay];
    [player setDelegate: self];
    //recorderLabel.text=@"Playing..";
    [player play];
    printf("playing..\n");

调试器输出为
file:// localhost / var / mobile / Applications / 9A607A45-974B-4E9F-9839-FD21B3BC9DD8 / Documents / 1251828741.caf(player)
isFileURL
play ..

The debugger out put is file://localhost/var/mobile/Applications/9A607A45-974B-4E9F-9839-FD21B3BC9DD8/Documents/1251828741.caf(player) isFileURL playing..

推荐答案

iPhone的.caf文件需要编码为单声道,而不是立体声频道,只能用于iPhone。

.caf file for iPhone need to be encoded as a mono channel and not with a stereo channel then only it will work with iPhone.

这篇关于播放.caf文件:在模拟器中工作正常但在iPhone中没有的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆