Skip to content

Commit 7da42e3

Browse files
Crash--facebook-github-bot-4
authored andcommitted
add allowsInlineMediaPlayback prop to play inline html5 video
Summary: Allow an html5 video to be played inline. (see #3112) Closes facebook/react-native#3137 Reviewed By: svcscm Differential Revision: D2674318 Pulled By: nicklockwood fb-gh-sync-id: cf71e4039c7027f1468370ae3ddef6eb3e2d2d4f
1 parent 2a9a5fc commit 7da42e3

2 files changed

Lines changed: 33 additions & 15 deletions

File tree

Libraries/Components/WebView/WebView.ios.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,26 +100,41 @@ var WebView = React.createClass({
100100
onNavigationStateChange: PropTypes.func,
101101
startInLoadingState: PropTypes.bool, // force WebView to show loadingView on first load
102102
style: View.propTypes.style,
103+
103104
/**
104105
* Used for android only, JS is enabled by default for WebView on iOS
106+
* @platform android
105107
*/
106108
javaScriptEnabledAndroid: PropTypes.bool,
109+
107110
/**
108111
* Sets the JS to be injected when the webpage loads.
109112
*/
110113
injectedJavaScript: PropTypes.string,
111114

112115
/**
113-
* Used for iOS only, sets whether the webpage scales to fit the view and the
114-
* user can change the scale
116+
* Sets whether the webpage scales to fit the view and the user can change the scale.
117+
* @platform ios
115118
*/
116119
scalesPageToFit: PropTypes.bool,
117120

118121
/**
119122
* Allows custom handling of any webview requests by a JS handler. Return true
120123
* or false from this method to continue loading the request.
124+
* @platform ios
121125
*/
122126
onShouldStartLoadWithRequest: PropTypes.func,
127+
128+
/**
129+
* Determines whether HTML5 videos play inline or use the native full-screen
130+
* controller.
131+
* default value `false`
132+
* **NOTE** : "In order for video to play inline, not only does this
133+
* property need to be set to true, but the video element in the HTML
134+
* document must also include the webkit-playsinline attribute."
135+
* @platform ios
136+
*/
137+
allowsInlineMediaPlayback: PropTypes.bool,
123138
},
124139

125140
getInitialState: function() {
@@ -188,6 +203,7 @@ var WebView = React.createClass({
188203
onLoadingError={this.onLoadingError}
189204
onShouldStartLoadWithRequest={onShouldStartLoadWithRequest}
190205
scalesPageToFit={this.props.scalesPageToFit}
206+
allowsInlineMediaPlayback={this.props.allowsInlineMediaPlayback}
191207
/>;
192208

193209
return (

React/Views/RCTWebViewManager.m

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ @interface RCTWebViewManager () <RCTWebViewDelegate>
1818

1919
@end
2020

21-
@implementation RCTWebViewManager {
21+
@implementation RCTWebViewManager
22+
{
2223
NSConditionLock *_shouldStartLoadLock;
2324
BOOL _shouldStartLoad;
2425
}
@@ -32,18 +33,19 @@ - (UIView *)view
3233
return webView;
3334
}
3435

35-
RCT_REMAP_VIEW_PROPERTY(url, URL, NSURL);
36-
RCT_REMAP_VIEW_PROPERTY(html, HTML, NSString);
37-
RCT_REMAP_VIEW_PROPERTY(bounces, _webView.scrollView.bounces, BOOL);
38-
RCT_REMAP_VIEW_PROPERTY(scrollEnabled, _webView.scrollView.scrollEnabled, BOOL);
39-
RCT_REMAP_VIEW_PROPERTY(scalesPageToFit, _webView.scalesPageToFit, BOOL);
40-
RCT_EXPORT_VIEW_PROPERTY(injectedJavaScript, NSString);
41-
RCT_EXPORT_VIEW_PROPERTY(contentInset, UIEdgeInsets);
42-
RCT_EXPORT_VIEW_PROPERTY(automaticallyAdjustContentInsets, BOOL);
43-
RCT_EXPORT_VIEW_PROPERTY(onLoadingStart, RCTDirectEventBlock);
44-
RCT_EXPORT_VIEW_PROPERTY(onLoadingFinish, RCTDirectEventBlock);
45-
RCT_EXPORT_VIEW_PROPERTY(onLoadingError, RCTDirectEventBlock);
46-
RCT_EXPORT_VIEW_PROPERTY(onShouldStartLoadWithRequest, RCTDirectEventBlock);
36+
RCT_REMAP_VIEW_PROPERTY(url, URL, NSURL)
37+
RCT_REMAP_VIEW_PROPERTY(html, HTML, NSString)
38+
RCT_REMAP_VIEW_PROPERTY(bounces, _webView.scrollView.bounces, BOOL)
39+
RCT_REMAP_VIEW_PROPERTY(scrollEnabled, _webView.scrollView.scrollEnabled, BOOL)
40+
RCT_REMAP_VIEW_PROPERTY(scalesPageToFit, _webView.scalesPageToFit, BOOL)
41+
RCT_EXPORT_VIEW_PROPERTY(injectedJavaScript, NSString)
42+
RCT_EXPORT_VIEW_PROPERTY(contentInset, UIEdgeInsets)
43+
RCT_EXPORT_VIEW_PROPERTY(automaticallyAdjustContentInsets, BOOL)
44+
RCT_EXPORT_VIEW_PROPERTY(onLoadingStart, RCTDirectEventBlock)
45+
RCT_EXPORT_VIEW_PROPERTY(onLoadingFinish, RCTDirectEventBlock)
46+
RCT_EXPORT_VIEW_PROPERTY(onLoadingError, RCTDirectEventBlock)
47+
RCT_EXPORT_VIEW_PROPERTY(onShouldStartLoadWithRequest, RCTDirectEventBlock)
48+
RCT_REMAP_VIEW_PROPERTY(allowsInlineMediaPlayback, _webView.allowsInlineMediaPlayback, BOOL)
4749

4850
- (NSDictionary<NSString *, id> *)constantsToExport
4951
{

0 commit comments

Comments
 (0)