【发布时间】:2011-03-18 13:09:38
【问题描述】:
我目前正在使用 MPMoviePlayerController 在 iPhone 内播放视频,现在我希望在视图的一小块区域(而不是全屏)播放该视频。我认为有一种框架方式可以做到这一点,但我在某处找不到所需的教程。你遇到过吗?那太好了。
更新
我已经达到了这一点,但它仍然没有显示播放器在屏幕上播放。
-(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];
}
【问题讨论】:
-
顺便说一句 - 你设置的 onMSAASDone 函数的意图是什么,当视频结束时调用(上面的 NSNotificationCenter 调用)?只是好奇,因为我正在设置类似的东西,所以想了解您对该功能的计划。在我的实现中,我需要为下一个视频设置滚动到位并在当前视频完成后立即启动...
标签: iphone objective-c xcode mpmovieplayercontroller