视频加载
导入#import <MediaPlayer/MediaPlayer.h>
定义一个播放器的类MPMoviePlayerController *movie;
<span style="font-size:18px;"> NSString *str = [[NSBundle mainBundle] pathForResource:@"预告片" ofType:@"mp4"];
//把音频文件转换成url格式
NSURL *url = [NSURL fileURLWithPath:str];//初始化音频类 并且添加播放文件
if (movie==nil) {
movie=[[MPMoviePlayerController alloc]initWithContentURL:url];
}else{
[movie setContentURL:url];
}
movie.controlStyle=MPMovieControlStyleDefault;//播放器的类型是否显示快进,暂停,全屏等按键
movie.shouldAutoplay=NO; //是否自动播放
movie.repeatMode=MPMovieRepeatModeOne;//是否安指定位置开始播放
[movie setFullscreen:YES animated:YES]; //设置是否全屏显示
movie.scalingMode=MPMovieScalingModeAspectFit;//满屏是是否按比例
[movie.view setFrame:CGRectMake(30, 50, 320, 200)]; //播放器坐标大小
[self.view addSubview:movie.view];
[movie play]; //视频播放</span>
[movie stop];