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

@ -22,7 +22,6 @@ import { Icon } from 'mastodon/components/icon';
import { playerSettings } from 'mastodon/settings';
import { displayMedia, useBlurhash } from '../../initial_state';
import { currentMedia, setCurrentMedia } from '../../reducers/media_attachments';
import { isFullscreen, requestFullscreen, exitFullscreen } from '../ui/util/fullscreen';
const messages = defineMessages({
@ -182,7 +181,6 @@ class Video extends PureComponent {
};
handlePause = () => {
this.video.pause();
this.setState({ paused: true });
};
@ -346,32 +344,11 @@ class Video extends PureComponent {
};
togglePlay = () => {
const videos = document.querySelectorAll('video');
videos.forEach((video) => {
const button = video.nextElementSibling;
button.addEventListener('click', () => {
if (video.paused) {
videos.forEach((e) => {
if (e !== video) {
e.pause();
}
});
video.play();
this.setState({ paused: false });
} else {
video.pause();
this.setState({ paused: true });
}
});
});
if (currentMedia !== null) {
currentMedia.pause();
if (this.state.paused) {
this.setState({ paused: false }, () => this.video.play());
} else {
this.setState({ paused: true }, () => this.video.pause());
}
this.video.play();
setCurrentMedia(this.video);
};
toggleFullscreen = () => {