diff --git a/app/assets/javascripts/player_listeners.js b/app/assets/javascripts/player_listeners.js index c23daa5e9a..f79266fb84 100644 --- a/app/assets/javascripts/player_listeners.js +++ b/app/assets/javascripts/player_listeners.js @@ -50,21 +50,22 @@ function addActionButtonListeners(player, mediaObjectId, sectionIds) { const IS_MOBILE = (/Mobi/i).test(USER_AGENT); const IS_TOUCH_ONLY = navigator.maxTouchPoints && navigator.maxTouchPoints > 2 && !window.matchMedia("(pointer: fine").matches; const IS_SAFARI = (/Safari/i).test(USER_AGENT); - if (currentIndex != canvasIndex && - (((IS_TOUCH_ONLY || IS_IPHONE || IS_MOBILE) && IS_SAFARI && player?.player.src() != '') + if (currentIndex != canvasIndex && !player.player.canvasIsEmpty) { + if ((((IS_TOUCH_ONLY || IS_IPHONE || IS_MOBILE) && IS_SAFARI && player?.player.src() != '') || player?.player.readyState() >= 2)) { - canvasIndex = currentIndex; - buildActionButtons(player, mediaObjectId, sectionIds); - firstLoad = false; + canvasIndex = currentIndex; + buildActionButtons(player, mediaObjectId, sectionIds); + firstLoad = false; + } } /* - Update only share links when player.readyState() == 0 and player.src() is empty, - i.e. player is empty with an inaccessible media source + Update only share links when Canvas/section is empty, + i.e. Canvas/section is empty with an inaccessible media source */ - if (currentIndex != canvasIndex && player.player.readyState() === 0 - && player.player.src() === '') { + if (currentIndex != canvasIndex && player.player.canvasIsEmpty) { canvasIndex = currentIndex; setUpShareLinks(mediaObjectId, sectionIds); + resetAllActionButtons(); } /* Add player event listeners to update UI components on the page */ @@ -80,26 +81,13 @@ function addActionButtonListeners(player, mediaObjectId, sectionIds) { }); /* - Disable action buttons tied to player related information on player's 'dispose' event, so that the - user doesn't interact with them get corrupted data in the UI when player is loading the new section - media into it. Once the player is fully loaded these buttons are enabled as needed. + Disable action buttons tied to player related information on player's 'loadstart' event which functions + parallel to the player's src changes. So, that the user doesn't interact with them get corrupted data + in the UI when player is loading the new section media into it. + Once the player is fully loaded these buttons are enabled as needed. */ - player.player.on('dispose', () => { - currentSectionLabel = undefined; - let addToPlaylistBtn = document.getElementById('addToPlaylistBtn'); - $('#addToPlaylistPanel').collapse('hide'); - resetAddToPlaylistForm(); - if (addToPlaylistBtn) { - addToPlaylistBtn.disabled = true; - } - let thumbnailBtn = document.getElementById('thumbnailBtn'); - if (thumbnailBtn) { - thumbnailBtn.disabled = true; - } - let timelineBtn = document.getElementById('timelineBtn'); - if (timelineBtn) { - timelineBtn.disabled = true; - } + player.player.on('loadstart', () => { + resetAllActionButtons(); }); // Collapse sub-panel related to the selected option in the add to playlist form when it is collapsed @@ -114,6 +102,26 @@ function addActionButtonListeners(player, mediaObjectId, sectionIds) { } } } +/** + * Reset the action buttons and global variables on Canvas/section change + */ +function resetAllActionButtons() { + currentSectionLabel = undefined; + let addToPlaylistBtn = document.getElementById('addToPlaylistBtn'); + $('#addToPlaylistPanel').collapse('hide'); + resetAddToPlaylistForm(); + if (addToPlaylistBtn) { + addToPlaylistBtn.disabled = true; + } + let thumbnailBtn = document.getElementById('thumbnailBtn'); + if (thumbnailBtn) { + thumbnailBtn.disabled = true; + } + let timelineBtn = document.getElementById('timelineBtn'); + if (timelineBtn) { + timelineBtn.disabled = true; + } +} /** * Build action buttons for create thumbnail, add to playlist, create timeline and share diff --git a/package.json b/package.json index 09b1ea8f57..f92cedae1d 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "@babel/plugin-proposal-object-rest-spread": "^7.20.7", "@babel/preset-react": "^7.0.0", "@babel/runtime": "7", - "@samvera/ramp": "https://github.com/samvera-labs/ramp.git#v3.1.3", + "@samvera/ramp": "https://github.com/samvera-labs/ramp.git#25a519f3f78dd8579ff8b8b96e59c846879628c8", "babel-plugin-macros": "^3.1.0", "babel-plugin-transform-react-remove-prop-types": "^0.4.24", "buffer": "^6.0.3", diff --git a/yarn.lock b/yarn.lock index 35e82e9dc3..7a0aee8e90 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1440,12 +1440,12 @@ estree-walker "^2.0.2" picomatch "^2.3.1" -"@samvera/ramp@https://github.com/samvera-labs/ramp.git#v3.1.3": - version "3.1.3" - resolved "https://github.com/samvera-labs/ramp.git#6c233c2cd668856b6bce1ce63076455a9e58b0f2" +"@samvera/ramp@https://github.com/samvera-labs/ramp.git#25a519f3f78dd8579ff8b8b96e59c846879628c8": + version "3.1.2" + resolved "https://github.com/samvera-labs/ramp.git#25a519f3f78dd8579ff8b8b96e59c846879628c8" dependencies: "@rollup/plugin-json" "^6.0.1" - "@silvermine/videojs-quality-selector" "^1.2.4" + "@silvermine/videojs-quality-selector" "^1.3.1" mammoth "^1.4.19" manifesto.js "^4.1.0" mime-db "^1.52.0" @@ -1453,7 +1453,7 @@ sanitize-html "^2.10.0" videojs-markers-plugin "^1.0.2" -"@silvermine/videojs-quality-selector@^1.2.4": +"@silvermine/videojs-quality-selector@^1.3.1": version "1.3.1" resolved "https://registry.yarnpkg.com/@silvermine/videojs-quality-selector/-/videojs-quality-selector-1.3.1.tgz#23307dd3d5be442f7aa127c01820f16a3d9476a3" integrity sha512-uo6gs2HVG2TD0bpZAl0AT6RkDXzk9PnAxtmmW5zXexa2uJvkdFT64QvJoMlEUd2FUUwqYqqAuWGFDJdBh5+KcQ== @@ -4059,9 +4059,9 @@ make-dir@^3.0.2, make-dir@^3.1.0: semver "^6.0.0" mammoth@^1.4.19: - version "1.7.1" - resolved "https://registry.yarnpkg.com/mammoth/-/mammoth-1.7.1.tgz#8e0b19ba2ce6a0c364e3ea7afa0ecfe67b7f33d3" - integrity sha512-ckxfvNH5sUaJh+SbYbxpvB7urZTGS02jA91rFCNiL928CgE9FXXMyXxcJBY0n+CpmKE/eWh7qaV0+v+Dbwun3Q== + version "1.7.2" + resolved "https://registry.yarnpkg.com/mammoth/-/mammoth-1.7.2.tgz#e0efd28f46e183d807230e9ce119966dc6b1215e" + integrity sha512-MqWU2hcLf1I5QMKyAbfJCvrLxnv5WztrAQyorfZ+WPq7Hk82vZFmvfR2/64ajIPpM4jlq0TXp1xZvp/FFaL1Ug== dependencies: "@xmldom/xmldom" "^0.8.6" argparse "~1.0.3"