2

The question is really simple. I would like to emulate the behaviour of the default OSX's Audio QuickLook plugin, and I need the QuickTime Player which normally stays at the bottom of its preview window. I would also like that when my custom plugin is being used I can also hear the sound of the file I'm currently previewing.

Here is some code (from the GeneratePreviewForURL.m file) that might be useful to understand better the context:

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;
}
user1447316
  • 123
  • 2
  • 11

1 Answers1

0

With Xcode 4.2 on OSX 10.6.8 it was possible to obtain that result simply using the <audio> tag and loading the file with its <src> attribute (if you also wanted to play the audio at the opening of the preview window you only had to set the <autoplay> attribute to "true")...unfortunately now with Xcode 5.1 on Mavericks, it seems that neither using the cid: scheme (that you already used in the sample code for loading the .png file) does the job!

Only reporting a bug to Apple could (probably) solve this problem.