停止AVPlayer音乐在另一个控制器
问题描述:
所以我有这个变量在我的委托命名AppDelegate.h:停止AVPlayer音乐在另一个控制器
AVAudioPlayer *introSound;
它首先加载期间连续播放。
[introSound stop];
我想要做的就是从一个单独的控制器,firstController.m停止。
我试图
[AppDelegate.introSound stop];
但它抛出一个错误说:
error: expected ':' before '.' token
是什么原因造成的?
答
我假设你的意思是编译器错误? AppDelegate引用类,而不是指您的应用程序委托的类的实例。要获得从任何地方,这样做:
AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
[appDelegate.introSound stop];
你还需要确保introSound是一个属性,而不仅仅是AppDelegate中的实例变量。
答
用这种方式捕获的视频/音频的简单和best.do这
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];
}
+0
同样,你的答案并不涉及OP所具有的问题。在回答之前,请正确阅读问题*。 – 2012-06-21 15:10:15
谢谢!这个伎俩。虽然我将它添加为:AppDelegate * appDelegate =(AppDelegate *)[[UIApplication sharedApplication] delegate]; 非常感谢! – TRF 2010-09-18 13:55:26