I am trying to load videos/playlists from YouTube (personal account) using Swift. I added the YTPlayerView
class and iframe HTML file to do so but the videos are not loading.
I added a UIView in the storyboard and changed its class to YTPlayerView and created an IBOutlet.
Here's the code:
import UIKit
import youtube_ios_player_helper
class YTViewController: UIViewController, YTPlayerViewDelegate {
@IBOutlet var videoPlayer: YTPlayerView!
override func viewDidLoad() {
let videoID = "https://www.youtube.com/watch?v=M7lc1UVf-VE"
videoPlayer.loadVideoByURL(videoID, startSeconds: 0.0, suggestedQuality: .Small)
videoPlayer.playVideo()
}
}
As far as I read in the documentation this is what it takes to show a video. But when I run the app the UIView does nothing. How can I get this working?