Ansh Vohra
Ansh Vohra

Reputation: 25

Cue only one video in YTPlayerView

I have integrated the iOS Helper Library for playing YouTube video in app. I am successfully able to play the video. But when the video finishes, I get buttons on the screen for next/previous video(recommended video list). I only want the reload button to appear on the screen for playing that particular video again.

I had tried to cue video but by doing that, the video doesn't play.

playerview.cueVideo(byId: videoid, startSeconds: 00, suggestedQuality: .large)

Can anyone please help me.

Upvotes: 0

Views: 342

Answers (1)

Droid Chris
Droid Chris

Reputation: 3783

Here is my method for playing a YouTube video with Swift 3:

func loadYouTubeVideo() {
    let YouTubeVideoID = getYouTubeVideoID(youTubeVideoURL: QRValue)
    if(YouTubeVideoID != nil) {
        print(YouTubeVideoID! + " is YouTube video ID")
        let playerVars = [
            "origin": "http://www.youtube.com",
            "start" : 0,
            "end" : 30,
            "playsinline" : 1,
            "showinfo" : 1,
            "rel" : 0,
            "modestbranding" : 1,
            "controls" : 0,
        ] as [String : Any]
        YouTubePlayerView.load(withVideoId: YouTubeVideoID, playerVars: playerVars)
    } else {
        launchYouTubeIssueAlertDialog()
    }
}

Upvotes: 1

Related Questions