gpt4 book ai didi

ios - SKVideoNode.pause() 不暂停视频

转载 作者:行者123 更新时间:2023-11-28 08:44:50 25 4
gpt4 key购买 nike

我有一个 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,但是当调用 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 rate 正在被覆盖,因此不能暂停 SKVideoNode。

最佳答案

我不得不暂停 AVPlayerItem 所以 -

playerThree.pause();

成功了。

关于ios - SKVideoNode.pause() 不暂停视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35597734/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com