SKVideoNode.pause()不会暂停视频

时间:2016-02-24 09:10:31

标签: ios swift video avplayer skvideonode

我有一个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 playerplay player,但它不会暂停视频,我还会读到我应该暂停AVPlayer,但是在调用时{ {1}}视频也未暂停。

请参阅 - 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

为什么多个SO答案表示在SKVideoNode上调用playerThree.pause();.pause有效,即使在实现它时,它实际上也不起作用。

暂停此视频后,我希望能够切换到新的视频播放器,我已经开始工作......只是因为我无法删除或暂停此视频播放器。

根据这篇文章看 - https://forums.developer.apple.com/thread/28470正在覆盖AVPlayer速率,因此无法暂停SKVideoNode。

1 个答案:

答案 0 :(得分:0)

我不得不暂停AVPlayerItem -

playerThree.pause();

诀窍。