Fix audio and video items in account gallery in web UI (#14282)
* Fix audio and video items in account gallery in web UI - Fix audio items not using thumbnails - Fix video items not using custom thumbnails - Fix video items autoplaying like GIFs * Change audio and video items in account gallery to autoplay when opened in web UI * Fix code style issue
This commit is contained in:
parent
96e89d1ef4
commit
6cc5b822f5
5 changed files with 91 additions and 64 deletions
|
@ -37,6 +37,7 @@ class Audio extends React.PureComponent {
|
|||
backgroundColor: PropTypes.string,
|
||||
foregroundColor: PropTypes.string,
|
||||
accentColor: PropTypes.string,
|
||||
autoPlay: PropTypes.bool,
|
||||
};
|
||||
|
||||
state = {
|
||||
|
@ -259,6 +260,14 @@ class Audio extends React.PureComponent {
|
|||
this.setState({ hovered: false });
|
||||
}
|
||||
|
||||
handleLoadedData = () => {
|
||||
const { autoPlay } = this.props;
|
||||
|
||||
if (autoPlay) {
|
||||
this.audio.play();
|
||||
}
|
||||
}
|
||||
|
||||
_initAudioContext () {
|
||||
const context = new AudioContext();
|
||||
const source = context.createMediaElementSource(this.audio);
|
||||
|
@ -336,7 +345,7 @@ class Audio extends React.PureComponent {
|
|||
}
|
||||
|
||||
render () {
|
||||
const { src, intl, alt, editable } = this.props;
|
||||
const { src, intl, alt, editable, autoPlay } = this.props;
|
||||
const { paused, muted, volume, currentTime, duration, buffer, dragging } = this.state;
|
||||
const progress = (currentTime / duration) * 100;
|
||||
|
||||
|
@ -345,10 +354,11 @@ class Audio extends React.PureComponent {
|
|||
<audio
|
||||
src={src}
|
||||
ref={this.setAudioRef}
|
||||
preload='none'
|
||||
preload={autoPlay ? 'auto' : 'none'}
|
||||
onPlay={this.handlePlay}
|
||||
onPause={this.handlePause}
|
||||
onProgress={this.handleProgress}
|
||||
onLoadedData={this.handleLoadedData}
|
||||
crossOrigin='anonymous'
|
||||
/>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue