[英]iOS4 MPMoviePlayerController Embedding
I am using MPMoviePlayerController currently to play a video inside IPhone and now I wish to play this video in a small area of the view (not the full screen). 我目前正在使用MPMoviePlayerController在iPhone内播放视频,现在我希望在视图的一小块区域内播放此视频(不是全屏)。 I think there is a frame way of doing it but I couldn't find the required tutorial somewhere.
我认为有一种方法可以做到这一点,但我无法在某处找到所需的教程。 Have you been across any?
你遇到过吗? That would be great.
那很好啊。
UPDATED 更新
I have reached to this point but still it doesn't show the player to play on screen. 我已经达到了这一点,但它仍然没有显示播放器在屏幕上播放。
-(IBAction)startVideo {
//start video here
NSURL *path = [[NSURL alloc] initWithString:[self localVideoPath:NO]];
// Create custom movie player
MPMoviePlayerController *moviePlayer = [[[MPMoviePlayerController alloc] initWithContentURL:path] autorelease];
[moviePlayer setScalingMode:MPMovieScalingModeAspectFill];
[moviePlayer setControlStyle:MPMovieControlStyleNone];
[moviePlayer setFullscreen:FALSE];
// May help to reduce latency
[moviePlayer prepareToPlay];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(onMSAASDone:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
//---play partial screen---
//moviePlayer.view.frame = CGRectMake(0, 0, 200, 300);
moviePlayer.view.frame = image.frame;
//[[moviePlayer view] setFrame: [image bounds]];
[image removeFromSuperview];
[self.view addSubview:moviePlayer.view];
// Show the movie player as modal
//[self presentModalViewController:moviePlayer animated:YES];
// Prep and play the movie
[moviePlayer play];
}
Here is 'windowed' code... 这是'窗口'代码......
MPMoviePlayerController *player =
[[MPMoviePlayerController alloc]
initWithContentURL:[NSURL fileURLWithPath:url]];
[player setControlStyle:MPMovieControlStyleNone];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(movieFinishedCallback:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
[player setScalingMode:MPMovieScalingModeAspectFill];
[player setFullscreen:FALSE];
//---play partial screen---
player.view.frame = CGRectMake(0, 0, 200, 300);
[self.view addSubview:player.view];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.