のiOS 4.2.1を実行しているiPhoneの沈黙を与え、私はiOSアプリに短い(4秒)のオーディオクリップを再生しようとしているシステムオーディオの再生が
問題。
- (iOS 4.2.1のiPhone 3G)私は黙っています。ただし、必要に応じて振動が発生します。
- シミュレータでは、オーディオが期待どおりに再生されます。
私は、Snow Leopard 10.6.8の上にあるVMWareのLion VMインスタンス10.7.2で動作しています。それは、リニアPCMファイルです
- を試してみた何
ファイル名の大文字と小文字がコードとファイルで同じであることを確認してください。
- ターゲットを消去し、iPhoneから削除して再構築しました。
コード
// Usage from class
-(void)loadRunningView {
JGTimerRunningViewController *runningViewController = [[JGTimerRunningViewController alloc] initWithNibName:@"JGRunningViewController" bundle:nil];
[runningViewController loadAlertSoundWithFilename:@"DigitalAlarm1"];
}
@interface JGTimerRunningViewController : UIViewController {
IBOutlet UILabel *timeLabel;
CFURLRef soundFileURLRef;
SystemSoundID soundFileObject;
}
@implementation JGTimerRunningViewController
-(void)loadAlertSoundWithFilename:(NSString *)alertSoundFilename_ {
// Get the main bundle for the app
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFStringRef filename = (CFStringRef)alertSoundFilename_;
soundFileURLRef = CFBundleCopyResourceURL (mainBundle, filename, CFSTR ("aiff"), NULL);
// Create a system sound object representing the sound file
AudioServicesCreateSystemSoundID (soundFileURLRef, &soundFileObject);
}
..
-(IBAction)playSound:(id)sender {
AudioServicesPlaySystemSound (soundFileObject);
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
}
-(void)showRedCard {
[[self view] setBackgroundColor:[UIColor redColor]];
[self playSound:self];
}
...
- (void)dealloc {
CFRelease(soundFileURLRef);
AudioServicesDisposeSystemSoundID(soundFileObject);
[timeLabel release];
[super dealloc];
}
@end
ええ、これも聞いたことがあり、帽子はまったく同じです。それを理解できません。 –
iPhone自体に問題があるかどうか疑問に思っています。しかし、別のアラームアプリとAppleのものは、完璧な音を発するものである。 –
ブレークポイントを設定し、コードをステップ実行して、例えば 'soundFileURLRef'がnullでないことなどを確認しましたか? –