@@klawischnigg
Oder du müsstest erst alle Player stoppen und danach den ausgewählten mit JavaScript starten, was die Komplexität des Scripts unnötig erhöht.
Ja natürlich wäre das die einfachste Lösung. Ich hatte das Problem des TO schon öfter und hab's genauso gelöst. Ich weiß nicht, wo Du da eine "Erhöhung der Komplexität" siehst…
Vergleiche meh
for (const mediaplayer of mediaplayers) {
if (!mediaplayer.paused && !mediaplayer.ended && mediaplayer.currentTime > 0) {
mediaplayer.pause();
mediaplayer.currentTime = 0;
}
}
event.target.play();
und
for (const mediaplayer of mediaplayers) {
if (mediaplayer !== event.target) {
mediaplayer.pause();
}
}
Du siehst es auch?
Abgesehen davon funtioniert @Hörnchen’s Lösung nur mit Zurücksetzen der Player, was – wie gesagt – nicht das gewünschte Verhalten sein dürfte.
🖖 Live long and prosper
--
“In my home, the America I love, the America I've written about, that has been a beacon of hope and liberty for 250 years, is currently in the hands of a corrupt, incompetent and treasonous administration. Tonight, we ask all who believe in democracy and the best of our American spirit, to rise with us, raise your voices against authoritarianism, and let freedom reign.”
— Bruce Springsteen, Manchester 2025-05-14
“In my home, the America I love, the America I've written about, that has been a beacon of hope and liberty for 250 years, is currently in the hands of a corrupt, incompetent and treasonous administration. Tonight, we ask all who believe in democracy and the best of our American spirit, to rise with us, raise your voices against authoritarianism, and let freedom reign.”
— Bruce Springsteen, Manchester 2025-05-14