Search code examples
youtubeios6

iOS6 play videos with webView (works in iOS5)


I used to play videos inside my iOS app using uiwebviews with the following code:

NSString *embedHTML = @"\
<html><head>\
<style type=\"text/css\">\
body {\
background-color: transparent;\
color: white;\
}\
</style>\
</head><body style=\"margin:0\">\
<embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \
width=\"%0.0f\" height=\"%0.0f\"></embed>\
</body></html>";

NSString *html = [NSString stringWithFormat:embedHTML, urlToOpen, frame.size.width, frame.size.height];
self.videoView = [[UIWebView alloc] initWithFrame:frame];
[videoView loadHTMLString:html baseURL:nil];
[self.videoView setDelegate:self];
[self.view addSubview:videoView];
[videoView release];

With iOS6 it doesn't work.

Has anybody find any solution to play youtube videos compiling with iOS6?

Thanks


Solution

  • Ok, Here is the answer.

    Use http://www.youtube.com/v/XXXXXXX

    instead of http://www.youtube.com/watch?v=XXXXXXX.

    find it here:

    iOS - UIWebView not working due to parsing error