gpt4 book ai didi

ios - 为什么不在一个 View 中初始化两个 MPMoviePlayerController?

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

系统:iOS 7.0

NSFileManager *fileManager = [NSFileManager defaultManager];
NSArray *docPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *audioPath = [[docPaths objectAtIndex:0] stringByAppendingPathComponent:@"test.mp4"];

if (YES == [fileManager fileExistsAtPath:audioPath])
{
MPMoviePlayerController *moviePlayer = nil;

//1
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL: [NSURL fileURLWithPath:audioPath]];
[moviePlayer setScalingMode:MPMovieScalingModeAspectFit];
[moviePlayer setControlStyle: MPMovieControlStyleEmbedded];
[moviePlayer.view setBackgroundColor:[UIColor clearColor]];
[moviePlayer.view setFrame: CGRectMake(20, 240, 80, 80)];
moviePlayer.shouldAutoplay = NO;
[moviePlayer prepareToPlay];
self.abcd = moviePlayer;
[self.view addSubview: moviePlayer.view];

//2
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL: [NSURL fileURLWithPath:audioPath]];
[moviePlayer setScalingMode:MPMovieScalingModeAspectFit];
[moviePlayer setControlStyle: MPMovieControlStyleEmbedded];
[moviePlayer.view setBackgroundColor:[UIColor clearColor]];
[moviePlayer.view setFrame: CGRectMake(20, 40, 80, 80)];
moviePlayer.shouldAutoplay = NO;
[moviePlayer prepareToPlay];
self.edf = moviePlayer;
[self.view addSubview: moviePlayer.view];

}

当我初始化两个MPMoviePlayerControllers时,为什么只显示一个?如果我只初始化#1,没问题,如果只初始化#2,也可以,但是如果我同时初始化#1和#2,它只显示#2。为什么会这样?谢谢。

最佳答案

您能否详细说明您所说的只会“显示”一个是什么意思?您可以添加这两个 View ,但根据 Apple 的文档:

Note: Although you can create multiple MPMoviePlayerController objects and present their views in your interface, only one movie player at a time can play its movie.

来源:https://developer.apple.com/library/ios/documentation/mediaplayer/reference/MPMoviePlayerController_Class/Reference/Reference.html

关于ios - 为什么不在一个 View 中初始化两个 MPMoviePlayerController?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25463856/

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