Search code examples
iosobjective-cmpmovieplayercontroller

How do I pass a NSInputStream to MPMoviePlayerController?


I have a video in the form of NSInputStream object that I'm using to write data to. I know MPMoviePlayerController can receive a file location with an NSURL, however what I'm wondering is whether it provides functionality for reading bytes from an NSInputStream, or how this could be achieved?

I've heard mentions about how NSURLProtocol can be used to set up a custom protocol to do this sort of thing, but I've not seen any samples with readable code.


Solution

  • I fear this is not possible. The init method

    - (id)initWithContentURL:(NSURL *)url
    

    requires a file URL. So, we cannot be sure that MPMoviePlayerController will use the URL loading system. Very likely it's using the File Manager API.

    The preferred API would be (anyway):

    - (id)initWithStream:(NSInputStream*)inputStream;
    

    I would suggest to file an enhancement request to Apple.