fea-audio-player: limpiar el aviso de error cuando el audio sí llega a reproducir #221
@@ -125,6 +125,18 @@ add_action('wp_footer', function () {
|
|||||||
document.querySelectorAll('audio[data-fea-audio-track]').forEach(function (audio) {
|
document.querySelectorAll('audio[data-fea-audio-track]').forEach(function (audio) {
|
||||||
var fired = false;
|
var fired = false;
|
||||||
audio.addEventListener('play', function () {
|
audio.addEventListener('play', function () {
|
||||||
|
// La verificación pudo fallar en el primer intento (p.ej. audio.play()
|
||||||
|
// rechazado por política de autoplay tras el await de verificación) y
|
||||||
|
// dejar el mensaje de error en pantalla. Si el audio realmente rompe a
|
||||||
|
// reproducir -en este intento o en uno posterior desde los controles
|
||||||
|
// nativos-, ese es el estado real: limpiar el aviso y ocultar el botón.
|
||||||
|
var wrap = audio.closest('.fea-audio');
|
||||||
|
if (wrap) {
|
||||||
|
var status = wrap.querySelector('.fea-audio-status');
|
||||||
|
if (status) status.textContent = '';
|
||||||
|
var button = wrap.querySelector('[data-fea-audio-verified-play]');
|
||||||
|
if (button) button.hidden = true;
|
||||||
|
}
|
||||||
if (fired || typeof gtag !== 'function') return;
|
if (fired || typeof gtag !== 'function') return;
|
||||||
fired = true;
|
fired = true;
|
||||||
gtag('event', 'audio_play', {
|
gtag('event', 'audio_play', {
|
||||||
|
|||||||
Reference in New Issue
Block a user