【发布时间】:2024-01-05 02:25:01
【问题描述】:
我遇到了 MPMovieplayerController 的问题。
mp = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
现在,当我尝试编写 mp. 时,列表不包含“setControlStyle”!有什么问题吗?
如果我直接写[mp setControlStyle:MPMovieControlStyleFullscreen];,视频会全屏开始,但不会显示完成按钮,但是如果我点击完成按钮应该在的地方,它就可以正常工作!!!!
已编辑:
- (id)initWithPath:(NSString *)moviePath
{
// Initialize and create movie URL
if (self = [super init])
{
movieURL = [NSURL URLWithString:moviePath];
[movieURL retain];
}
return self;
}
- (void) readyPlayer
{
mp = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
[mp setControlStyle:MPMovieControlStyleFullscreen];
[mp setFullscreen:YES];
if ([mp respondsToSelector:@selector(loadState)])
{
// Register that the load state changed (movie is ready)
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayerLoadStateChanged:)
name:MPMoviePlayerLoadStateDidChangeNotification
object:nil];
}
else
{
[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePreloadDidFinish:)
name:MPMoviePlayerContentPreloadDidFinishNotification
object:nil];
}
// Register to receive a notification when the movie has finished playing.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:nil];
}
- (void) loadView
{
[self setView:[[[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]] autorelease]];
[[self view] setBackgroundColor:[UIColor blackColor]];
}
- (void) moviePlayerLoadStateChanged:(NSNotification*)notification
{
//[self makeButton];
// Unless state is unknown, start playback
if ([mp loadState] != MPMovieLoadStateUnknown)
{
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerLoadStateDidChangeNotification
object:nil];
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO];
// Rotate the view for landscape playback
[[self view] setBounds:CGRectMake(0, 0, 480, 320)];
[[self view] setCenter:CGPointMake(160, 240)];
[[self view] setTransform:CGAffineTransformMakeRotation(M_PI / 2)];
// Set frame of movieplayer
[[mp view] setFrame:CGRectMake(0, 0, 480, 320)];
// Add movie player as subview
[[self view] addSubview:[mp view]];
// Play the movie
[mp play];
}
}
需要指导。
【问题讨论】:
-
第二个问题,你是在设备上测试还是在模拟器上测试?你如何显示 MPMoviePlayerController - 也许你可以给我们看一些代码。
标签: iphone ios4 mpmovieplayercontroller