非常奇怪的错误!
好的,我正在使用Sprite Kit创建游戏。
在发布时播放视频(MPMoviePlayerController)
视频停止播放后,我使用以下代码将其解除...
- (void) moviePlayBackDidFinish:(NSNotification*)notification {
_moviePlayer = [notification object];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:_moviePlayer];
if ([_moviePlayer respondsToSelector:@selector(setFullscreen:animated:)])
{
_moviePlayer.fullscreen = NO;
[_moviePlayer.view removeFromSuperview];
}
}
视频删除后会显示游戏内容。
然而,只要游戏出现,背景图像就会显得模糊或对比度较低,但随后会在2-3秒左右再次显示正常。
我找到了问题的原因....
当我设置
时_moviePlayer.controlStyle = MPMovieControlStyleNone;
发生了这个错误。但是当我设置
_moviePlayer.controlStyle = MPMovieControlStyleFullscreen;
很好!!
我不想看到或有任何控制!..
有没有人遇到过这个/知道如何解决这个问题?
提前致谢
丹
答案 0 :(得分:1)
您可以使用MPMoviePlayerController
:
AVPlayer
NSString *resourcePath = [[NSBundle mainBundle] pathForResource:@"yourFileName" ofType:@"mp4"];
NSURL *videoURL = [NSURL fileURLWithPath:resourcePath];
AVPlayerItem *playerItem = [AVPlayerItem playerItemWithURL:videoURL];
AVPlayer *player = [AVPlayer playerWithPlayerItem:playerItem];
SKVideoNode *introVideo = [[SKVideoNode alloc] initWithAVPlayer: player];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerItemDidReachEnd:) name:AVPlayerItemDidPlayToEndTimeNotification object:[player currentItem]];
和
- (void)playerItemDidReachEnd:(NSNotification *)notification {
// Remove AVPlayer, remove Observer...
}