UIWebView allowsInlineMediaPlayback
@property(nonatomic) BOOL allowsInlineMediaPlayback
Discussion of [UIWebView allowsInlineMediaPlayback]
The default value on iPhone is NO.
In order for video to play inline, not only does this property need to be set on the view, but the video element in the HTML document must also include the webkit-playsinline attribute.
UIWebView allowsInlineMediaPlayback example.
- (void)viewDidLoad {
[super viewDidLoad];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"my url"]];
[request setValue:[NSString stringWithFormat:@"%@ (iPhone/%@)", [request valueForHTTPHeaderField:@"User-Agent"],@"1.0"] forHTTPHeaderField:@"User-Agent"];
request.cachePolicy = NSURLRequestReloadIgnoringLocalAndRemoteCacheData;
[_webView loadRequest:request];
_webView.allowsInlineMediaPlayback = YES;
[_webView setDataDetectorTypes:UIDataDetectorTypeAll];
}
[super viewDidLoad];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"my url"]];
[request setValue:[NSString stringWithFormat:@"%@ (iPhone/%@)", [request valueForHTTPHeaderField:@"User-Agent"],@"1.0"] forHTTPHeaderField:@"User-Agent"];
request.cachePolicy = NSURLRequestReloadIgnoringLocalAndRemoteCacheData;
[_webView loadRequest:request];
_webView.allowsInlineMediaPlayback = YES;
[_webView setDataDetectorTypes:UIDataDetectorTypeAll];
}
Example of [UIWebView allowsInlineMediaPlayback].
BOOL ok = [super application:application didFinishLaunchingWithOptions:launchOptions];
if (ok) {
self.webView.allowsInlineMediaPlayback = YES;
self.webView.mediaPlaybackRequiresUserAction = NO;
}
return ok;
if (ok) {
self.webView.allowsInlineMediaPlayback = YES;
self.webView.mediaPlaybackRequiresUserAction = NO;
}
return ok;
UIWebView allowsInlineMediaPlayback example.
HTML
<video id="player" width="480" height="320" webkit-playsinline>
Obj-C
webview.allowsInlineMediaPlayback = YES;
<video id="player" width="480" height="320" webkit-playsinline>
Obj-C
webview.allowsInlineMediaPlayback = YES;