【问题标题】:How to insert the QuickTime player bar into a custom QuickLook plugin?如何将 QuickTime 播放器栏插入自定义 QuickLook 插件?
【发布时间】:2012-06-15 11:13:46
【问题描述】:

这个问题很简单。我想模拟默认 OSX 的 Audio QuickLook 插件的行为,我需要 QuickTime Player,它通常位于预览窗口的底部。我也希望在使用我的自定义插件时也能听到我当前正在预览的文件的声音。

这里有一些代码(来自 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"];

        props=@{
            (__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;
}

【问题讨论】:

    标签: objective-c xcode macos quicktime quicklook


    【解决方案1】:

    使用 OSX 10.6.8 上的 Xcode 4.2,只需使用 &lt;audio&gt; 标记并使用其 &lt;src&gt; 属性加载文件(如果您还想在预览开始时播放音频)就可以获得该结果窗口,您只需将&lt;autoplay&gt; 属性设置为“true”)...不幸的是,现在在 Mavericks 上使用 Xcode 5.1,似乎既没有使用cid: 方案(您已经在示例代码中使用了该方案来加载@ 987654326@ 文件)完成了这项工作!

    只有reporting a bug to Apple 可以(可能)解决这个问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多