Cocoa webview - html5 video fullscreen not working

≡放荡痞女 提交于 2019-12-04 09:41:22

问题


I'm trying to build an osx cocoa application with an integrated webkit webview to display a web page.

On the webpage are html5 video elements which the user should be able to play in fullscreen. But fullscreen just shows a black screen on mountain lion (10.8.2) audio is still playing but on osx lion it worked, is this a bug or did I miss something.

Minimum Sample:

Steps:

Create a cocoa app add a webview connect the property "web" and add the webkit framework

Code:

#AppDelegate.h

#import <Cocoa/Cocoa.h>
#import <WebKit/WebKit.h>

@interface AppDelegate : NSObject <NSApplicationDelegate>
@property (assign) IBOutlet NSWindow *window;
@property (weak) IBOutlet WebView *web;
@end

#AppDelegate.m

#import "AppDelegate.h"

@implementation AppDelegate

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
  NSString *html = @"<html><body><video src=\"http://video-js.zencoder.com/oceans-clip.mp4\" controls></body></html>";
  [[self.web mainFrame] loadHTMLString:html baseURL:nil];
}
@end

FIXED IN OSX 10.8.3:

Problem seems to be fixed in OSX 10.8.3 fullscreen is working now, even without sandboxing as it did prior to OSX 10.8.2


回答1:


I setup a project with the exact code you posted. This did indeed fail for me, and only showed a black screen in full-screen mode.

However this seems to be a sandboxing issue with WebKit. After sandboxing the app full screen worked as expected. (Using 10.8.2)

The app was sandbox without any additional permissions needed to make this work:




回答2:


could u try this code, hope it will work with u.. this works on iphone and i guess it will work on osx

header file

UIWebView *webView;

Implement file

NSString *html = @"<html><body><video src=\"http://video-js.zencoder.com/oceans-clip.mp4\" controls></body></html>";

webView =[[UIWebView alloc] initWithFrame:CGRectMake(14, 57, 670, 675)];
        [webView loadHTMLString:html baseURL:nil];
[self.view addSubview:webView];


来源:https://stackoverflow.com/questions/12536897/cocoa-webview-html5-video-fullscreen-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!