简体   繁体   English

如何解决的运行时错误,操作无法完成。 (OSStatus错误-43。)?

[英]how to solve run time error of The operation couldn’t be completed. (OSStatus error -43.)?

I am beginner of iPhone. 我是iPhone的初学者。 I want to play audio.for that purpose I have used AVAudioPlayer.. but that object return null value.. and also give run time error of The operation couldn't be completed. 我想播放音频。为此,我使用了AVAudioPlayer ..但该对象返回null值。并且还给出了无法完成操作的运行时错误。 (OSStatus error -43.) (OSStatus错误-43。)

This is the code I used 这是我使用的代码

-(IBAction)sound
{
   NSError *error;
   int currentsound;
    path=[[NSBundle mainBundle] pathForResource:@"Animalfile" ofType:@"plist"];
    dict=[NSDictionary dictionaryWithContentsOfFile:path];

    animalaudio=[dict valueForKey:@"audio"];
    NSLog(@"print:%@",dict);
    NSLog(@"printanimal%@",animalaudio);
    audiolist=[animalaudio objectAtIndex:currentsound];
    NSLog(@"audiolist:%@",audiolist);
    url=[NSURL fileURLWithPath:audiolist];
    NSLog(@"url:%@",url);
     audioplayer=[[AVAudioPlayer alloc]initWithContentsOfURL:url error:&error];
    NSLog(@"audioplayer:%@",audioplayer);
     if( audioplayer == nil ){

        NSLog(@"Failed with reason: %@", [error localizedDescription]);
    }
    else{
        [audioplayer play];
    }
  }

in that url also return the mp3 file but why url not pass in AVAudioPlayer because of audioplayer return the null but not return mp3 file.so, which code I write in AVAudioPlayer?give any suggestion and source code.... 在该网址中还返回了mp3文件,但为什么由于音频播放器而未在AVAudioPlayer中传递该网址,但返回了null但未返回mp3文件,所以我在AVAudioPlayer中编写了哪些代码?给出任何建议和源代码....

path=[[NSBundle mainBundle] pathForResource:@"Animalfile" ofType:@"plist"];

path must be a single file not a plist 路径必须是单个文件而不是plist

try to give the path one value 尝试给路径一个值

Example: 例:

path = [[NSString alloc] initWithFormat:[[NSBundle mainBundle] pathForResource:@"firstTrack" ofType:@"mp3"]]

-43 is a File not found error Check that the relative file path in your plist can be found from the working directory. -43是“找不到文件”错误检查是否可以从工作目录中找到plist中的相对文件路径。 Or better, use one of the many resource-finding methods of NSBundle to find your sound file directly, you will then get an existing absolute path. 或者更好的方法是,使用NSBundle的许多资源查找方法之一直接找到您的声音文件,然后您将获得一个现有的绝对路径。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 MidiClientCreate“操作无法完成。 (OSStatus错误-50。)” - MidiClientCreate “The operation couldn't be completed. (OSStatus error -50.)” ITLibrary:无法完成操作。 (OSStatus 错误 7011。) - ITLibrary: The operation couldn’t be completed. (OSStatus error 7011.) 如何解决运行时错误'无法创建带有消息的可写数据库文件'无法完成操作。 (可可错误260.)'。'? - how to solve run time error 'Failed to create writable database file with message 'The operation couldn’t be completed. (Cocoa error 260.)'.'? SKSMTPMessage错误-无法完成该操作。(OSStatus错误-9807。) - SKSMTPMessage Error- The operation couldn't be completed.(OSStatus error -9807.) 该操作无法完成。 可可错误4 - The operation couldn’t be completed. Cocoa Error 4 iOS:-canOpenURL:URL失败:“ fbauth2:/”-错误:“操作无法完成。 (OSStatus错误-10814。)”在模拟器和设备上 - iOS: -canOpenURL: failed for URL: “fbauth2:/” - error: “The operation couldn’t be completed. (OSStatus error -10814.)” on Simulators & Devices 该操作无法完成。 (可可错误:3840。) - The Operation couldn't be completed. (Cocoa error: 3840.) “这项行动无法完成。 (可可错误512.)“ - “The operation couldn’t be completed. (Cocoa error 512.)” 该操作无法完成。 (可可错误1560.) - The operation couldn’t be completed. (Cocoa error 1560.) 如何解决错误:操作无法完成。 (可可错误3840。)json iOS? - How to resolve error:the operation couldn’t be completed. (cocoa error 3840.) json iOS?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM