2016-02-24 127 views
1

我有一个SKVideoNode,像这样 -SKVideoNode.pause()不暂停视频

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代替,但调用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

为什么多个SO回答说,在SKVideoNode调用.pause.play的作品,即使在实现时,它实际上并没有正常工作。

暂停此视频中,我希望能够交换到一个新的视频播放器后,我已经得到了工作..它只是我不能删除或暂停该视频播放器。

见 - https://forums.developer.apple.com/thread/28470根据该交AVPlayer速率被覆盖,因而SKVideoNode不能暂停。

回答

0

我不得不暂停AVPlayerItem如此 -

playerThree.pause(); 

的伎俩。