I init a SKVideoNode
with an AVPlayer
instance, When I call AVPlayer's
play method, the video don't play. But It can play when I call SKVideoNode
instance's play method.
The reason I have to use AVPlayer
not SKVideoNode
is that I have to monitor the current video's currentTime, play ended status notification. but SKVideoNode
doesn't have these two property status.
self.player = [[AVPlayer alloc] initWithURL:url];
self.videoNode = [SKVideoNode videoNodeWithAVPlayer:self.player];
//some other code are not related to this, so I omit them here
//These two observe can work
[self.player.currentItem addObserver:self forKeyPath:@"status" options:NSKeyValueObservingOptionNew context:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(itemDidFinishPlaying) name:AVPlayerItemDidPlayToEndTimeNotification object:self.player.currentItem];
//[self.player play]; This method doesn't make video play
[self.videoNode play];//This one does