gpt4 book ai didi

video - MPMoviePlayerController 不会在完成播放后自动关闭电影 (ios 6)

转载 作者:行者123 更新时间:2023-11-28 21:39:13 25 4
gpt4 key购买 nike

我可能没有很好地表达我的标题,也许更正确的说法是我的 NSNotification 并没有在我的电影播放完毕后忽略它的 View 。我发现其他人也有这个问题,但没有解决方案,这似乎是我正在运行的 iOS 6 的问题。

视频播放完毕后,您需要按“完成”关闭,但我希望它自动关闭,因为我将在解决此问题后使用 MPMovieControlStyleNone。这是我的代码,删除了未使用的部分:`

#import "MovieViewController.h"

@interface MovieViewController ()

@end

@implementation MovieViewController

@synthesize moviePlayer = _moviePlayer;

- (IBAction)playMovie:(id)sender
{
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:@"TestMovie" ofType:@"mov"]];
_moviePlayer =
[[MPMoviePlayerController alloc]
initWithContentURL:url];

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:_moviePlayer];

_moviePlayer.controlStyle = MPMovieControlStyleDefault;
_moviePlayer.shouldAutoplay = YES;
[self.view addSubview:_moviePlayer.view];
[_moviePlayer setFullscreen:YES animated:NO];
}

- (void) moviePlayBackDidFinish:(NSNotification*)notification {

MPMoviePlayerController *player = [notification object];

[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];

if ([player
respondsToSelector:@selector(setFullscreen:animated:)])
{
[player.view removeFromSuperview];
}
}

@end`

最佳答案

我也遇到过这个问题在 moviePlayBackDidFinish 中修复只需添加

player.fullscreen = NO;

从父 View 中删除 View 之前

关于video - MPMoviePlayerController 不会在完成播放后自动关闭电影 (ios 6),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12786679/

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