Skip to content

Commit

Permalink
Merge pull request #5804 from avalonmediasystem/v7.7.x
Browse files Browse the repository at this point in the history
Extend player status check for add to playlist to iPad Safari (#5799)
  • Loading branch information
cjcolvar authored Apr 24, 2024
2 parents 59d6c8a + 173ec12 commit 1d0f26c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/views/media_objects/_add_to_playlist.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,11 @@ Unless required by applicable law or agreed to in writing, software distributed
let addToPlaylistBtn = document.getElementById('addToPlaylistBtn');
if(addToPlaylistBtn && addToPlaylistBtn.disabled) {
const USER_AGENT = window.navigator.userAgent;
// Identify both iPad and iPhone devices
const IS_MOBILE = (/Mobi/i).test(USER_AGENT);
const IS_IPHONE = (/iPhone/i).test(USER_AGENT);
const IS_TOUCH_ONLY = navigator.maxTouchPoints && navigator.maxTouchPoints > 2 && !window.matchMedia("(pointer: fine").matches;
// Identify browser is Safari
const IS_SAFARI = (/Safari/i).test(USER_AGENT);
/*
For iOS Safari, player.readyState() never gets to 4 until media playback is
Expand All @@ -215,7 +219,7 @@ Unless required by applicable law or agreed to in writing, software distributed
clicks the 'Add to Playlist' button immediately on page load, which does not
happen in mobile context.
*/
if((IS_MOBILE && IS_SAFARI && player?.player.src() != '')
if(((IS_TOUCH_ONLY || IS_IPHONE || IS_MOBILE) && IS_SAFARI && player?.player.src() != '')
|| player?.player.readyState() === 4) {
addToPlaylistBtn.disabled = false;
}
Expand Down

0 comments on commit 1d0f26c

Please sign in to comment.