gpt4 book ai didi

iphone - MPMovieplayerController "Done"按钮

转载 作者:行者123 更新时间:2023-12-03 21:19:51 24 4
gpt4 key购买 nike

我在使用 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];
}
}

需要指导。

最佳答案

由于相关属性名为 controlStyle,因此您可以使用 mp.controlStyle=..;[mp setControlStyle:..];

对于第二个问题/问题,请参阅 mpmovieplayercontroller-audio-show-done-button以获得快速解决方案。

关于iphone - MPMovieplayerController "Done"按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5817309/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com