Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 89243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:41:10+00:00 2026-05-10T22:41:10+00:00

My application is a viewer for a custom format, a zip file with a

  • 0

My application is a viewer for a custom format, a zip file with a well defined XML manifest and resources, such as images and movies. I use zlib to open up the zip file in memory and then proceed to display said resources.

One problem I’ve ran into is that I’m unable to properly display videos, apparently because QTMovie cannot determine the mime-type. Movie loaded from file ([QTMovie movieWithFile]) works perfectly. Loaded from memory ([QTMovie movieWithData]) refuses to work.

This makes sense, because lacking the file extension, QTMovie cannot determine the mime-type information. After a bit of a search, I’ve resorted to using QTDataReference in the following mannner:

NSData *movieData = ...read from memory...; QTDataReference *movieDataReference = [[QTDataReference alloc] initWithReferenceToData:movieData name:fileName MIMEType:@'video/x-m4v']; QTMovie *mov = [QTMovie movieWithDataReference:movieDataReference error:&err]; 

This works nicely, however hardcoding MIMEType is far from ideal. I have access to the filename and the extension, so I’ve attempted to find the mime-type using UTI (thanks to the nice folks on #macdev):

- (NSString*)mimeTypeForExtension:(NSString*)ext {      CFStringRef UTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension,(CFStringRef)ext,NULL);     return NSMakeCollectable(UTTypeCopyPreferredTagWithClass((CFStringRef)UTI,kUTTagClassMIMEType)); } 

This however doesn’t work. Clearly, there’s an internal OS X database of extensions and corresponding mime-types, somewhere. Otherwise from-disk movies wouldn’t work. How do I get access to it?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T22:41:10+00:00Added an answer on May 10, 2026 at 10:41 pm

    The problem your having is that m4v and m4p dont have a mime types registered with Launch Services (probably because the mime type for m4v and m4p is not standard). In any event, what you should probably do is handle edge cases like this and then check for nil when the function returns (in case the extension is both not registered and not handled by you).

    The other thing is that you’re leaking memory with your current use. I’m assuming you’re using garbage collection, but the first call creates a CFString that is never released. Here is a suggested implementation of your method:

    -(NSString*)mimeTypeForExtension:(NSString*)ext {     NSAssert( ext, @'Extension cannot be nil' );     NSString* mimeType = nil;      CFStringRef UTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension,         (CFStringRef)ext, NULL);     if( !UTI ) return nil;      CFStringRef registeredType = UTTypeCopyPreferredTagWithClass(UTI, kUTTagClassMIMEType);     if( !registeredType ) // check for edge case     {         if( [ext isEqualToString:@'m4v'] )             mimeType = @'video/x-m4v';         else if( [ext isEqualToString:@'m4p'] )             mimeType = @'audio/x-m4p';         // handle anything else here that you know is not registered     } else {         mimeType = NSMakeCollectable(registeredType);     }      CFRelease(UTI);     return mimeType; } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 64k
  • Answers 64k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Let's not mix ethics here. Bad ethics would be stealing… May 11, 2026 at 10:47 am
  • added an answer I have resolved this. Just make sure that the point… May 11, 2026 at 10:47 am
  • added an answer Here's an implementation of that exercise answer. Perhaps it helps.… May 11, 2026 at 10:47 am

Related Questions

My application is a viewer for a custom format, a zip file with a
My application is a vb6 executable, but some newer forms in the system are
Question says it all, really. My application is a time tracker. It's currently written
My application is preparing a cover-sheet for submitting documents by fax. I identify the
My application is implemented as a service (running under services.exe). I am adding a
In my web application there is a process that queries data from all over
I need to detect whether my application is running within a virtualized OS instance
My application is pretty simple: it starts up with a view controller that holds
Here is a simplified version of my application showing what I'm doing. /* in
My Java application is started from within a native program through java.dll. This native

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.