2015-11-26 18:20:57 +03:00
|
|
|
/*
|
2016-01-07 07:06:39 +03:00
|
|
|
Copyright 2015, 2016 OpenMarket Ltd
|
2019-12-20 03:45:24 +03:00
|
|
|
Copyright 2019 The Matrix.org Foundation C.I.C.
|
2015-11-26 18:20:57 +03:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2019-12-08 15:16:17 +03:00
|
|
|
import React, {createRef} from 'react';
|
2017-12-26 04:03:18 +03:00
|
|
|
import PropTypes from 'prop-types';
|
2019-09-06 20:37:43 +03:00
|
|
|
import createReactClass from 'create-react-class';
|
2015-11-26 18:20:57 +03:00
|
|
|
|
2019-12-20 03:45:24 +03:00
|
|
|
export default createReactClass({
|
2015-11-26 18:20:57 +03:00
|
|
|
displayName: 'VideoFeed',
|
|
|
|
|
2016-01-11 18:28:59 +03:00
|
|
|
propTypes: {
|
2016-02-23 18:46:27 +03:00
|
|
|
// maxHeight style attribute for the video element
|
2017-12-26 04:03:18 +03:00
|
|
|
maxHeight: PropTypes.number,
|
2016-02-23 18:46:27 +03:00
|
|
|
|
2016-01-11 18:28:59 +03:00
|
|
|
// a callback which is called when the video element is resized
|
|
|
|
// due to a change in video metadata
|
2017-12-26 04:03:18 +03:00
|
|
|
onResize: PropTypes.func,
|
2016-01-11 18:28:59 +03:00
|
|
|
},
|
|
|
|
|
2020-03-31 23:12:52 +03:00
|
|
|
// TODO: [REACT-WARNING] Replace component with real class, use constructor for refs
|
2019-12-08 15:16:17 +03:00
|
|
|
UNSAFE_componentWillMount() {
|
|
|
|
this._vid = createRef();
|
|
|
|
},
|
|
|
|
|
2016-01-11 18:28:59 +03:00
|
|
|
componentDidMount() {
|
2019-12-08 15:16:17 +03:00
|
|
|
this._vid.current.addEventListener('resize', this.onResize);
|
2016-01-11 18:28:59 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
2019-12-08 15:16:17 +03:00
|
|
|
this._vid.current.removeEventListener('resize', this.onResize);
|
2016-01-11 18:28:59 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
onResize: function(e) {
|
2017-11-16 16:19:36 +03:00
|
|
|
if (this.props.onResize) {
|
2016-01-11 18:28:59 +03:00
|
|
|
this.props.onResize(e);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-11-26 18:20:57 +03:00
|
|
|
render: function() {
|
|
|
|
return (
|
2019-12-08 15:16:17 +03:00
|
|
|
<video ref={this._vid} style={{maxHeight: this.props.maxHeight}}>
|
2015-11-26 18:20:57 +03:00
|
|
|
</video>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|