I have a UITableView full of thumbnails of videos on YouTube, and when they click on it, I want to automatically start full-screen viewing of videos on YouTube without the user seeing the added view or having to interact further than clicking on the thumbnail.
Basically, I don't want to see a YouTube video player with a red play icon at all.
I planned to use youtube-ios-player-helper / YTPlayerView for this, and I understand that it just uses a UIWebView , but I can't seem to figure out how to make it work.
If I create an instance variable in my class, set myself as a delegate and select a random video to view:
let YouTubePlayer = YTPlayerView() override func viewDidLoad() { super.viewDidLoad() YouTubePlayer.delegate = self YouTubePlayer.loadWithVideoId("apKJikXWU2g") ... }
and then when calling the delegate method:
func playerViewDidBecomeReady(playerView: YTPlayerView!) { YouTubePlayer.playVideo() }
But most of the time it either crashes in my AppDelegate with this message:
Nov 5, 23:34:44 rtcreporting [73827]: registration begins ...
November 5, 23:34:44 rtcreporting [73827]: setMessageLoggingBlock: called
Or it will work if I turn off the control points, but before I receive the video, I get a ton of messages about the restriction of the layout machine, showing that something is angry at some level.
Is it because I'm using a subclass of UIView without adding it to the view hierarchy?
How can I perform a YouTube auto-play behavior after a specific event without revealing an intermediate view?