Taking video from video camera and displaying it with MPMoviePlayerController IPhone SDK

StackOverflow https://stackoverflow.com/questions/1275878

  •  16-09-2019
  •  | 
  •  

Question

Has anyone tried taking a video from the camera and then using the video player provided to play it? When you take the video in portrait mode, sometimes the movie will play (when the player puts it in landscape mode) and when it puts it in portrait mode you cannot view the movie all you hear is sound,sometimes in landscape mode is flickers and does not play right, has anyone encountered this and found a way to fix it? My code to play the video looks like this:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    NSURL *urls=[info objectForKey:@"UIImagePickerControllerMediaURL"] ;
    moviePlayer = 
    [[MPMoviePlayerController alloc] initWithContentURL:[info urls]];

    if (moviePlayer)
    {

        [moviePlayer play];
    }
}

I checked settings on the docs nothing seems like it would fix this...Thanks

Was it helpful?

Solution

I think you are not using the proper NSURL object

NSURL *urls=[info objectForKey:@"UIImagePickerControllerMediaURL"] ; moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[info urls]];

It should be

moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL: urls];

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top