Youtube, UIWebView and Overlay Controls

184 views
Skip to first unread message

YoryoBass

unread,
Jan 23, 2011, 1:16:41 PM1/23/11
to iPhoneWebDev
Hi everybody

I've been looking at this forum, but I have not found an answer to
this problem.
I managed to perfectly reproduce a YouTube video embedded in a
UIWebView. The video and audio work perfectly, but would need to
present the playback controls to get out the video at any time, or to
pause.

Any suggestions?


Thank you

Lee Andron

unread,
Jan 23, 2011, 11:28:58 PM1/23/11
to iphone...@googlegroups.com
Yoryo,

Could you share your code please, or a page for us to check?


I managed to perfectly reproduce a YouTube video embedded in a
UIWebView. The video and audio work perfectly, but would need to
present the playback controls to get out the video at any time, or to
pause.

--
-Lee Andron
617-272-0936
http://www.linkedin.com/in/andron

YoryoBass

unread,
Jan 24, 2011, 2:38:10 AM1/24/11
to iPhoneWebDev
For sure, this is my source code:

// Create the video preview frame inside the alertView
UIWebView *videoView;
CGRect videoFrame = CGRectMake(70, 120, 142, 129);
videoView = [[UIWebView alloc] initWithFrame:videoFrame];
[alertView addSubview:videoView];

// Create the html to embed in the alertView
NSString *embedHTML = @"\
<html><head>\
<style type=\"text/css\">\
body {\
background-color: transparent;\
color: white;\
}\
</style>\
</head><body style=\"margin:0\">\
<embed id=\"youtubeVideo\" src=\"%@\" type=\"application/x-shockwave-
flash\" \
width=\"%0.0f\" height=\"%0.0f\"></embed>\
</body></html>";
NSString *html = [NSString stringWithFormat:embedHTML, @"http://
www.youtube.com/watch?v=M9wSPssze5g", 142.0, 129.5];
[videoView loadHTMLString:html baseURL:nil];
------------------------------------------
With the code above, the video plays with no problem, but when I tap
the screen nothing occurs. When the video is finished, it closes and
we retutn to the app.

But with this one:

// Create the video preview frame inside the alertView
UIWebView *videoView;
CGRect videoFrame = CGRectMake(70, 120, 142, 129);
videoView = [[UIWebView alloc] initWithFrame:videoFrame];
[alertView addSubview:videoView];

// Create the preview
NSString *videoURLStr = [NSString stringWithFormat:@"http://
www.youtube.com/embed/%@?autoplay=0", @"M9wSPssze5g"];
NSURL* videoURL = [NSURL URLWithString:videoURLStr];
[videoView loadRequest:[NSURLRequest requestWithURL:videoURL]];

I can get the controls to pause the video but when it stops nothing
occurs...
Curious...

Giacomo Balli

unread,
Jan 27, 2011, 6:52:26 PM1/27/11
to iPhoneWebDev
use the <video> tag

On Jan 24, 8:38 am, YoryoBass <yoryob...@gmail.com> wrote:
> For sure, this is my source code:
>
> // Create the video preview frame inside the alertView
> UIWebView *videoView;
> CGRect videoFrame = CGRectMake(70, 120, 142, 129);
> videoView = [[UIWebView alloc] initWithFrame:videoFrame];
> [alertView addSubview:videoView];
>
> // Create the html to embed in the alertView
> NSString *embedHTML = @"\
> <html><head>\
> <style type=\"text/css\">\
> body {\
> background-color: transparent;\
> color: white;\}\
>
> </style>\
> </head><body style=\"margin:0\">\
> <embed id=\"youtubeVideo\" src=\"%@\" type=\"application/x-shockwave-
> flash\" \
> width=\"%0.0f\" height=\"%0.0f\"></embed>\
> </body></html>";
> NSString *html = [NSString stringWithFormat:embedHTML, @"http://www.youtube.com/watch?v=M9wSPssze5g", 142.0, 129.5];
> [videoView loadHTMLString:html baseURL:nil];
> ------------------------------------------
> With the code above, the video plays with no problem, but when I tap
> the screen nothing occurs. When the video is finished, it closes and
> we retutn to the app.
>
> But with this one:
>
> // Create the video preview frame inside the alertView
>                 UIWebView *videoView;
>                 CGRect videoFrame = CGRectMake(70, 120, 142, 129);
>                 videoView = [[UIWebView alloc] initWithFrame:videoFrame];
>                 [alertView addSubview:videoView];
>
>                 // Create the preview
>                 NSString *videoURLStr = [NSString stringWithFormat:@"http://www.youtube.com/embed/%@?autoplay=0", @"M9wSPssze5g"];

YoryoBass

unread,
Jan 28, 2011, 8:42:27 AM1/28/11
to iPhoneWebDev
How can I use this tag? Can you put an example? Thank you

Rémi Grumeau

unread,
Jan 28, 2011, 10:01:33 AM1/28/11
to iphone...@googlegroups.com
Hi Lee,

iPhone doesn't support video playback outside of QuickTime (where you
can on iPad) so perhaps you could use some native video object for
that... but i have no skills in native dev so i can't help more.

R.

Le 28 janv. 11 à 14:42, YoryoBass a écrit :

> --
> You received this message because you are subscribed to the Google
> Groups "iPhoneWebDev" group.
> To post to this group, send email to iphone...@googlegroups.com.
> To unsubscribe from this group, send email to iphonewebdev...@googlegroups.com
> .
> For more options, visit this group at http://groups.google.com/group/iphonewebdev?hl=en
> .
>

Giacomo Balli

unread,
Jan 28, 2011, 11:19:29 AM1/28/11
to iPhoneWebDev
did you care to look it up?
http://www.w3schools.com/html5/tag_video.asp

YoryoBass

unread,
Jan 28, 2011, 11:35:51 AM1/28/11
to iPhoneWebDev
For sure, and I will try tomorrow. But if someone of you have a
functional example it will be great :)

On Jan 28, 5:19 pm, Giacomo Balli <giacomoba...@gmail.com> wrote:
> did you care to look it up?http://www.w3schools.com/html5/tag_video.asp

Rémi Grumeau

unread,
Jan 28, 2011, 11:44:30 AM1/28/11
to iphone...@googlegroups.com
http://shapeshed.com/examples/HTML5-video-element/

Please next time, take 2min for some googling before... thx :)

Le 28 janv. 11 à 17:35, YoryoBass a écrit :

lavanya516 srcw

unread,
Feb 10, 2011, 3:27:24 AM2/10/11
to iphone...@googlegroups.com
search and download youtubedownloader s/w in google then you can
easily donload any video.

Reply all
Reply to author
Forward
0 new messages