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';
|
2015-11-26 18:20:57 +03:00
|
|
|
|
2020-08-29 14:14:16 +03:00
|
|
|
export default class VideoFeed extends React.Component {
|
|
|
|
static 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,
|
2020-08-29 14:14:16 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
2016-01-11 18:28:59 +03:00
|
|
|
|
2019-12-08 15:16:17 +03:00
|
|
|
this._vid = createRef();
|
2020-08-29 14:14:16 +03:00
|
|
|
}
|
2019-12-08 15:16:17 +03:00
|
|
|
|
2016-01-11 18:28:59 +03:00
|
|
|
componentDidMount() {
|
2019-12-08 15:16:17 +03:00
|
|
|
this._vid.current.addEventListener('resize', this.onResize);
|
2020-08-29 14:14:16 +03:00
|
|
|
}
|
2016-01-11 18:28:59 +03:00
|
|
|
|
|
|
|
componentWillUnmount() {
|
2019-12-08 15:16:17 +03:00
|
|
|
this._vid.current.removeEventListener('resize', this.onResize);
|
2020-08-29 14:14:16 +03:00
|
|
|
}
|
2016-01-11 18:28:59 +03:00
|
|
|
|
2020-08-29 14:14:16 +03:00
|
|
|
onResize = (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);
|
|
|
|
}
|
2020-08-29 14:14:16 +03:00
|
|
|
};
|
2016-01-11 18:28:59 +03:00
|
|
|
|
2020-08-29 14:14:16 +03:00
|
|
|
render() {
|
2015-11-26 18:20:57 +03:00
|
|
|
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>
|
|
|
|
);
|
2020-08-29 14:14:16 +03:00
|
|
|
}
|
|
|
|
}
|
2015-11-26 18:20:57 +03:00
|
|
|
|