Search code examples
iosiphonevideovideo-streamingmpmovieplayercontroller

Stream Video in iPhone


I have a table view with some movies:

enter image description here

When i select row from a table i do this:

Found movie for example is:

h t tp://.../movies/video/Adventure (Low-360p).mp4

NSString *URL = [foundMovie.movie stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *mediaURL = [NSURL URLWithString:URL];
MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:mediaURL];
[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(moviePlayBackDidFinish:)
                                             name:MPMoviePlayerPlaybackDidFinishNotification
                                           object:nil];

[mp setControlStyle:MPMovieControlStyleFullscreen];
[mp setMovieSourceType:MPMovieSourceTypeStreaming];
[mp setFullscreen:YES];

[self.view addSubview:[mp view]];

[mp prepareToPlay];
[mp play];

There is no error - nothing happens...


Solution

  •  mp = [[MPMoviePlayerController alloc] init];
    [mp prepareToPlay];
    mp.shouldAutoplay = YES;
    [mp setScalingMode:MPMovieScalingModeAspectFit];
     mp.contentURL = [NSURL URLWithString:YOUR_URL];
    mp.controlStyle = YES;
      mp.fullscreen = YES;
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(videoPlayBackDidFinish1:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
    
     [mp play];