Ios 停止另一控制器中的AVPlayer音乐
因此,我的委托中有一个名为AppDelegate.h的变量:Ios 停止另一控制器中的AVPlayer音乐,ios,avfoundation,avplayer,Ios,Avfoundation,Avplayer,因此,我的委托中有一个名为AppDelegate.h的变量: AVAudioPlayer *introSound; 它在第一次加载期间连续播放 [introSound stop]; 我要做的是从一个单独的控制器firstController.m停止它 我试过了 [AppDelegate.introSound stop]; 但它抛出了一个错误,即: 错误:应为“:”在“.”标记之前 是什么原因造成的?我想你的意思是编译器错误?AppDelegate引用的是类,而不是作为应用程序委托的类的实
AVAudioPlayer *introSound;
它在第一次加载期间连续播放
[introSound stop];
我要做的是从一个单独的控制器firstController.m停止它 我试过了
[AppDelegate.introSound stop];
但它抛出了一个错误,即:
错误:应为“:”在“.”标记之前
是什么原因造成的?我想你的意思是编译器错误?AppDelegate引用的是类,而不是作为应用程序委托的类的实例。要从任何地方获取,请执行以下操作:
AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
[appDelegate.introSound stop];
您还需要确保introSound是一个属性,而不仅仅是AppDelegate的一个实例变量。使用这种方式,以简单和最佳的方式捕获视频/音频。执行此操作
NSMutableURLRequest *request1 = [[[NSMutableURLRequest alloc] init] autorelease];
[request1 setHTTPMethod:@"GET"];
NSError *error;
NSURLResponse *response;
NSString *documentFolderPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
NSFileManager *fileManager1 = [NSFileManager defaultManager];
NSString *videosFolderPath = [documentFolderPath stringByAppendingPathComponent:@"videos"];
//NSString* videosFolderPath = [@"~/Documents/bar.mp3" stringByExpandingTildeInPath];
NSLog(@"video path:%@",videosFolderPath);
//Check if the videos folder already exists, if not, create it!!!
BOOL isDir;
if (([fileManager1 fileExistsAtPath:videosFolderPath isDirectory:&isDir] && isDir) == FALSE) {
//[[NSFileManager defaultManager] createDirectoryAtPath:videosFolderPath attributes:nil];
[fileManager1 createDirectoryAtPath:videosFolderPath withIntermediateDirectories:YES attributes:nil error:nil];
}
谢谢这就成功了。尽管我将其添加为:AppDelegateappDelegate=(AppDelegate)[[UIApplication sharedApplication]delegate];非常感谢!同样,你的回答并没有解决OP遇到的问题。回答前请仔细阅读问题。