Skip to main content

Gist c29e3f734511c0d726414bcb111afe51

✓ Published0🌍 Public
Aarielgk
Last edited Nov 15, 2016
Created on Oct 16, 2017

This example demonstrates how to play YouTube videos inside an Apple TV app by bridging JavaScript and native Swift code. It shows a custom `YTPlayerViewController` that uses the `AVKit` framework’s `AVPlayerViewController` alongside the `XCDYouTubeKit` library to retrieve video streams. The code integrates with `TVMLKit` by evaluating a JavaScript context, exposing a `playYTblock` function that native code can call. The video player selects from available stream qualities (e.g., HD720, medium360) and automatically dismisses the player when playback ends, using notification observers.

AI-generated description