gpt4 book ai didi

ios - MPMoviePlayerController 在 5 秒后停止播放视频

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:43:46 25 4
gpt4 key购买 nike

我尝试在 iOS 中播放视频,但它只播放了 5 秒的任何视频。这是我的代码:

NSBundle *bundle = [NSBundle mainBundle];
NSString *moviePath = [bundle pathForResource:@"videoviewdemo" ofType:@"mp4"];
NSURL *movieURL = [[NSURL alloc]initFileURLWithPath:moviePath];

MPMoviePlayerController *theMoviPlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
theMoviPlayer.controlStyle = MPMovieControlStyleFullscreen;
theMoviPlayer.controlStyle = MPMovieControlStyleDefault;
[theMoviPlayer setMovieSourceType:MPMovieSourceTypeFile];
theMoviPlayer.shouldAutoplay = YES;

theMoviPlayer.view.transform = CGAffineTransformConcat(theMoviPlayer.view.transform, CGAffineTransformMakeRotation(M_PI_2));

[theMoviPlayer.view setFrame:self.view.frame];
[theMoviPlayer prepareToPlay];
[self.view addSubview:theMoviPlayer.view];

最佳答案

声明一个ivar @property (nonatomic,strong) MPMoviePlayerController *myMovieController;

按如下方式将 MoviPlayer 分配给它,

self.myMovieController = theMoviPlayer;
[self.view addSubview: self.myMovieController.view];

然后播放电影。

问题似乎是 theMoviPlayer 没有保留。

关于ios - MPMoviePlayerController 在 5 秒后停止播放视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22219227/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com