-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* PoC for Ramp integration * Fix webpack error with new Ramp import * Remove MEJS references as much as possible without breaking playlists * Downgrade react to 17, render rails templates inside React component * Fix create timeline modal with Ramp integration * Set share panel URLs when canvas changes * Cleanup in some JS, HTML, and helper code and tar file for compiled ramp * Comment tests * Fix tests Co-author: [email protected]
- Loading branch information
Showing
17 changed files
with
467 additions
and
639 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 0 additions & 58 deletions
58
app/assets/javascripts/media_player_wrapper/mejs4_helper_quality.es6
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
// Copyright 2011-2022, The Trustees of Indiana University and Northwestern | ||
// University. Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software distributed | ||
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
// CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations under the License. | ||
|
||
|
||
/** | ||
* Get new timeline scopes for active section playing | ||
* @function getTimelineScopes | ||
* @param title title of the mediaobject | ||
* @return { [{string, int, string}], string } { [{label, tracks, t}], streamId } = [scope label, number of tracks, mediafragment], masterfile id | ||
*/ | ||
function getTimelineScopes(title) { | ||
let scopes = new Array(); | ||
let trackCount = 1; | ||
let currentPlayer = document.getElementById('iiif-media-player'); | ||
let duration = currentPlayer.player.duration(); | ||
let currentStructureItem = $('li[class="ramp--structured-nav__list-item active"]'); | ||
|
||
let item = currentStructureItem[0].childNodes[1] | ||
let label = item.text; | ||
let times = item.hash.split('#t=').reverse()[0]; | ||
let begin = parseFloat(times.split(',')[0]) || 0; | ||
let end = parseFloat(times.split(',')[1]) || duration; | ||
let streamId = item.pathname.split('/').reverse()[0]; | ||
scopes.push({ | ||
label: label, | ||
tracks: trackCount, | ||
t: `t=${begin},${end}`, | ||
}); | ||
|
||
let parent = currentStructureItem.closest('ul').closest('li'); | ||
while (parent.length > 0) { | ||
let next = parent.closest('ul').closest('li'); | ||
let tracks = parent.find('li a'); | ||
trackCount = tracks.length; | ||
begin = parseFloat(tracks[0].hash.split('#t=').reverse()[0].split(',')[0]) || 0; | ||
end = parseFloat(tracks[trackCount - 1].hash.split('#t=').reverse()[0].split(',')[1]) || ''; | ||
streamId = tracks[0].pathname.split('/').reverse()[0]; | ||
label = parent[0].childNodes[0].textContent; | ||
scopes.push({ | ||
label: next.length == 0 ? `${title} - ${label}` : label, | ||
tracks: trackCount, | ||
t: `t=${begin},${end}`, | ||
}); | ||
parent = next; | ||
} | ||
return { scopes: scopes.reverse(), streamId }; | ||
} | ||
|
||
function createTimestamp(secTime, showHrs) { | ||
let hours = Math.floor(secTime / 3600); | ||
let minutes = Math.floor((secTime % 3600) / 60); | ||
let seconds = secTime - minutes * 60 - hours * 3600; | ||
if (seconds > 59.9) { | ||
minutes = minutes + 1; | ||
seconds = 0; | ||
} | ||
seconds = parseInt(seconds); | ||
|
||
let hourStr = hours < 10 ? `0${hours}` : `${hours}`; | ||
let minStr = minutes < 10 ? `0${minutes}` : `${minutes}`; | ||
let secStr = seconds < 10 ? `0${seconds}` : `${seconds}`; | ||
|
||
let timeStr = `${minStr}:${secStr}`; | ||
if (showHrs || hours > 0) { | ||
timeStr = `${hourStr}:${timeStr}`; | ||
} | ||
return timeStr; | ||
} | ||
|
||
/** | ||
* Update section and lti section share links and embed code when switching sections | ||
* @function updateShareLinks | ||
* @return {void} | ||
*/ | ||
function updateShareLinks (e) { | ||
const sectionShareLink = e.detail.link_back_url; | ||
const ltiShareLink = e.detail.lti_share_link; | ||
const embedCode = e.detail.embed_code; | ||
$('#share-link-section') | ||
.val(sectionShareLink) | ||
.attr('placeholder', sectionShareLink); | ||
$('#ltilink-section') | ||
.val(ltiShareLink) | ||
.attr('placeholder', ltiShareLink); | ||
$('#embed-part').val(embedCode); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import React from 'react'; | ||
import { Transcript, IIIFPlayer, MediaPlayer, StructuredNavigation } from "@samvera/ramp"; | ||
import 'video.js/dist/video-js.css'; | ||
import "@samvera/ramp/dist/ramp.css"; | ||
import { Col, Row } from 'react-bootstrap'; | ||
import './Ramp.scss'; | ||
|
||
const Ramp = ({ base_url, mo_id, canvas_count, share, timeline }) => { | ||
const [transcriptsProp, setTrancsriptProp] = React.useState([]); | ||
const [manifestUrl, setManifestUrl] = React.useState(''); | ||
|
||
React.useEffect(() => { | ||
let url = `${base_url}/media_objects/${mo_id}/manifest.json`; | ||
setManifestUrl(url); | ||
buildTranscripts(url); | ||
}, []); | ||
|
||
const buildTranscripts = (url) => { | ||
let trProps = []; | ||
for(let i = 0; i < canvas_count; i++) { | ||
let canvasTrs = { canvasId: i, items: [] }; | ||
canvasTrs.items = [{ title: '', url }]; | ||
trProps.push(canvasTrs); | ||
} | ||
setTrancsriptProp(trProps); | ||
}; | ||
|
||
return ( | ||
<IIIFPlayer manifestUrl={manifestUrl}> | ||
<MediaPlayer enableFileDownload={false} /> | ||
<div className="ramp--rails-content"> | ||
{ timeline.canCreate && <div className="mr-1" dangerouslySetInnerHTML={{ __html: timeline.content }} /> } | ||
{ share.canShare && <div className="share-tabs" dangerouslySetInnerHTML={{ __html: share.content }} /> } | ||
</div> | ||
<Row> | ||
<Col> | ||
<StructuredNavigation /> | ||
</Col> | ||
<Col> | ||
<Transcript | ||
playerID="iiif-media-player" | ||
transcripts={transcriptsProp} | ||
/> | ||
</Col> | ||
</Row> | ||
</IIIFPlayer> | ||
); | ||
}; | ||
|
||
export default Ramp; |
Oops, something went wrong.