Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID
Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.

How to play youtube movie?

how can I play youtube movie?
Thanks
Post edited by Maor-S on

Replies

  • echtraechtra Posts: 5New Users
    Try to use imobilecinema or Take a look at this instructional post. I think it can help you.

    How to Watch YouTube Videos on Your iPhone | eHow.com

    I hope this can help.
  • Maor-SMaor-S Posts: 2New Users
    echtra;254024 said:
    Try to use imobilecinema or Take a look at this instructional post. I think it can help you.

    How to Watch YouTube Videos on Your iPhone | eHow.com

    I hope this can help.
    Ho no..
    I want to play Youtube inside my app.
  • listingboatlistingboat Posts: 55Registered Users
    Maor-S;254025 said:
    Ho no..
    I want to play Youtube inside my app.
    It's a little tricky, but I got this to work:

    What you need to do is put some custom HTML and embed the video in a UIWebView. I create a small UIWebView behind one of my UILabels in my view so the user doesn't really see it. For the code to play the video when the user clicks something like a View Video button, I use this:

    // This is a youtube video. Put up an invisible UIWebView
    if (youTubeWebView == nil) {
    youTubeWebView = [[UIWebView alloc] initWithFrame:CGRectMake(5.0, 5.0, 2.0, 2.0)];
    youTubeWebView.scalesPageToFit = YES;
    youTubeWebView.delegate = self;

    [self.view insertSubview:youTubeWebView atIndex:0];
    }
    NSString* embedHTML = @\"\"
    \"<html><head>\"
    \"<style type=\\"text/css\\">\"
    \"body {\"
    \"background-color: transparent;\"
    \"color: white;\"
    \"}\"
    \"</style>\"
    \"</head><body style=\\"margin:0\\">\"
    \"<object width=\\"%0.0f\\" height=\\"%0.0f\\"><param name=\\"movie\\" value=\\"%@&autoplay=1\\">\"
    \"</param><embed src=\\"%@&autoplay=1\\" type=\\"application/x-shockwave-flash\\" width=\\"%0.0f\\" height=\\"%0.0f\\"></embed></object>\"
    \"</body></html>\";
    NSString *html = [NSString stringWithFormat:embedHTML,
    youTubeWebView.frame.size.width,
    youTubeWebView.frame.size.height,
    thisFilm.trailerURL,
    thisFilm.trailerURL,
    youTubeWebView.frame.size.width,
    youTubeWebView.frame.size.height];
    [youTubeWebView loadHTMLString:html baseURL:nil];


    Then, you need the following code inside your controller to capture the UIWebView delegate call that the load finished:


    - (void)webViewDidFinishLoad:(UIWebView *)_webView {
    UIButton *b = [self findButtonInView:_webView];
    [b sendActionsForControlEvents:UIControlEventTouchUpInside];
    }


    Lastly, implement the findButtonInView method. This method recurses through the UIWebViews subviews looking for the button the user needs to click to start the video. This is so you can have the video auto play without the user having to press or see the embedded youtube view.


    - (UIButton *)findButtonInView:(UIView *)view {
    UIButton *button = nil;

    if ([view isMemberOfClass:[UIButton class]]) {
    return (UIButton *)view;
    }

    if (view.subviews && [view.subviews count] > 0) {
    for (UIView *subview in view.subviews) {
    button = [self findButtonInView:subview];
    if (button) return button;
    }
    }

    return button;
    }

  • zanquezanque Posts: 7New Users
    Hello

    i tried this method with iPhone and it worked fine.
    but its not working with iPad .. the video plays and you can hear the sound of the video but the youtube player is not showing.

    any thought why ?
  • listingboatlistingboat Posts: 55Registered Users
    zanque;414564 said:
    Hello

    i tried this method with iPhone and it worked fine.
    but its not working with iPad .. the video plays and you can hear the sound of the video but the youtube player is not showing.

    any thought why ?
    Hmm, I never tried this on an iPad, so not sure what would be happening here. Sorry.
Sign In or Register to comment.