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

标签 ios file video

如何无需按播放按钮即可自动播放视频。

最佳答案

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

这应该可以解决你的问题。经过尝试和测试

关于iOS视频文件在应用程序启动时自动播放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11500207/

相关文章:

java - 无法读取文件名

video - 在 ffmpeg 中可靠地获取 PTS 值?

iphone - 不同的 REST 客户端 = 不同的响应

ios - 在 SpriteKit 中已经运行 Action 时停止 Action

javascript - 在 Firefox 中设置 FileInput 的 FileList

file - 如何将一个文件增加十次

ios - 在 Objective C 的 FooterTableViewCell 中放置 View 的问题

ios - Swift 动态转换失败 UIPageViewController

shell - youtube-dl DASH 视频和音频,无需人工干预即可获得最高质量

javascript - html 的静音/取消静音图标