1
0
Fork 0
forked from fedi/mastodon

Fix audio player not working when media files are hosted on a different domain (#14118)

This commit is contained in:
ThibG 2020-06-22 19:24:16 +02:00 committed by GitHub
parent c6904c0d37
commit aaf91abffa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -229,6 +229,7 @@ class Audio extends React.PureComponent {
window.addEventListener('scroll', this.handleScroll); window.addEventListener('scroll', this.handleScroll);
const img = new Image(); const img = new Image();
img.crossOrigin = 'anonymous';
img.onload = () => this.handlePosterLoad(img); img.onload = () => this.handlePosterLoad(img);
img.src = this.props.poster; img.src = this.props.poster;
} }
@ -236,6 +237,7 @@ class Audio extends React.PureComponent {
componentDidUpdate (prevProps, prevState) { componentDidUpdate (prevProps, prevState) {
if (prevProps.poster !== this.props.poster) { if (prevProps.poster !== this.props.poster) {
const img = new Image(); const img = new Image();
img.crossOrigin = 'anonymous';
img.onload = () => this.handlePosterLoad(img); img.onload = () => this.handlePosterLoad(img);
img.src = this.props.poster; img.src = this.props.poster;
} }
@ -606,6 +608,7 @@ class Audio extends React.PureComponent {
onPause={this.handlePause} onPause={this.handlePause}
onProgress={this.handleProgress} onProgress={this.handleProgress}
onTimeUpdate={this.handleTimeUpdate} onTimeUpdate={this.handleTimeUpdate}
crossOrigin='anonymous'
/> />
<canvas <canvas