我有SKVideoNode,就像.
let path = "videoURL";
let url = NSURL(string: path);
let asset = AVURLAsset(URL: url!,options: nil);
let playerItem = AVPlayerItem(asset: asset);
let playerThree = AVPlayer(playerItem: playerItem);
let videoNode = SKVideoNode(AVPlayer: playerThree);我想在按钮上暂停一下,按钮看起来是这样的-
var isPausedThreeSixty : Bool = false;
@IBAction func threesixty(sender: AnyObject){
if (videoPlayer == 1) { // check if video player is the 360 videoplayer
if(isPausedThreeSixty == false){ //check if video is paused, if not pause video on click
videoNode?.pause(); // pause video node
print("pause player");
isPausedThreeSixty == true;
}else{ //if app runs else, video is paused, proceed to unpause.
videoNode?.play();
print("play player");
isPausedThreeSixty = false;
}
}
}我的代码确实打印了pause player和play player,但是它不会暂停视频,我还读到应该暂停AVPlayer,但是当调用playerThree.pause();时,视频也不会暂停。
见- How do I control playback of a video in an iOS Sprite Kit SKVideoNode?
和
AVPlayer play SKVideoNode video ,I just can not control the playback
为什么多个答案说调用.pause和.play在SKVideoNode上是有效的,即使在实现它时,它实际上不起作用。
在暂停了这段视频之后,我想换到一个新的视频播放器,我已经开始工作了。只是我不能删除或暂停这个视频播放器。
见- https://forums.developer.apple.com/thread/28470根据这个帖子AVPlayer率正在被覆盖,因此SKVideoNode不能暂停。
发布于 2016-03-30 13:10:05
我不得不暂停AVPlayerItem所以-
playerThree.pause();成功了。
https://stackoverflow.com/questions/35597734
复制相似问题