* Remove unnecessary imports * Remove unneeded shared.scss code and mixins * Add kbd to top
67 lines
2.6 KiB
Text
67 lines
2.6 KiB
Text
<div itemscope itemtype="http://schema.org/VideoObject" class="video-player-header">
|
|
<% if meta_tags %>
|
|
<meta itemprop="uploadDate" content="<%= article.published_at %>" />
|
|
<meta itemprop="name" content="<%= article.title %>" />
|
|
<meta itemprop="description" content="<%= article.description %>" />
|
|
<meta itemprop="thumbnailUrl" content="<%= cloudinary(article.video_thumbnail_url, 880) %>" />
|
|
<meta itemprop="contentUrl" content="<%= article.video_source_url %>" />
|
|
<% minutes, seconds = article.video_duration_in_minutes.split(":") %>
|
|
<meta itemprop="duration" content="<%= format("PT%<minutes>sM%<seconds>sS", minutes: minutes, seconds: seconds) %>" />
|
|
<div id="video-player-source" data-source="<%= article.video_source_url %>"></div>
|
|
<% end %>
|
|
<script src="//content.jwplatform.com/libraries/b1zWy2iv.js" async></script>
|
|
<div id="video-player-<%= article.id %>" class="video-player"></div>
|
|
</div>
|
|
|
|
<script type="text/javascript" async>
|
|
function getParameterByName(name, url) {
|
|
if (!url) url = window.location.href;
|
|
name = name.replace(/[\[\]]/g, "\\$&");
|
|
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
|
|
results = regex.exec(url);
|
|
if (!results) return null;
|
|
if (!results[2]) return '';
|
|
return decodeURIComponent(results[2].replace(/\+/g, " "));
|
|
}
|
|
|
|
function timeToSeconds(hms) {
|
|
if (hms.length < 3) {
|
|
return hms
|
|
} else if (hms.length < 6) {
|
|
var a = hms.split(':')
|
|
return hms = (+a[0]) * 60 + (+a[1])
|
|
} else {
|
|
var a = hms.split(':')
|
|
return hms = (+a[0]) * 60 * 60 + (+a[1]) * 60 + (+a[2])
|
|
}
|
|
}
|
|
|
|
var waitingOnJWP<%= article.id %> = setInterval(function () {
|
|
if (typeof jwplayer !== 'undefined') {
|
|
clearInterval(waitingOnJWP<%= article.id %>);
|
|
var playerInstance = jwplayer("video-player-<%= article.id %>");
|
|
playerInstance.setup({
|
|
file: "<%= article.video_source_url %>",
|
|
mediaid: "<%= article.video_code %>",
|
|
autostart: <%= internal_navigation? %>,
|
|
image: "<%= cloudinary(article.video_thumbnail_url, 880) %>",
|
|
playbackRateControls: true,
|
|
tracks: [{
|
|
file: "<%= article.video_closed_caption_track_url %>",
|
|
label: "English",
|
|
kind: "captions",
|
|
"default": false
|
|
}]
|
|
});
|
|
var time = getParameterByName('t')
|
|
if (time) {
|
|
jwplayer().on('ready', function (event) {
|
|
jwplayer().play();
|
|
});
|
|
jwplayer().on('firstFrame', function () {
|
|
jwplayer().seek(timeToSeconds(time))
|
|
});
|
|
}
|
|
}
|
|
}, 2)
|
|
</script>
|