How to play movie with a URL using a custom NSURLProtocol?

As you know,play a movie with MPMoviePlayerController object using

[[MPMoviePlayerController alloc] initWithContentURL: aURL];

now ,i want to achieve a custom NSURLProtocol in which i will decrypt a movie source that had be encrypt by AlgorithmDES. Is that possibility? thanks for giving any ideas.need you help~

-------------Problems Reply------------

UPDATE: I spoke to Apple about this and it's not possible to use MPMoviePlayerController with a NSURLProtocol subclass at the moment!


I am not sure but it could be possible. I am currently working on something similar but haven't got it fully working. What I have found out is that MPMoviePlayerController interacts with my custom NSURLProtocol subclass BUT it seems to be important to take the HTTPHeaders of the NSURLRequest into account because they define a range of bytes the MPMoviePlayerController needs.

If you dump them in your NSURLProtocol subclass you will get something like this twice for the start:

2011-01-16 17:00:47.287 iPhoneApp[1177:5f03] Start loading from request: {
Range = "bytes=0-1";


So my GUESS is that as long as you can provide the correct range and return a mp4 file that can be played by the MPMoviePlayerController it should be possible!

EDIT: Here is a interesting link: Protecting resources in iPhone and iPad apps

The solution is to proxy requests through a local HTTP server. I have accomplished this using CocoaHTTPServer.

Look at the HTTPAsyncFileResponse example.

There is one more solution as of iOS 7. You can use a AVAssetResourceLoaderDelegate for AVAssetResourceLoader. But this will only work with AVPlayer then.

There is a demo project by apple called AVARLDelegateDemo have a look at it and you should find what you need. (I think linking to it isn't a good idea, so just search for it in the Developer Library on Then use any custom URL scheme (without declaring a NSURLProtocol) and handle that URL scheme in the AVAssetResourceLoaderDelegate.

If there is a huge interest I could provide a proof of concept gist.

Category:ios Views:2 Time:2010-12-08

Related post

  • Is it possible to get the url of the customer who uses our Web Service SOAP 2010-06-23

    I'm new to SOAP, I work with PHP5 and I got my wsdl file with some functions in my .php file. I'm wondering if I can get the url from the customer who uses my Web Service. I want to validate the url in a php function server-side. --------------Soluti

  • How to generate a `link_to` URL passing some custom parameters? 2011-08-12

    I am using Ruby on Rails 3.0.9 and I would like to generate a link_to URL passing some custom parameters. That is, having a articles_path ( I would like to generate something like the following: link_to 'Sample link

  • Getting the failed url in a custom 404 error page 2009-03-03

    Is it possible to get the URL of the failed request from a custom 404 error page? I'm using IIS to set the custom error page to a .net page where I want to process the failed request. I've tried using the url and referer attributes from the request o

  • How do I retrieve the referrer page url once a custom error page is returned 2010-09-09

    I'd like to capture the http referrer url following the rendering of a custom error page. I have this set in my web.config <customErrors mode="On"> <error statusCode="500" redirect="/StaticError.aspx" /> </customErrors> In the OnLoa

  • Problem:fetch product URL in a custom Module: Magento 2010-10-28

    I have created a custom module in magento and wants to show products with their URL as links. I am trying in this way :- for ($counter=0; $counter < count($products); $counter++) { $_product = Mage::getModel('catalog/product')->loadByAttribute(

  • more than one app has same URL Identifier for Custom URL Application? 2011-01-21

    i have used custom URL scheme in my Application to open it from another Application(which may be my Own).suppose more than one Application in App store may have The URL Identifier i used.if user has two Application with same URL Scheme, what will ope

  • How can I achieve clean URL routing with custom user ID? 2011-08-28

    My ASP.NET MVC site allows users to register and give themselves user names, which will be unique and allow others to browse their pages with a clean URL that includes their name, like Twitter, Facebook, LinkedIn etc. do. For example:

  • IIS 7 URL Rewriting Module: Custom response and Post Data 2011-08-31

    I need to create a rule that rewrites an URL to a new one with code 301 and at the same time brings a Custom Response with code 200 (HTTP OK) also redirecting the data submitted by POST. I did this with two rules, however the data submitted is lost a

  • Blackberry Bold- Unable to recognize URLs and even custom patterns registered 2011-11-23

    We have a blackberry native app deployed on a BB Bold 9700 (OS Version: 5.0) The app registers a custom pattern of the form string://[0-9]* . Strings matching the pattern get highlighted but the app does not receive the complete string Also, with URL

  • Phonegap ChildBrowser opening an External URL via a custom iOS url 2011-12-06

    I'm currently work on a iOS/Phonegap app, I want to have it respond to a custom URL scheme, so that when a person clicks on a link in the regular browser it will open the app to a specific page, where said page is actually an external page. The app t

  • What is the query parameter name embedded in the url on Google Custom Site Search? 2012-01-06

    I'm using Google Custom Site Search and I want the initial search box on every page in the navigation, but want the results to appear on a different page (searchresults.html), however its asking me for the query parameter name embedded in the url? Wh

  • How do I correctly handle redirects for bad url's to custom 404 page in ruby on rails? 2012-02-24

    Users can access others users profiles like this: My find method in my users controller will find the user by their username.. now if the user doesn't exist I want them re-directed to a custom 404 error page I'll make. I also want t

  • MVC Url Routing For custom url 2012-03-14

    I want to pass url link like http://localhost:24873/Jobs/[companyname] or http://localhost:24873/[companyname]/Jobs/ (Preferred) I tried below routing in global aspx file and created controller named Jobs and Index action result with Jobs folder but

  • Providing A Failover URL When A Custom URL Scheme Cannot Be Handled 2012-04-08

    I have two iPhone apps that I've built that have their own custom URLs and are in the app store. Let's call them App A and App B. App A's interface is a UIWebView that gets its markup from a remote server that I run. The behavior I want to implement

  • how to set the url of the custom node in drupal 7 2013-05-27

    I am new in drupal. I am creating the custom url using the code in drupal 7 and I wanna to set up the custom url. I'm using the following code. currently it is showing the url I wanna to set it

  • Playing a stream of bytes on the iPhone MPMoviePlayerController 2011-01-08

    I have a stream of bytes that represent a movie with H264 video and AAC audio. I got it using an RTMP library (rtmp-dump) and the data is comming through the network to my iOS simulator. However I have no idea how to show it to the user. The MPMovieP

  • How can I troubleshoot my custom URL scheme? 2008-12-03

    I set up a simple event handler as mentioned here, but it appears that the selector isn't called. I put the code in my AppDelegate class and wired up the delegate in IB. Tried putting in some NSLog()s and breakpoints in the selector I expect to be ca

  • How to create user-friendly and seo-friendly urls in jsf? 2009-12-17

    For example, I have class Article with methods getTitle () and getContent (). I also have ArticlesService with method getAllArticles (). How to create a list of links with meaningful names (formed with #{article.title})? Like:

  • How Can a Plugin Hijack a URL in WordPress? 2009-12-31

    Of course I can always edit WordPress' .htaccess file, but that would kind of make my WP plugin a little non-standard. Instead, what is the way to hijack a URL via a custom plugin in WordPress? For instance, let's say I want to build an elaborate pro

Copyright (C), All Rights Reserved.

processed in 0.101 (s). 11 q(s)