MPMoviePlayerViewController won't play movie, start and closes immediately

↘锁芯ラ 提交于 2019-12-06 16:24:16
Pratik

check below answer

https://stackoverflow.com/a/15586468/1713478

change url to below code

NSString *path =[[NSBundle mainBundle] pathForResource:@"NO" ofType:@"mp4"]; 
NSURL *url = [NSURL fileURLWithPath:path];

try this you will be succeed.

Try this..

NSString *databaseName = @"NO.mp4";
    NSArray *documentPaths =
    NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

    NSString *documentDir = [documentPaths objectAtIndex:0];
    NSString *databasePath = [documentDir stringByAppendingPathComponent:databaseName];
    NSURL *url = [NSURL fileURLWithPath:databasePath];
    MPMoviePlayerViewController *moviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
    moviePlayer.view.frame = CGRectMake(0, 0, 500, 500);
    moviePlayer.moviePlayer.shouldAutoplay=YES;
    moviePlayer.moviePlayer.controlStyle = MPMediaTypeMusicVideo;
    [moviePlayer.moviePlayer setFullscreen:YES animated:YES];
    [self.view addSubview:moviePlayer.view];
    [moviePlayer.moviePlayer play];
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!