Skip to content

Commit

Permalink
removed setByKeyboard on tracks since it sets a wrong focus
Browse files Browse the repository at this point in the history
  • Loading branch information
digitas-git committed Apr 26, 2024
1 parent 59d81ca commit 73e50ce
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions src/js/features/tracks.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,12 @@ Object.assign(MediaElementPlayer.prototype, {
// if only one language then just make the button a toggle
if (t.options.toggleCaptionsButtonWhenOnlyOne && subtitles.length === 1) {
player.captionsButton.classList.add(`${t.options.classPrefix}captions-button-toggle`);
player.captionsButton.addEventListener('click', (e) => {
player.captionsButton.addEventListener('click', () => {
let trackId = 'none';
if (player.selectedTrack === null) {
trackId = player.getSubtitles()[0].trackId;
}
const keyboard = e.keyCode || e.which;
player.setTrack(trackId, (typeof keyboard !== 'undefined'));
player.setTrack(trackId);
});
} else {
const
Expand Down Expand Up @@ -436,9 +435,8 @@ Object.assign(MediaElementPlayer.prototype, {
/**
*
* @param {String} trackId, or "none" to disable captions
* @param {Boolean} setByKeyboard
*/
setTrack (trackId, setByKeyboard) {
setTrack (trackId) {
const
t = this,
radios = t.captionsButton.querySelectorAll('input[type="radio"]'),
Expand Down Expand Up @@ -478,12 +476,6 @@ Object.assign(MediaElementPlayer.prototype, {
const event = createEvent('captionschange', t.media);
event.detail.caption = t.selectedTrack;
t.media.dispatchEvent(event);

if (!setByKeyboard) {
setTimeout(function() {
t.getElement(t.container).focus();
}, 500);
}
},

/**
Expand Down Expand Up @@ -558,9 +550,7 @@ Object.assign(MediaElementPlayer.prototype, {
const target = document.getElementById(`${autoplayTrack.trackId}-btn`)
if (target) {
target.checked = true;
const clickEvent = createEvent('click', target);
clickEvent.stopPropagation();
target.dispatchEvent(clickEvent);
target.dispatchEvent(createEvent('click', target));
}
}
}
Expand Down

0 comments on commit 73e50ce

Please sign in to comment.