Catch exceptions on video tag play
This commit is contained in:
parent
32c587dc0d
commit
cb5022681d
@ -21,8 +21,21 @@ class VideoListItem extends Component {
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
if (this.videoTag && this.videoTag.paused) {
|
||||
this.videoTag.play();
|
||||
const playElement = (elem) => {
|
||||
if (elem.paused) {
|
||||
var p = elem.play();
|
||||
if (p && (typeof Promise !== 'undefined') && (p instanceof Promise)) {
|
||||
// Catch exception when playing video
|
||||
p.catch(function(e) {});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// This is here to prevent the videos from freezing when they're
|
||||
// moved around the dom by react, e.g., when changing the user status
|
||||
// see https://bugs.chromium.org/p/chromium/issues/detail?id=382879
|
||||
if (this.videoTag) {
|
||||
playElement(this.videoTag);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user