gpt4 book ai didi

objective-c - 用 MPMoviePlayer 播放电影——控件不会显示

转载 作者:行者123 更新时间:2023-11-28 17:45:21 24 4
gpt4 key购买 nike

我想播放带有控件的电影——播放、停止、快进等。我使用以下代码:

- (void)viewDidLoad
{
[super viewDidLoad];
NSURL *movieUrl = [NSURL fileURLWithPath:
[[NSBundle mainBundle] pathForResource:@"Spot"
ofType:@"mp4"]];

MPMoviePlayerController* myMovie=[[MPMoviePlayerController alloc]
initWithContentURL:movieUrl];

//disable scaling of our movie
myMovie.scalingMode = MPMovieScalingModeNone;
[myMovie.view setFrame: myView.bounds];
[myView addSubview: myMovie.view];

[[myMovie view] setFrame:[myView bounds]];
myMovie.initialPlaybackTime = 2.0;

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(movieFinished:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:myMovie];
myMovie.scalingMode = MPMovieScalingModeAspectFill;
myMovie.controlStyle = MPMovieControlStyleEmbedded;
[myMovie play];
// Do any additional setup after loading the view from its nib.
}

影片可以播放,但没有控件。谁能帮帮我?

最佳答案

试试这是否有效...

-(void)viewWillAppear:(BOOL)animated
{
NSString *urlStr = [[NSBundle mainBundle] pathForResource:@"Spot.mp4" ofType:nil];
NSURL *url = [NSURL fileURLWithPath:urlStr];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
[self.view addSubview:moviePlayer.view];
moviePlayer.view.frame = CGRectMake(0, 0, 300, 400);
[moviePlayer play];
}

您将获得所有控件。

关于objective-c - 用 MPMoviePlayer 播放电影——控件不会显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6282433/

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