1

I have tried the following code but this is not working. only a black screen is coming out as output.

    NSURL *url_vdo=[[NSURL alloc] initWithString:@"url"];
    moviePlayer=[[MPMoviePlayerController alloc] initWithContentURL:url_vdo];

    [moviePlayer.view setFrame: self.view.bounds];

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDonePressed:) name:MPMoviePlayerDidExitFullscreenNotification object:moviePlayer];
    moviePlayer.controlStyle=MPMovieControlStyleFullscreen;
    [moviePlayer play];
    [moviePlayer setFullscreen:YES animated:YES];

    [self.view addSubview:moviePlayer.view];
  • Did you get any error? Can you try this answer http://stackoverflow.com/a/22141471/468724 – Inder Kumar Rathore Jun 10 '15 at 04:45
  • What happen if you cut and paste the URL and copy into the browser or VLC? Are you sure that it contains data? Are you sure they are not protected? Have you tried to inspect the URL using Apple Media Streaming Validator? in which part of the code are you doing this, maybe view frame is still zero. – Andrea Jun 10 '15 at 04:47
  • no i am not getting any error.. only a black screen is flashing out and in the background it shows 'loading' then it stops.. i have checked the url in safari but it cant run the video.. but this url is working fine in the android app.. anyway thanks for ur help.. :) – debika mondal Jun 10 '15 at 05:05
  • Are you sure that is not protected and in a correct format to b streamed on iOS devices? Should it require a token? – Andrea Jun 10 '15 at 07:23
  • the url itself contains a token.. the token is getting associated with the url when am fetching the url by firing the web service.. – debika mondal Jun 10 '15 at 09:19

2 Answers2

1
NSURL *movieURL = [NSURL URLWithString:@"http://url.m3u8"];
MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];

if (mp)
{
    mp.view.frame = self.view.bounds;
    [self.view addSubview:mp.view];

    // save the movie player object
    [mp setFullscreen:YES];

    // Play the movie!
    [mp play];

    self.moviePlayer = mp;
}
Akshay Karanth
  • 347
  • 1
  • 13
0

Try to change this line:

[moviePlayer.view setFrame: self.view.bounds];

With this line:

[moviePlayer.view setFrame: self.view.frame];
ridvankucuk
  • 2,407
  • 1
  • 23
  • 41