gpt4 book ai didi

objective-c - UIViewController 中的 MPMoviePlayer

转载 作者:行者123 更新时间:2023-11-29 13:23:21 25 4
gpt4 key购买 nike

我在 UIWebView 中有一个 html 按钮,点击它会推送一个带有编程 segue 操作的 UIViewController。如何在使用 MPMoviePlayer 加载 UIViewController 时播放电影。此代码在 MPMoviePlayerViewController 中播放电影,而不是在 UIViewController 中播放电影。我想在 segue 推送的 UIViewController 中播放电影。

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
if ([request.URL.scheme isEqualToString:@"inapp"]) {
if ([request.URL.host isEqualToString:@"capture"]) {

[self performSegueWithIdentifier: @"SegueAction" sender: self];
NSURL * urlA1 = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"A1"ofType:@"mp4"]];
MPMoviePlayerViewController *playercontrollerA1 = [[MPMoviePlayerViewController alloc] initWithContentURL:urlA1];
playercontrollerA1.moviePlayer.repeatMode = MPMovieRepeatModeOne;
[self presentMoviePlayerViewControllerAnimated:playercontrollerA1];
playercontrollerA1.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
// do capture action
}
return NO;
}
return YES;
}

最佳答案

使用MPMoviePlayerController .您可以将其添加为 self.view 的 subview 。

例如:

MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL: myURL];
[player prepareToPlay];
[player.view setFrame: myView.bounds]; // player's frame must match parent's
[self.view addSubview: player.view];
// ...
[player play];

有关更多详细信息,请查看上面的苹果文档链接。

更新:

NSURL *urlA1 = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"A1"ofType:@"mp4"]]; 
MPMoviePlayerController *moviePlayer =
[[MPMoviePlayerController alloc] initWithContentURL:urlA1];
moviePlayer.repeatMode = MPMovieRepeatModeOne;
[self.view addSubview:moviePlayer.view];
moviePlayer.movieSourceType = MPMovieSourceTypeFile;
// do capture action

关于objective-c - UIViewController 中的 MPMoviePlayer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13810861/

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