Chr*_*ina 4 cocoa-touch objective-c mpmovieplayercontroller ios
我有一个MPMoviePlayerController名字myMoviePlayer; 我的应用加载时分配并初始化它:
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;
}
Run Code Online (Sandbox Code Playgroud)
我的应用程序中有两个视图名为imageView和videoView.我需要隐藏myMoviePlayer的imageView,当我的UI视图是一次显示它videoView.
每次我放映电影,movieName都会有所不同.
现在,myVideoPlayer每次我的视图更改为电影视图时,我都会分配和初始化.是否可以在myMoviePlayer不重新分配的情况下设置新的视频网址?
Nic*_*ver 13
就在这里:
[myMoviePlayer setContentURL:[NSURL URLWithString:aMovieUrl]];
Run Code Online (Sandbox Code Playgroud)
只需设置的contentURL属性的的的MPMoviePlayerController实例.
Sharmain我遇到了你的问题......你需要设置contentURL,然后调用mpmovieplayercontroller的Play方法:
[myPlayer setContentURL:xyz];
[myPlayer play];
Run Code Online (Sandbox Code Playgroud)
请享用..!!
| 归档时间: |
|
| 查看次数: |
8347 次 |
| 最近记录: |