2
這個問題很簡單。我想模仿默認OSX的音頻QuickLook插件的行爲,我需要通常停留在其預覽窗口底部的QuickTime Player。我也喜歡當我的自定義插件正在使用時,我也可以聽到我目前正在預覽的文件的聲音。如何將QuickTime播放器欄插入到自定義QuickLook插件中?
下面是一些代碼(從GeneratePreviewForURL.m文件),可能是有用的,以更好地理解上下文:
OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options)
{
@autoreleasepool {
if (QLPreviewRequestIsCancelled(preview)) return noErr;
NSMutableString *html=[[NSMutableString alloc] init];
NSDictionary *props;
NSData *imageData=[NSData dataWithContentsOfFile:@"/tmp/IMAGE.png"];
[email protected]{
(__bridge NSString *)kQLPreviewPropertyTextEncodingNameKey:@"UTF-8",
(__bridge NSString *)kQLPreviewPropertyMIMETypeKey:@"text/html",
(__bridge NSString *)kQLPreviewPropertyAttachmentsKey:@{
@"IMAGE":@{
(__bridge NSString *)kQLPreviewPropertyMIMETypeKey:@"image/png",
(__bridge NSString *)kQLPreviewPropertyAttachmentDataKey: imageData,
},
},
};
[html appendString:@"<html>"];
[html appendString:@"<body>"];
[html appendString:@"<img src=\"cid:IMAGE\">"];
[html appendString:@"<br><br>"];
//...
[html appendString:@"</body>"];
[html appendString:@"</html>"];
QLPreviewRequestSetDataRepresentation(preview,(CFDataRef)[html dataUsingEncoding:NSUTF8StringEncoding],kUTTypeHTML,(CFDictionaryRef)props);
}
return noErr;
}