Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Webview/Webkit not working as expected

This is my first time posting here. So please bear with me. I am using Webkit to display some content from YouTube in a webview.

Background

  • OS: OS X 10.10.2
  • SDK: OS X 10.10

Problem

As I stated before I am using a WebView to display content from YouTube. But, I ran into some problems which I have outlined below

When attempting to use the YouTube's fullscreen action this is what happens:

Test One (Using Flash):

Observations:

  • What wrong I did: When using the Flash player on YouTube’s website when I attempt to play a video everything worked fine. Additionally, when I clicked the YouTube video’s full screen button the window did appear in full screen. However, it is not completely fullscreen (the menu bar is still visible)

  • What I expected: I expected that the video would have entered fullscreen entirely. In Safari everything works fine.

Test Two (Using HTML5):

Observations:

  • What I did: When using the HTML5 player on YouTube’s website when I attempted to play a video everything worked fine. However, when I clicked the YouTube video’s full screen button nothing happened.

  • What I expected: I expected that the video would have entered full screen. I did noticed when doing this ins Safari everything worked as expected.

Can someone please help me with this matter? I have searched everywhere and found nothing.

Here is a sample of the test app I did to illustrate this problem:

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
    // Insert code here to initialize your application

    NSURL *url = [NSURL URLWithString:@"https://www.youtube.com"];
    NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
    [[[self webView] mainFrame] loadRequest:urlRequest];
    [self.window setContentView:self.webView];

    //When YES WebView will use Flash if available, else will use HTML5
    BOOL shouldUsePlugin = YES;

    if (shouldUsePlugin == YES) {

        [[[self webView] preferences] setPlugInsEnabled:YES];

        //Test 1: Using Flash

    } else {

        [[[self webView]preferences]setPlugInsEnabled:NO];

        //Test 2: Using HTML5

    }
}
like image 676
Soneé John Avatar asked Mar 24 '15 00:03

Soneé John


1 Answers

For those using the newer WebKit API (WKWebView) see my answer here: WKWebView Mac Browser Enable fullscreen html5? for enabling fullscreen on HTML5 content

like image 189
Soneé John Avatar answered Sep 24 '22 05:09

Soneé John