Jim
Jim

Reputation: 181

iOS app playing youtube Video on Apple-TV

I would like to build an iOS app that plays youtube videos within a UIWebView window, with the UIWebView window being user selected to either play directly on the iOS device, or via AirPlay onto an AppleTV.

The website displayed in the UIWebView is my own website and will have javascript that will signal back-and-forth to the app when the youtube video ends (using the iframe api for youtube).

Question: Is the above possible?

Specifically, the iOS docs show that I need to have in the html within the UIWebView:

<video src="myPlaylist.m3u8"
   height="300" width="400"
   x-webkit-airplay="allow" >

<embed airplay="allow"
   src="movie.mov"
   width=400
   height=300
   mime-type="video/quicktime">
</embed>

</video>

But with YouTube iFrame api I do not have access to the < video > tag so how do I make the AirPlay icon visible to the user on the UIWebView window?

Thank you for any direction anyone can provide.

Jim

Upvotes: 0

Views: 293

Answers (1)

Eric Marschner
Eric Marschner

Reputation: 106

UIWebView uses it's own movie player controller to play embedded videos. It offers a setting to allow AirPlay:

    [_webView setMediaPlaybackAllowsAirPlay:YES];

When set to YES, you'll get the familiar AirPlay icon when the movie plays.

Upvotes: 1

Related Questions