|
@@ -144,6 +144,7 @@ type Props = {
|
144
|
144
|
*/
|
145
|
145
|
class Video extends Component<Props> {
|
146
|
146
|
_videoElement: ?Object;
|
|
147
|
+ _mounted: boolean;
|
147
|
148
|
|
148
|
149
|
/**
|
149
|
150
|
* Default values for {@code Video} component's properties.
|
|
@@ -189,6 +190,8 @@ class Video extends Component<Props> {
|
189
|
190
|
* @returns {void}
|
190
|
191
|
*/
|
191
|
192
|
componentDidMount() {
|
|
193
|
+ this._mounted = true;
|
|
194
|
+
|
192
|
195
|
if (this._videoElement) {
|
193
|
196
|
this._videoElement.volume = 0;
|
194
|
197
|
this._videoElement.onplaying = this._onVideoPlaying;
|
|
@@ -200,7 +203,14 @@ class Video extends Component<Props> {
|
200
|
203
|
// Ensure the video gets play() called on it. This may be necessary in the
|
201
|
204
|
// case where the local video container was moved and re-attached, in which
|
202
|
205
|
// case video does not autoplay.
|
203
|
|
- this._videoElement.play();
|
|
206
|
+ this._videoElement.play()
|
|
207
|
+ .catch(error => {
|
|
208
|
+ // Prevent uncaught "DOMException: The play() request was interrupted by a new load request"
|
|
209
|
+ // when video playback takes long to start and it starts after the component was unmounted.
|
|
210
|
+ if (this._mounted) {
|
|
211
|
+ throw error;
|
|
212
|
+ }
|
|
213
|
+ });
|
204
|
214
|
}
|
205
|
215
|
}
|
206
|
216
|
|
|
@@ -212,6 +222,7 @@ class Video extends Component<Props> {
|
212
|
222
|
* @returns {void}
|
213
|
223
|
*/
|
214
|
224
|
componentWillUnmount() {
|
|
225
|
+ this._mounted = false;
|
215
|
226
|
this._detachTrack(this.props.videoTrack);
|
216
|
227
|
}
|
217
|
228
|
|