1

私はiPhoneプログラミングの初心者で、小さなアニメーションプログラムを書きました。サウンドにaudiotoolboxフレームを使用しましたが、機能していました。しかし、サウンドファイルを変更すると。(リソースとフォルダーからexfileを削除し、同じ名前、同じパスの別のファイルを追加します)

しかし、サウンドを変更した後は機能しません。

サウンドファイルもex-fileで入れ替えましたが、exファイルすら動かない。

(両方とも .wav タイプです) 必要に応じて、ここにコードを記述できます。

ありがとうございます。

4

1 に答える 1

0

コードを書き直してみましたか?代わりに AVFoundation フレームワークを使用することもできます。

.h

#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>

@interface AudioPlayerViewController : UIViewController {
    AVAudioPlayer *audioPlayer;
}

@end

.m

- (void)viewDidLoad {
    [super viewDidLoad];

    NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/audiofile.mp3", [[NSBundle mainBundle] resourcePath]]];

    NSError *error;
    audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];

    if (audioPlayer == nil)
        NSLog([error description]);
    else
        [audioPlayer play];

}
于 2011-10-12T08:19:24.607 に答える