IOS 视频播放--

来源:互联网 发布:sql 字段名为变量 编辑:程序博客网 时间:2024/05/01 08:46
在.h文件导入库文件
#import <MediaPlayer/MPMoviePlayerViewController.h>
在.m实现文件中
NSString *path=[[NSBundle mainBundle] pathForResource:@"name" ofType:@"mp4"];NSURL *URL = [[NSURL alloc] initFileURLWithPath:path];MPMoviePlayerViewController *_moviePlayerController = [[MPMoviePlayerViewController alloc] initWithContentURL:URL];[_moviePlayerController.moviePlayer play];

//自我控制MPMoviePlayerController的位置--
MPMoviePlayerController *moviePlayer;

NSString *moviePath = [[NSBundlemainBundle] pathForResource:@"name"

                                                         ofType:@"mp4"];

   if (moviePath) {

       NSURL *movieURL = [NSURLfileURLWithPath:moviePath];

        moviePlayer = [[MPMoviePlayerControlleralloc]

                      initWithContentURL:movieURL];

    }

    

    [[selfview] addSubview:[moviePlayerview]];

    

    [[moviePlayerview] setFrame:CGRectMake(0,44, 320, 378)];


    moviePlayer.controlStyle =MPMovieControlStyleDefault;

    [moviePlayer play];


原创粉丝点击