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 7402423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:44:16+00:00 2026-05-29T04:44:16+00:00

I’m trying to implement a MPMedia player to play internet files. So far I

  • 0

I’m trying to implement a MPMedia player to play internet files. So far I have managed to open the media player with links to videos hosted by me. The problem starts when I try to load an url that doesn’t directly map to a file but instead gets redirected to the file.

The initial url looks like this: h*tp://www.example.com/numbers/numbers/numbers

and when I put it in my browser it is automatically changed for something like this: h*tp://www.example.com/numbers.mp4?to=numbers

When I use the initial url directly, just like I was doing with direct urls, the player comes up and inmediatly goes down without playing the video.

I have tried NSURLConnection to get the redirect url but I haven´t been able to get it working, somehow the method – connection:willSendRequest:redirectResponse: doesn’t get called. I think it may be because it has been removed in iOS 5, but I don’t know any alternatives, and this kind of problems are really undocumented.

Here is my code: (I’ve skipped the shortUrl initialization, it works).

NSLog(@"%@",shortUrl);

redirecionando=TRUE;

NSURLConnection * conection = [[NSURLConnection alloc]initWithRequest:[NSURLRequest requestWithURL:shortUrl] delegate:self];
[conection start];

while(self.redirecting);

self.moviePlayerController = [[MPMoviePlayerViewController alloc] initWithContentURL:finalurl];
moviePlayerController.view.frame = self.view.bounds;
[self presentMoviePlayerViewControllerAnimated:moviePlayerController];
moviePlayerController.moviePlayer.controlStyle = MPMovieControlStyleFullscreen;
moviePlayerController.moviePlayer.shouldAutoplay = YES;
[moviePlayerController.moviePlayer prepareToPlay];
moviePlayerController.moviePlayer.fullscreen=YES;



}

- (NSURLRequest *)connection: (NSURLConnection *)inConnection
             willSendRequest: (NSURLRequest *)inRequest
            redirectResponse: (NSURLResponse *)inRedirectResponse;
{
    finalurl=inRequest.URL; 
    self.redirecting=FALSE;
    return inRequest;
}

I know that this last methos isn’t getting called, I NSLogged it. Right now, when the above code gets executed it just waits because of the while loop.

By the way, I cannot use an external api to discover the redirection like http://longurl.org/ because the link returns a token access for the device that asks for
it.

Thanks in advance.

  • 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. Editorial Team
    Editorial Team
    2026-05-29T04:44:18+00:00Added an answer on May 29, 2026 at 4:44 am

    I solved it. It turs out that with the line:

    while(self.redirecting);
    

    I was bloking the main thread and thus preventing the method connection: willSendRequest: redirectResponse: from being called. I’ve solved it getting the code below that line and putting it into another function called from the redirect method. I’ve also had to modify the redirect method because it got called many times, even with the original url before arriving at the mp4.

    Thanks if you took the time to read the question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have thousands of HTML files to process using Groovy/Java and I need to
I am trying to loop through a bunch of documents I have to put
I have a bunch of posts stored in text files formatted in yaml/textile (from
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I am trying to render a haml file in a javascript response like so:

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.