diff --git a/app/assets/javascripts/ramp_utils.js b/app/assets/javascripts/ramp_utils.js index 6b270c3f02..256c2bb8e5 100644 --- a/app/assets/javascripts/ramp_utils.js +++ b/app/assets/javascripts/ramp_utils.js @@ -221,7 +221,7 @@ function disableEnableCurrentTrack(activeTrack, currentTime, isSeeked, sectionTi $('#playlistitem_scope_track').closest('label').css('cursor', 'pointer'); } } else { - // Whena activeTrack is undefined, disable the current track option + // When activeTrack is undefined, disable the current track option $('#playlistitem_scope_track')[0].disabled = true; $('#current-track-name').text(''); $('#current-track-text').addClass('disabled-option'); diff --git a/app/javascript/components/MediaObjectRamp.jsx b/app/javascript/components/MediaObjectRamp.jsx index 8ad5acffff..dc70cb0ce2 100644 --- a/app/javascript/components/MediaObjectRamp.jsx +++ b/app/javascript/components/MediaObjectRamp.jsx @@ -39,8 +39,7 @@ const ExpandCollapseArrow = () => { }; const Ramp = ({ - base_url, - mo_id, + urls, master_files_count, has_structure, title, @@ -52,13 +51,33 @@ const Ramp = ({ has_transcripts }) => { const [manifestUrl, setManifestUrl] = React.useState(''); + const [startCanvasId, setStartCanvasId] = React.useState(); + const [startCanvasTime, setStartCanvasTime] = React.useState(); const [isClosed, setIsClosed] = React.useState(false); let expandCollapseBtnRef = React.useRef(); let interval; React.useEffect(() => { + const { base_url, fullpath_url } = urls; + // Split the current path from the time fragment in the format .../:id?t=time + let [ fullpath, start_time ] = fullpath_url.split('?t='); + // Split the current path in the format /media_objects/:mo_id/section/:mf_id + let [ _, __, mo_id, ___, start_canvas ] = fullpath.split('/'); + // Build the manifest URL let url = `${base_url}/media_objects/${mo_id}/manifest.json`; + + // Set start Canvas ID and start time in the state for Ramp + setStartCanvasId( + start_canvas && start_canvas != undefined + ? `${base_url}/media_objects/${mo_id}/manifest/canvas/${start_canvas}` + : undefined + ); + setStartCanvasTime( + start_time && start_time != undefined + ? parseFloat(start_time) + : undefined + ) setManifestUrl(url); // Attach player event listeners when there's structure @@ -120,7 +139,9 @@ const Ramp = ({ return ( + customErrorMessage='This page encountered an error. Please refresh or contact an administrator.' + startCanvasId={startCanvasId} + startCanvasTime={startCanvasTime}> { (cdl.enabled && !cdl.can_stream) diff --git a/app/views/media_objects/_item_view.html.erb b/app/views/media_objects/_item_view.html.erb index 65c77c04d5..4b09fe811a 100644 --- a/app/views/media_objects/_item_view.html.erb +++ b/app/views/media_objects/_item_view.html.erb @@ -41,8 +41,7 @@ Unless required by applicable law or agreed to in writing, software distributed
<%= react_component("MediaObjectRamp", { - base_url: request.protocol+request.host_with_port, - mo_id: @media_object.id, + urls: { base_url: request.protocol + request.host_with_port, fullpath_url: request.fullpath }, master_files_count: @media_object.master_files.size, has_structure: @media_object.master_files.any?{ |mf| mf.has_structuralMetadata? }, title: { content: render('title') }, @@ -85,20 +84,21 @@ Unless required by applicable law or agreed to in writing, software distributed function initTranscriptCheck() { let player = document.getElementById('iiif-media-player'); if(player) { - addPlayerEventListeners(player.player, () => { + addPlayerEventListeners(player, () => { clearInterval(timeCheck); }); } } function addPlayerEventListeners(player) { - player.on('loadedmetadata', () => { - transcriptCheck(); + player.player.on('loadedmetadata', () => { + let canvasindex = player.dataset['canvasindex']; + transcriptCheck(canvasindex); }); } - function transcriptCheck() { - let sectionId = sectionIds[canvasIndex]; + function transcriptCheck(canvasindex) { + let sectionId = sectionIds[canvasindex]; let transcriptTab = document.evaluate('//a[text()="Transcripts"]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; let detailTab = document.evaluate('//a[text()="Details"]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; diff --git a/app/views/media_objects/_share.html.erb b/app/views/media_objects/_share.html.erb index 8afc5ef84b..f36b838b7c 100644 --- a/app/views/media_objects/_share.html.erb +++ b/app/views/media_objects/_share.html.erb @@ -28,7 +28,7 @@ Unless required by applicable law or agreed to in writing, software distributed