Reputation: 311
I am using this library: https://github.com/youtube/youtube-ios-player-helper
And I am still getting just a blank UIView with no YouTube player when I run my project. No errors at all.
Here is my code:
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var ytPlayer: YTPlayerView!
override func viewDidLoad() {
super.viewDidLoad()
ytPlayer.loadVideoById("8PQQZ_nwk6s", startSeconds: 0.0, suggestedQuality: .Auto)
}
}
I have checked similar questions on Stack Overflow and have been unable to figure out the problem so far. Can anyone tell me what I am missing?
Upvotes: 1
Views: 2149
Reputation: 311
I figured out the problem!
First, I changed:
ytPlayer.loadVideoById("8PQQZ_nwk6s", startSeconds: 0.0, suggestedQuality: .Auto)
TO:
ytPlayer.loadVideoWithId("8PQQZ_nwk6s")
And that got me this error (which means the HTML file is not being found):
Error Domain=NSCocoaErrorDomain Code=258 "The file name is invalid."
Then, I removed YTPlayerView-iframe-player.html from my project, moved it into a folder named "Assets" and then included that folder into my project and it works now.
Upvotes: 4