Skip to content

Commit

Permalink
Merge pull request #5559 from avalonmediasystem/add-to-playlist-btnfix
Browse files Browse the repository at this point in the history
Use timeupdate event to enable add to playlist btn when loadedmetadata event misses
  • Loading branch information
cjcolvar authored Jan 10, 2024
2 parents 8ac795c + 7489bc0 commit 4b4bc7d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/views/media_objects/_add_to_playlist.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,15 @@ Unless required by applicable law or agreed to in writing, software distributed
player.on('loadedmetadata', () => {
enableAddToPlaylist();
});
// On MacOS, sometimes browsers miss the loadedmetadata event resulting not enabling the add to playlist button.
// This event listener gets fired right after the first segment loads into the player, and checks the button's
// state to enable it if the loadedmetadata event misses.
player.on('timeupdate', () => {
let addToPlaylistBtn = document.getElementById('addToPlaylistBtn');
if (addToPlaylistBtn && addToPlaylistBtn.disabled) {
addToPlaylistBtn.disabled = false;
}
})
player.on('seeked', () => {
if(getActiveItem() != undefined) {
activeTrack = getActiveItem(false);
Expand Down

0 comments on commit 4b4bc7d

Please sign in to comment.