Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7162879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:48:29+00:00 2026-05-28T13:48:29+00:00

I am playing youtube video on iPad via webView using this code. NSString *htmlString

  • 0

I am playing youtube video on iPad via webView using this code.

NSString *htmlString = [NSString stringWithFormat:@"<html>\
                        <body>\
                          <div id=\"player\"> </div>\
                          <script>\
                            var tag = document.createElement('script');\
                            tag.src = \"http://www.youtube.com/player_api\";\
                            var firstScriptTag = document.getElementsByTagName('script')[0];\
                            firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);\
                            var done = false;\
                            var player;\
                            function onYouTubePlayerAPIReady() {\
                               player = new YT.Player('player', {\
                               height: '%i',\
                               width: '%i',\
                               videoId: '%@',\
                               events: {\
                                'onReady': onPlayerReady,\
                                'onStateChange': onPlayerStateChange\
                                }\
                              });\
                            }\
                            function onPlayerReady(evt) {\
                                evt.target.playVideo();\
                            }\
                            function onPlayerStateChange(evt) {\
                                if(evt.data==0)\
                                {\
                                      window.location=\"http:\\end\";\
                                 }\
                             }\
                             function resizePlayer(width,height)\
                             {\
                                   player.setSize(width, height);\
                             }\
                           </script>\
                        </body>\
                     </html>",
                        height,width, videoID];

The problem is that when I’m installing my app via xCode it works fine, but when I’m using ipa file it don’t.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T13:48:30+00:00Added an answer on May 28, 2026 at 1:48 pm

    I have found what caused my problem.

    To allow my application to catch a moment when video reaches the end, I wrote Javascript code to redirect page to another URL. Then I implemented method from WebViewProtocol -(BOOL)webView:(UIWebView *) shouldStartLoadWithREquest:(NSURLRequest *) navigationType:(UIWebViewNavigationType)navigationType. The main idea was to close view when it tries to go to some special link, but I’ve made one mistake that for some unknown reason didn’t raised when I launch my app from XCode.

    Code with error:

    -(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request     navigationType:(UIWebViewNavigationType)navigationType
    {
         NSString *url = [[request URL] absoluteString];
    if ([url isEqualToString:@"http://youtube.com/end"])
    {
        [self onCloseVideo];
        [self unsubscribe];
        return = NO;
    } 
    //here on else I had to return YES but I didn't
    }
    

    Code without error:

    -(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request     navigationType:(UIWebViewNavigationType)navigationType
    {
         NSString *url = [[request URL] absoluteString];
         BOOL shouldStartRequest = YES;
    if ([url isEqualToString:@"http://youtube.com/end"])
    {
        [self onCloseVideo];
        shouldStartRequest = NO;
    }               
    
    return shouldStartRequest;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

right now i m using this code for playing youtube videos <?php // Replace
Am playing youtube video files by launching youtube: Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(text2.getText().toString()));
Using the code found here: How to popup a jquery window to play youtube
I found a method to play YouTube video on MPMoviePlayerController. For this simply need
Is there a way of detecting when a Youtube Video has finished playing from
I am using jquery to expand a div with a youtube embed, but when
I've been struggling with this for weeks now. On the iPad so 3.2. Using
Android 4.0 phones only have virtual buttons, which actually go invisible when playing youtube/video
I'm playing a youtube video from a specific view (not the view that appears
How I can Retrieve Recommended Video using YouTubeQuery I mean I am using YouTube

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.