YoutubeKit
YoutubeKit copied to clipboard
Videos only plays audio
I am having a very bizarre issue where the video plays only audio but does not show: Here is the code:
import AppKit import CocoaYoutubeKit import WebKit
class PlayViewController: NSViewController {
private var player: YTSwiftyPlayer!
override func viewDidAppear() {
super.viewDidAppear()
self.view.window?.title = "Videos"
self.view.window?.titleVisibility = .hidden
self.view.window?.titlebarAppearsTransparent = true
self.view.window?.styleMask.insert(.fullSizeContentView)
}
override func viewDidLoad() {
super.viewDidLoad()
player = YTSwiftyPlayer(
frame: CGRect(x: 0, y: 0, width: 640, height: 480),
playerVars: [.playsInline(true), .videoID("61-AN084GH0"), .loopVideo(true), .showRelatedVideo(false), .showModestbranding(true), .showInfo(false), VideoEmbedParameter.showControls(VideoControlAppearance.hidden)])
player.autoplay = true
view.addSubview(player)
player.delegate = self as YTSwiftyPlayerDelegate
player.loadPlayer()
}
}
Video shows only if I replace "view.addSubview(player)" with "view = player" For info the class PlayViewController is a SplitViewItem Controller. When I don't use a SplitViewController with 2 child controllers and use only a regular ViewController this problem disappears.
Thank you for helping.