应用程序启动时IOS视频文件自动播放

时间:2012-07-16 07:58:32

标签: ios file video

如何在不必按下播放按钮的情况下自动播放视频。

1 个答案:

答案 0 :(得分:1)

 MPMoviePlayerController *player = [[MPMoviePlayerController alloc]initWithContentURL:[NSURL fileURLWithPath:@"yourVideoPath"]];
player.shouldAutoplay=YES;
player.view.frame = CGRectMake(0.0, 0.0, 480.0, 320.0);
player.movieSourceType = MPMovieSourceTypeFile;    
player.controlStyle = MPMovieControlStyleEmbedded;

[self.view  addSubview:player.view];

这应该可以解决您的问题。尝试和测试