我有一个名为 myMoviePlayer
的 MPMoviePlayerController
;我在我的应用加载时分配并初始化它:
NSString *moviePath = [bundle pathForResource:[movieName uppercaseString] ofType:@"mov" inDirectory:@"Videos"];
if(moviePath)
{
NSURL *movieURL = [NSURL fileURLWithPath:moviePath];
myMoviePlayer=[[MPMoviePlayerController alloc] initWithContentURL:movieURL];
[**myUI.view** setFrame:CGRectMake(80, 80, 600, 350)];
[self.view addSubview:myMoviePlayer.view];
myMoviePlayer.shouldAutoplay=NO;
}
我的应用程序中有两个 View ,名为 imageView
和 videoView
。我需要在 imageView
中隐藏 myMoviePlayer
并在我的 UI View 为 videoView
时再次显示它。
每次放映电影时,movieName
都会不同。
现在,每次我的 View 更改为电影 View 时,我都在分配和初始化 myVideoPlayer
。是否可以将新的视频 url 设置为 myMoviePlayer
而无需再次分配它?
最佳答案
是的,有:
[myMoviePlayer setContentURL:[NSURL URLWithString:aMovieUrl]];
关于objective-c - 更改 MPMoviePlayerController 实例的视频 url 而不是分配新的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6129632/