I need to present an audio or video content in iOS.
Unfortunately, I do not receive the audio/video as URL, but as NSData with content-type (MIME type).
It seems UIWebView does not play the audio/video data properly when using the loadData:MIMEType:textEncodingName:baseURL:
only when using the loadRequest: (thanks Apple for this wonderful controller)
So I wanted to save the NSData to a temp file, but I don’t have the file extension (just MIME type).
What is the best way to accomplish this?
Maybe implement an audio/video player using some other iOS controls?
Thanks in advance.
If anyone wants to know here is the solution:
You need to use UTType functions
declared in a framework called MobileCoreServices.
The basic idea is to get the UTI from the MIME type, then get the extension from the UTI:
MIME-Type –> UTI –> file-extension.
An example of MIME-Type to UTI conversion can be found here.