0
0
Fork 0

Revert "Feature - Prevents multiple audio/video attachments from being played at the same time (#24717)" (#28251)

This commit is contained in:
Claire 2023-12-19 06:08:52 +01:00 committed by GitHub
parent 8b1eeb2f90
commit 3598c2e1db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 140 deletions

View file

@ -20,7 +20,6 @@ import { formatTime, getPointerPosition, fileNameFromURL } from 'mastodon/featur
import { Blurhash } from '../../components/blurhash';
import { displayMedia, useBlurhash } from '../../initial_state';
import { currentMedia, setCurrentMedia } from '../../reducers/media_attachments';
import Visualizer from './visualizer';
@ -166,32 +165,15 @@ class Audio extends PureComponent {
}
togglePlay = () => {
const audios = document.querySelectorAll('audio');
audios.forEach((audio) => {
const button = audio.previousElementSibling;
button.addEventListener('click', () => {
if(audio.paused) {
audios.forEach((e) => {
if (e !== audio) {
e.pause();
}
});
audio.play();
this.setState({ paused: false });
} else {
audio.pause();
this.setState({ paused: true });
}
});
});
if (currentMedia !== null) {
currentMedia.pause();
if (!this.audioContext) {
this._initAudioContext();
}
this.audio.play();
setCurrentMedia(this.audio);
if (this.state.paused) {
this.setState({ paused: false }, () => this.audio.play());
} else {
this.setState({ paused: true }, () => this.audio.pause());
}
};
handleResize = debounce(() => {
@ -213,7 +195,6 @@ class Audio extends PureComponent {
};
handlePause = () => {
this.audio.pause();
this.setState({ paused: true });
if (this.audioContext) {