mirror of
https://github.com/status-im/react-native.git
synced 2025-01-15 03:56:03 +00:00
721763020a
Summary: HTML video elements can have the `autoplay` attribute, which forces them to play automatically whenever they load on the page. In this diff, I introduce a new prop `mediaPlaybackRequiresUserAction`, which allows us to control whether video or audio element autoplays even when `autoplay` is set. Reviewed By: shergin Differential Revision: D6382256 fbshipit-source-id: 617508653910d600bc43f7f68c6dfd17ab1b6dd8
41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
/**
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @format
|
|
* @flow
|
|
* @providesModule WKWebView
|
|
*/
|
|
|
|
const React = require('react');
|
|
|
|
const requireNativeComponent = require('requireNativeComponent');
|
|
|
|
const RCTWKWebView = requireNativeComponent('RCTWKWebView');
|
|
|
|
type RCTWKWebViewProps = {
|
|
allowsInlineMediaPlayback?: boolean,
|
|
mediaPlaybackRequiresUserAction?: boolean,
|
|
};
|
|
|
|
class WKWebView extends React.Component<RCTWKWebViewProps> {
|
|
componentWillReceiveProps(nextProps: RCTWKWebViewProps) {
|
|
this.showRedboxOnPropChanges(nextProps, 'allowsInlineMediaPlayback');
|
|
this.showRedboxOnPropChanges(nextProps, 'mediaPlaybackRequiresUserAction');
|
|
}
|
|
|
|
showRedboxOnPropChanges(nextProps: RCTWKWebViewProps, propName: string) {
|
|
if (this.props[propName] !== nextProps[propName]) {
|
|
console.error(`Changes to property ${propName} do nothing after the initial render.`);
|
|
}
|
|
}
|
|
|
|
render() {
|
|
return <RCTWKWebView {...this.props}/>;
|
|
}
|
|
}
|
|
|
|
module.exports = WKWebView;
|