How to play YouTube videos, not full-screen

I want to play a YouTube video in my iPhone app in a view or in a web view. I know that you can play embedded videos on the iPad, but I could not do it on the iPhone. As soon as the video starts playing, the movie player goes into full-screen mode, so my user interface is not displayed.

Does anyone know how to overcome this limitation? Are there any other apps that do this in the app store?

Thanks!

+4
source share
1 answer

Use this code to add a tube to your application.

To do this, you need to configure the web view in your view. Then call the loadHTMLString:baseURL: method on the UIWebView instance using some carefully crafted HTML containing a snippet of YouTube embedded player code and some supporting HTML to make sure the thumbnail of the video is displayed correctly. Set the base URL of your site’s URL (it doesn’t do anything here - usually UIWebView uses it to properly handle relative URLs).

 NSString *youTube = @"<html><head> <meta name = \"viewport\" content = \"initial-scale = 1.0, user-scalable = no, width = 212\"/></head> <body style=\"background:#F00;margin-top:0px;margin-left:0px\"> <div><object width=\"212\" height=\"172\"> <param name=\"movie\" value=\"http://www.youtube.com/v/oHg5SJYRHA0&f=gdata_videos&c=ytapi-my-clientID&d=nGF83uyVrg8eD4rfEkk22mDOl3qUImVMV6ramM\"></param> <param name=\"wmode\" value=\"transparent\"></param> <embed src=\"http://www.youtube.com/v/oHg5SJYRHA0&f=gdata_videos&c=ytapi-my-clientID&d=nGF83uyVrg8eD4rfEkk22mDOl3qUImVMV6ramM\" type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"212\" height=\"172\"></embed> </object></div></body></html>"; [webView loadHTMLString:youTube baseURL:[NSURL URLWithString:@"http://www.your-url.com"]]; 

Further link: YouTube

+1
source

All Articles