Maxamilian Demian
Maxamilian Demian

Reputation: 311

YouTube-Player-iOS-Helper in Swift not working but no error

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

Answers (1)

Maxamilian Demian
Maxamilian Demian

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

Related Questions