YoutubeKit icon indicating copy to clipboard operation
YoutubeKit copied to clipboard

Video plays only in storyboard and doesn't work with xib files.

Open zhaxylykbayev opened this issue 7 years ago • 2 comments
trafficstars

Hi!

So, it works without problems when I use Main.storyboard, but loading player in xib files fails. When I make self.view.addSubview(player) got youtubeIframeAPIFailedToLoad, but changing it to self.videoView = player solves it, but still video not appearing. Logs:

playerReady
player(_:didChangeState:):unstarted
player(_:didChangeState:):buffering
player(_:didChangeQuality:):hd720
apiDidChange

Creating player:

     player = YTSwiftyPlayer(
            frame: CGRect(x: 0, y: 0, width: self.videoView.frame.width, height: self.videoView.frame.height),
            playerVars: [.videoID("nKMk3q7bHjA"), .showFullScreenButton(false),.showControls(.showAfterPlaying), .showRelatedVideo(false), .playsInline(true), .showInfo(false), .showModestbranding(false)])

zhaxylykbayev avatar Nov 06 '18 06:11 zhaxylykbayev

It would be great if you could post here an example project with demonstration the issue.

mkdk avatar Nov 12 '18 08:11 mkdk

 fileprivate func setupYoutubeVideo(){
        youtubePlayer = YTSwiftyPlayer(
            frame: CGRect(x: 0, y: 0, width: backView.frame.size.width, height: backView.frame.size.height),
            playerVars: [
                .playsInline(true),
                .videoID(videoUrl.getVideoIDFromYoutubeUrl()),
                .loopVideo(false),
                .showRelatedVideo(false),
        ])
        youtubePlayer?.autoplay = true
        //youtubePlayer?.backgroundColor = .black
        self.backView.addSubview(youtubePlayer ?? YTSwiftyPlayer())
        //youtubePlayer?.delegate = self
        youtubePlayer?.loadPlayer()
    }

tiskender2 avatar Jun 07 '20 13:06 tiskender2

Please take a look at this related pull request: https://github.com/rinov/YoutubeKit/issues/28

rinov avatar May 21 '23 07:05 rinov