Catch exceptions on video tag play

This commit is contained in:
Lucas Fialho Zawacki 2018-05-29 17:51:50 +00:00
parent 32c587dc0d
commit cb5022681d

View File

@ -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);
}
}