简体   繁体   中英

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

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

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];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM