1
當我測試時,我的Safari Web Inspector中都沒有顯示ForgeLog
和NSLog
。我做錯了什麼或者是故意的?未在Web檢查器中顯示日誌
[ForgeLog d:@"Playing file at..."];
編輯:下面是上下文的代碼的其餘部分。 (這次使用NSLog
。)
#import "audio_API.h"
static AVAudioPlayer* player = nil;
@implementation audio_API
+ (void)play:(ForgeTask*)task {
// parse the file url from the file object
ForgeFile* file = [[ForgeFile alloc] initWithFile:[task.params objectForKey:@"file"]];
NSString* fileURL = [file url];
NSLog(@"Playing file at %@", fileURL);
NSURL* url = [[NSBundle mainBundle] URLForResource:fileURL withExtension:@"m4a"];
// TESTING
//url = [[NSBundle mainBundle] URLForResource:@"seconds" withExtension:@"m4a"];
// END TESTING
NSAssert(url, @"URL is invalid.");
// create the player
NSError* error = nil;
player = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
if(!player)
{
NSLog(@"Error creating player: %@", error);
};
[player play];
[task success:nil];
}
你可以發佈你調用它的方法嗎? –
@ChrisLoonam我按照你的要求編輯了我的文章:) – Garrett