У меня есть класс PlayerWindow, который имеет функции базового управления видео.
В его конструкторе есть часть кода, которая добавляет обработчик кнопки воспроизведения:
Код: Выделить всё
this.#playButton.addEventListener('click', () => {
if (!this.#isPlaying) this.play();
else this.pause();
});
Код: Выделить всё
loadVideo(index) {
if (this.#videoIndex == index)
return;
this.#videoIndex = index;
const video = data.video[index];
this.#title.innerText = `${index + 1}. ${video.title}`;
this.preview = `image/preview/${video.preview}`;
this.title = `${video.title} - Windows Media Player`;
this.#link.href = video.link;
this.#video.src = `video/edit/${video.src}`;
this.#video.load();
this.reset();
}
Код: Выделить всё
play() {
this.#isPlaying = true;
this.#video.play();
this.#setSeekInterval();
this.#playButton.classList.add('blue-button-pause');
this.#playButton.classList.remove('blue-button-play');
}
Подробнее здесь: https://stackoverflow.com/questions/798 ... -the-video
Мобильная версия