Error while embedding a Youtube video in IOS.

jp78jp78 USMember

Hi,
So I have some code in an app to display a youtube video, however when I try to play it I got an error from youtube "An error has occured".

webView = new UIWebView(View.Bounds);
            View.AddSubview(webView);

            var url = "https://www.youtube.com/watch?v=avvBpyh1kdE"; // NOTE: https secure request
            webView.LoadRequest(new NSUrlRequest(new NSUrl(url)));

Could someone tell me how to fix this?
Thanks

Answers

  • DaveHuntDaveHunt USMember ✭✭✭✭✭

    See my response to your post in the other thread.

    The short answer - you're using the wrong URL.

  • jp78jp78 USMember

    @DaveHunt So I did what you said and my new code is:

    webView = new UIWebView(View.Bounds);
                View.AddSubview(webView);
    
    
                var url = "https://www.youtube.com/embed/avvBpyh1kdE"; // NOTE: https secure request
                string embed = "<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/avvBpyh1kdE\" frameborder=\"0\" allowfullscreen></iframe>";
                webView.LoadHtmlString(embed, null);
    

    and it still doesn't work :(.

  • VamsiValiveruVamsiValiveru USMember ✭✭

    I am getting string from web service which I need to show in iOS device on a web view. I am able to load the string on a web view but the video is missing.

    I have attached the text file

    This is my code

    webView.LoadHtmlString(welcomeText, new NSUrl(""));

Sign In or Register to comment.