Sentry in live only
This commit is contained in:
parent
0f8c6e147b
commit
c7ea13c0c7
628
changelog.md
628
changelog.md
File diff suppressed because it is too large
Load Diff
426
demo/dist/demo.js
vendored
426
demo/dist/demo.js
vendored
@ -3769,240 +3769,248 @@ var singleton = Raven;
|
|||||||
// Please see readme.md in the root or github.com/sampotts/plyr
|
// Please see readme.md in the root or github.com/sampotts/plyr
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
|
|
||||||
singleton.config('https://d4ad9866ad834437a4754e23937071e4@sentry.io/305555').install();
|
(function () {
|
||||||
|
var isLive = window.location.host === 'plyr.io';
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function () {
|
// Raven / Sentry
|
||||||
singleton.context(function () {
|
// For demo site (https://plyr.io) only
|
||||||
if (window.shr) {
|
if (isLive) {
|
||||||
window.shr.setup({
|
singleton.config('https://d4ad9866ad834437a4754e23937071e4@sentry.io/305555').install();
|
||||||
count: {
|
}
|
||||||
classname: 'button__count'
|
|
||||||
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
|
singleton.context(function () {
|
||||||
|
if (window.shr) {
|
||||||
|
window.shr.setup({
|
||||||
|
count: {
|
||||||
|
classname: 'button__count'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setup tab focus
|
||||||
|
var tabClassName = 'tab-focus';
|
||||||
|
|
||||||
|
// Remove class on blur
|
||||||
|
document.addEventListener('focusout', function (event) {
|
||||||
|
event.target.classList.remove(tabClassName);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Add classname to tabbed elements
|
||||||
|
document.addEventListener('keydown', function (event) {
|
||||||
|
if (event.keyCode !== 9) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delay the adding of classname until the focus has changed
|
||||||
|
// This event fires before the focusin event
|
||||||
|
setTimeout(function () {
|
||||||
|
document.activeElement.classList.add(tabClassName);
|
||||||
|
}, 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Setup the player
|
||||||
|
var player = new Plyr('#player', {
|
||||||
|
debug: true,
|
||||||
|
title: 'View From A Blue Moon',
|
||||||
|
iconUrl: '../dist/plyr.svg',
|
||||||
|
keyboard: {
|
||||||
|
global: true
|
||||||
|
},
|
||||||
|
tooltips: {
|
||||||
|
controls: true
|
||||||
|
},
|
||||||
|
captions: {
|
||||||
|
active: true
|
||||||
|
},
|
||||||
|
keys: {
|
||||||
|
google: 'AIzaSyDrNwtN3nLH_8rjCmu5Wq3ZCm4MNAVdc0c'
|
||||||
|
},
|
||||||
|
ads: {
|
||||||
|
enabled: true,
|
||||||
|
publisherId: '918848828995742'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
// Setup tab focus
|
// Expose for tinkering in the console
|
||||||
var tabClassName = 'tab-focus';
|
window.player = player;
|
||||||
|
|
||||||
// Remove class on blur
|
// Setup type toggle
|
||||||
document.addEventListener('focusout', function (event) {
|
var buttons = document.querySelectorAll('[data-source]');
|
||||||
event.target.classList.remove(tabClassName);
|
var types = {
|
||||||
});
|
video: 'video',
|
||||||
|
audio: 'audio',
|
||||||
|
youtube: 'youtube',
|
||||||
|
vimeo: 'vimeo'
|
||||||
|
};
|
||||||
|
var currentType = window.location.hash.replace('#', '');
|
||||||
|
var historySupport = window.history && window.history.pushState;
|
||||||
|
|
||||||
// Add classname to tabbed elements
|
// Toggle class on an element
|
||||||
document.addEventListener('keydown', function (event) {
|
function toggleClass(element, className, state) {
|
||||||
if (event.keyCode !== 9) {
|
if (element) {
|
||||||
return;
|
element.classList[state ? 'add' : 'remove'](className);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delay the adding of classname until the focus has changed
|
// Set a new source
|
||||||
// This event fires before the focusin event
|
function newSource(type, init) {
|
||||||
setTimeout(function () {
|
// Bail if new type isn't known, it's the current type, or current type is empty (video is default) and new type is video
|
||||||
document.activeElement.classList.add(tabClassName);
|
if (!(type in types) || !init && type === currentType || !currentType.length && type === types.video) {
|
||||||
}, 0);
|
return;
|
||||||
});
|
}
|
||||||
|
|
||||||
// Setup the player
|
switch (type) {
|
||||||
var player = new Plyr('#player', {
|
case types.video:
|
||||||
debug: true,
|
player.source = {
|
||||||
title: 'View From A Blue Moon',
|
type: 'video',
|
||||||
iconUrl: '../dist/plyr.svg',
|
title: 'View From A Blue Moon',
|
||||||
keyboard: {
|
sources: [{
|
||||||
global: true
|
src: 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.mp4',
|
||||||
},
|
type: 'video/mp4'
|
||||||
tooltips: {
|
}],
|
||||||
controls: true
|
poster: 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.jpg',
|
||||||
},
|
tracks: [{
|
||||||
captions: {
|
kind: 'captions',
|
||||||
active: true
|
label: 'English',
|
||||||
},
|
srclang: 'en',
|
||||||
keys: {
|
src: 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.en.vtt',
|
||||||
google: 'AIzaSyDrNwtN3nLH_8rjCmu5Wq3ZCm4MNAVdc0c'
|
default: true
|
||||||
},
|
}, {
|
||||||
ads: {
|
kind: 'captions',
|
||||||
enabled: true,
|
label: 'French',
|
||||||
publisherId: '918848828995742'
|
srclang: 'fr',
|
||||||
}
|
src: 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.fr.vtt'
|
||||||
});
|
}]
|
||||||
|
};
|
||||||
|
|
||||||
// Expose for tinkering in the console
|
break;
|
||||||
window.player = player;
|
|
||||||
|
|
||||||
// Setup type toggle
|
case types.audio:
|
||||||
var buttons = document.querySelectorAll('[data-source]');
|
player.source = {
|
||||||
var types = {
|
type: 'audio',
|
||||||
video: 'video',
|
title: 'Kishi Bashi – “It All Began With A Burst”',
|
||||||
audio: 'audio',
|
sources: [{
|
||||||
youtube: 'youtube',
|
src: 'https://cdn.plyr.io/static/demo/Kishi_Bashi_-_It_All_Began_With_a_Burst.mp3',
|
||||||
vimeo: 'vimeo'
|
type: 'audio/mp3'
|
||||||
};
|
}, {
|
||||||
var currentType = window.location.hash.replace('#', '');
|
src: 'https://cdn.plyr.io/static/demo/Kishi_Bashi_-_It_All_Began_With_a_Burst.ogg',
|
||||||
var historySupport = window.history && window.history.pushState;
|
type: 'audio/ogg'
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
|
||||||
// Toggle class on an element
|
break;
|
||||||
function toggleClass(element, className, state) {
|
|
||||||
if (element) {
|
|
||||||
element.classList[state ? 'add' : 'remove'](className);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set a new source
|
case types.youtube:
|
||||||
function newSource(type, init) {
|
player.source = {
|
||||||
// Bail if new type isn't known, it's the current type, or current type is empty (video is default) and new type is video
|
type: 'video',
|
||||||
if (!(type in types) || !init && type === currentType || !currentType.length && type === types.video) {
|
title: 'View From A Blue Moon',
|
||||||
return;
|
sources: [{
|
||||||
|
src: 'https://youtube.com/watch?v=bTqVqk7FSmY',
|
||||||
|
provider: 'youtube'
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case types.vimeo:
|
||||||
|
player.source = {
|
||||||
|
type: 'video',
|
||||||
|
sources: [{
|
||||||
|
src: 'https://vimeo.com/76979871',
|
||||||
|
provider: 'vimeo'
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the current type for next time
|
||||||
|
currentType = type;
|
||||||
|
|
||||||
|
// Remove active classes
|
||||||
|
Array.from(buttons).forEach(function (button) {
|
||||||
|
return toggleClass(button.parentElement, 'active', false);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Set active on parent
|
||||||
|
toggleClass(document.querySelector('[data-source="' + type + '"]'), 'active', true);
|
||||||
|
|
||||||
|
// Show cite
|
||||||
|
Array.from(document.querySelectorAll('.plyr__cite')).forEach(function (cite) {
|
||||||
|
cite.setAttribute('hidden', '');
|
||||||
|
});
|
||||||
|
document.querySelector('.plyr__cite--' + type).removeAttribute('hidden');
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (type) {
|
// Bind to each button
|
||||||
case types.video:
|
|
||||||
player.source = {
|
|
||||||
type: 'video',
|
|
||||||
title: 'View From A Blue Moon',
|
|
||||||
sources: [{
|
|
||||||
src: 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.mp4',
|
|
||||||
type: 'video/mp4'
|
|
||||||
}],
|
|
||||||
poster: 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.jpg',
|
|
||||||
tracks: [{
|
|
||||||
kind: 'captions',
|
|
||||||
label: 'English',
|
|
||||||
srclang: 'en',
|
|
||||||
src: 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.en.vtt',
|
|
||||||
default: true
|
|
||||||
}, {
|
|
||||||
kind: 'captions',
|
|
||||||
label: 'French',
|
|
||||||
srclang: 'fr',
|
|
||||||
src: 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.fr.vtt'
|
|
||||||
}]
|
|
||||||
};
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case types.audio:
|
|
||||||
player.source = {
|
|
||||||
type: 'audio',
|
|
||||||
title: 'Kishi Bashi – “It All Began With A Burst”',
|
|
||||||
sources: [{
|
|
||||||
src: 'https://cdn.plyr.io/static/demo/Kishi_Bashi_-_It_All_Began_With_a_Burst.mp3',
|
|
||||||
type: 'audio/mp3'
|
|
||||||
}, {
|
|
||||||
src: 'https://cdn.plyr.io/static/demo/Kishi_Bashi_-_It_All_Began_With_a_Burst.ogg',
|
|
||||||
type: 'audio/ogg'
|
|
||||||
}]
|
|
||||||
};
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case types.youtube:
|
|
||||||
player.source = {
|
|
||||||
type: 'video',
|
|
||||||
title: 'View From A Blue Moon',
|
|
||||||
sources: [{
|
|
||||||
src: 'https://youtube.com/watch?v=bTqVqk7FSmY',
|
|
||||||
provider: 'youtube'
|
|
||||||
}]
|
|
||||||
};
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case types.vimeo:
|
|
||||||
player.source = {
|
|
||||||
type: 'video',
|
|
||||||
sources: [{
|
|
||||||
src: 'https://vimeo.com/76979871',
|
|
||||||
provider: 'vimeo'
|
|
||||||
}]
|
|
||||||
};
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set the current type for next time
|
|
||||||
currentType = type;
|
|
||||||
|
|
||||||
// Remove active classes
|
|
||||||
Array.from(buttons).forEach(function (button) {
|
Array.from(buttons).forEach(function (button) {
|
||||||
return toggleClass(button.parentElement, 'active', false);
|
button.addEventListener('click', function () {
|
||||||
|
var type = button.getAttribute('data-source');
|
||||||
|
|
||||||
|
newSource(type);
|
||||||
|
|
||||||
|
if (historySupport) {
|
||||||
|
window.history.pushState({ type: type }, '', '#' + type);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Set active on parent
|
// List for backwards/forwards
|
||||||
toggleClass(document.querySelector('[data-source="' + type + '"]'), 'active', true);
|
window.addEventListener('popstate', function (event) {
|
||||||
|
if (event.state && 'type' in event.state) {
|
||||||
// Show cite
|
newSource(event.state.type);
|
||||||
Array.from(document.querySelectorAll('.plyr__cite')).forEach(function (cite) {
|
|
||||||
cite.setAttribute('hidden', '');
|
|
||||||
});
|
|
||||||
document.querySelector('.plyr__cite--' + type).removeAttribute('hidden');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bind to each button
|
|
||||||
Array.from(buttons).forEach(function (button) {
|
|
||||||
button.addEventListener('click', function () {
|
|
||||||
var type = button.getAttribute('data-source');
|
|
||||||
|
|
||||||
newSource(type);
|
|
||||||
|
|
||||||
if (historySupport) {
|
|
||||||
window.history.pushState({ type: type }, '', '#' + type);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
// List for backwards/forwards
|
// On load
|
||||||
window.addEventListener('popstate', function (event) {
|
if (historySupport) {
|
||||||
if (event.state && 'type' in event.state) {
|
var video = !currentType.length;
|
||||||
newSource(event.state.type);
|
|
||||||
|
// If there's no current type set, assume video
|
||||||
|
if (video) {
|
||||||
|
currentType = types.video;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Replace current history state
|
||||||
|
if (currentType in types) {
|
||||||
|
window.history.replaceState({
|
||||||
|
type: currentType
|
||||||
|
}, '', video ? '' : '#' + currentType);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If it's not video, load the source
|
||||||
|
if (currentType !== types.video) {
|
||||||
|
newSource(currentType, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// On load
|
|
||||||
if (historySupport) {
|
|
||||||
var video = !currentType.length;
|
|
||||||
|
|
||||||
// If there's no current type set, assume video
|
|
||||||
if (video) {
|
|
||||||
currentType = types.video;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Replace current history state
|
|
||||||
if (currentType in types) {
|
|
||||||
window.history.replaceState({
|
|
||||||
type: currentType
|
|
||||||
}, '', video ? '' : '#' + currentType);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If it's not video, load the source
|
|
||||||
if (currentType !== types.video) {
|
|
||||||
newSource(currentType, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
// Google analytics
|
// Google analytics
|
||||||
// For demo site (https://plyr.io) only
|
// For demo site (https://plyr.io) only
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
if (window.location.host === 'plyr.io') {
|
if (isLive) {
|
||||||
(function (i, s, o, g, r, a, m) {
|
(function (i, s, o, g, r, a, m) {
|
||||||
i.GoogleAnalyticsObject = r;
|
i.GoogleAnalyticsObject = r;
|
||||||
i[r] = i[r] || function () {
|
i[r] = i[r] || function () {
|
||||||
(i[r].q = i[r].q || []).push(arguments);
|
(i[r].q = i[r].q || []).push(arguments);
|
||||||
};
|
};
|
||||||
i[r].l = 1 * new Date();
|
i[r].l = 1 * new Date();
|
||||||
a = s.createElement(o);
|
a = s.createElement(o);
|
||||||
m = s.getElementsByTagName(o)[0];
|
m = s.getElementsByTagName(o)[0];
|
||||||
a.async = 1;
|
a.async = 1;
|
||||||
a.src = g;
|
a.src = g;
|
||||||
m.parentNode.insertBefore(a, m);
|
m.parentNode.insertBefore(a, m);
|
||||||
})(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');
|
})(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');
|
||||||
window.ga('create', 'UA-40881672-11', 'auto');
|
window.ga('create', 'UA-40881672-11', 'auto');
|
||||||
window.ga('send', 'pageview');
|
window.ga('send', 'pageview');
|
||||||
}
|
}
|
||||||
/* eslint-enable */
|
/* eslint-enable */
|
||||||
|
})();
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
|
||||||
|
2
demo/dist/demo.js.map
vendored
2
demo/dist/demo.js.map
vendored
File diff suppressed because one or more lines are too long
2
demo/dist/demo.min.js
vendored
2
demo/dist/demo.min.js
vendored
File diff suppressed because one or more lines are too long
2
demo/dist/demo.min.js.map
vendored
2
demo/dist/demo.min.js.map
vendored
File diff suppressed because one or more lines are too long
@ -163,7 +163,7 @@
|
|||||||
c-1.1,0.9-2.5,1.4-4.1,1.4c-0.3,0-0.5,0-0.8,0c1.5,0.9,3.2,1.5,5,1.5c6,0,9.3-5,9.3-9.3c0-0.1,0-0.3,0-0.4C15,4.3,15.6,3.7,16,3z"></path>
|
c-1.1,0.9-2.5,1.4-4.1,1.4c-0.3,0-0.5,0-0.8,0c1.5,0.9,3.2,1.5,5,1.5c6,0,9.3-5,9.3-9.3c0-0.1,0-0.3,0-0.4C15,4.3,15.6,3.7,16,3z"></path>
|
||||||
</svg>
|
</svg>
|
||||||
<p>If you think Plyr's good,
|
<p>If you think Plyr's good,
|
||||||
<a href="https://twitter.com/intent/tweet?text=A+simple+HTML5+media+player+with+custom+controls+and+WebVTT+captions.&url=http%3A%2F%2Fplyr.io&via=Sam_Potts"
|
<a href="https://twitter.com/intent/tweet?text=A+simple+HTML5+media+player+with+custom+controls+and+WebVTT+captions.&url=http%3A%2F%2Fplyr.io&via=Sam_Potts"
|
||||||
target="_blank" data-shr-network="twitter">tweet it</a>
|
target="_blank" data-shr-network="twitter">tweet it</a>
|
||||||
</p>
|
</p>
|
||||||
</aside>
|
</aside>
|
||||||
@ -181,7 +181,7 @@
|
|||||||
<script src="https://cdn.rangetouch.com/1.0.1/rangetouch.js" async></script>
|
<script src="https://cdn.rangetouch.com/1.0.1/rangetouch.js" async></script>
|
||||||
|
|
||||||
<!-- Docs script -->
|
<!-- Docs script -->
|
||||||
<script src="dist/demo.js?2" crossorigin="anonymous"></script>
|
<script src="dist/demo.js" crossorigin="anonymous"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
@ -6,253 +6,255 @@
|
|||||||
|
|
||||||
import Raven from 'raven-js';
|
import Raven from 'raven-js';
|
||||||
|
|
||||||
Raven.config('https://d4ad9866ad834437a4754e23937071e4@sentry.io/305555').install();
|
(() => {
|
||||||
|
const isLive = window.location.host === 'plyr.io';
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
// Raven / Sentry
|
||||||
Raven.context(() => {
|
// For demo site (https://plyr.io) only
|
||||||
if (window.shr) {
|
if (isLive) {
|
||||||
window.shr.setup({
|
Raven.config('https://d4ad9866ad834437a4754e23937071e4@sentry.io/305555').install();
|
||||||
count: {
|
}
|
||||||
classname: 'button__count',
|
|
||||||
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
Raven.context(() => {
|
||||||
|
if (window.shr) {
|
||||||
|
window.shr.setup({
|
||||||
|
count: {
|
||||||
|
classname: 'button__count',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setup tab focus
|
||||||
|
const tabClassName = 'tab-focus';
|
||||||
|
|
||||||
|
// Remove class on blur
|
||||||
|
document.addEventListener('focusout', event => {
|
||||||
|
event.target.classList.remove(tabClassName);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Add classname to tabbed elements
|
||||||
|
document.addEventListener('keydown', event => {
|
||||||
|
if (event.keyCode !== 9) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delay the adding of classname until the focus has changed
|
||||||
|
// This event fires before the focusin event
|
||||||
|
setTimeout(() => {
|
||||||
|
document.activeElement.classList.add(tabClassName);
|
||||||
|
}, 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Setup the player
|
||||||
|
const player = new Plyr('#player', {
|
||||||
|
debug: true,
|
||||||
|
title: 'View From A Blue Moon',
|
||||||
|
iconUrl: '../dist/plyr.svg',
|
||||||
|
keyboard: {
|
||||||
|
global: true,
|
||||||
|
},
|
||||||
|
tooltips: {
|
||||||
|
controls: true,
|
||||||
|
},
|
||||||
|
captions: {
|
||||||
|
active: true,
|
||||||
|
},
|
||||||
|
keys: {
|
||||||
|
google: 'AIzaSyDrNwtN3nLH_8rjCmu5Wq3ZCm4MNAVdc0c',
|
||||||
|
},
|
||||||
|
ads: {
|
||||||
|
enabled: true,
|
||||||
|
publisherId: '918848828995742',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
// Setup tab focus
|
// Expose for tinkering in the console
|
||||||
const tabClassName = 'tab-focus';
|
window.player = player;
|
||||||
|
|
||||||
// Remove class on blur
|
// Setup type toggle
|
||||||
document.addEventListener('focusout', event => {
|
const buttons = document.querySelectorAll('[data-source]');
|
||||||
event.target.classList.remove(tabClassName);
|
const types = {
|
||||||
});
|
video: 'video',
|
||||||
|
audio: 'audio',
|
||||||
|
youtube: 'youtube',
|
||||||
|
vimeo: 'vimeo',
|
||||||
|
};
|
||||||
|
let currentType = window.location.hash.replace('#', '');
|
||||||
|
const historySupport = window.history && window.history.pushState;
|
||||||
|
|
||||||
// Add classname to tabbed elements
|
// Toggle class on an element
|
||||||
document.addEventListener('keydown', event => {
|
function toggleClass(element, className, state) {
|
||||||
if (event.keyCode !== 9) {
|
if (element) {
|
||||||
return;
|
element.classList[state ? 'add' : 'remove'](className);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delay the adding of classname until the focus has changed
|
// Set a new source
|
||||||
// This event fires before the focusin event
|
function newSource(type, init) {
|
||||||
setTimeout(() => {
|
// Bail if new type isn't known, it's the current type, or current type is empty (video is default) and new type is video
|
||||||
document.activeElement.classList.add(tabClassName);
|
if (!(type in types) || (!init && type === currentType) || (!currentType.length && type === types.video)) {
|
||||||
}, 0);
|
return;
|
||||||
});
|
}
|
||||||
|
|
||||||
// Setup the player
|
switch (type) {
|
||||||
const player = new Plyr('#player', {
|
case types.video:
|
||||||
debug: true,
|
player.source = {
|
||||||
title: 'View From A Blue Moon',
|
type: 'video',
|
||||||
iconUrl: '../dist/plyr.svg',
|
title: 'View From A Blue Moon',
|
||||||
keyboard: {
|
sources: [{
|
||||||
global: true,
|
|
||||||
},
|
|
||||||
tooltips: {
|
|
||||||
controls: true,
|
|
||||||
},
|
|
||||||
captions: {
|
|
||||||
active: true,
|
|
||||||
},
|
|
||||||
keys: {
|
|
||||||
google: 'AIzaSyDrNwtN3nLH_8rjCmu5Wq3ZCm4MNAVdc0c',
|
|
||||||
},
|
|
||||||
ads: {
|
|
||||||
enabled: true,
|
|
||||||
publisherId: '918848828995742',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// Expose for tinkering in the console
|
|
||||||
window.player = player;
|
|
||||||
|
|
||||||
// Setup type toggle
|
|
||||||
const buttons = document.querySelectorAll('[data-source]');
|
|
||||||
const types = {
|
|
||||||
video: 'video',
|
|
||||||
audio: 'audio',
|
|
||||||
youtube: 'youtube',
|
|
||||||
vimeo: 'vimeo',
|
|
||||||
};
|
|
||||||
let currentType = window.location.hash.replace('#', '');
|
|
||||||
const historySupport = window.history && window.history.pushState;
|
|
||||||
|
|
||||||
// Toggle class on an element
|
|
||||||
function toggleClass(element, className, state) {
|
|
||||||
if (element) {
|
|
||||||
element.classList[state ? 'add' : 'remove'](className);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set a new source
|
|
||||||
function newSource(type, init) {
|
|
||||||
// Bail if new type isn't known, it's the current type, or current type is empty (video is default) and new type is video
|
|
||||||
if (!(type in types) || (!init && type === currentType) || (!currentType.length && type === types.video)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (type) {
|
|
||||||
case types.video:
|
|
||||||
player.source = {
|
|
||||||
type: 'video',
|
|
||||||
title: 'View From A Blue Moon',
|
|
||||||
sources: [
|
|
||||||
{
|
|
||||||
src: 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.mp4',
|
src: 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.mp4',
|
||||||
type: 'video/mp4',
|
type: 'video/mp4',
|
||||||
},
|
}],
|
||||||
],
|
poster: 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.jpg',
|
||||||
poster: 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.jpg',
|
tracks: [
|
||||||
tracks: [
|
{
|
||||||
{
|
kind: 'captions',
|
||||||
kind: 'captions',
|
label: 'English',
|
||||||
label: 'English',
|
srclang: 'en',
|
||||||
srclang: 'en',
|
src: 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.en.vtt',
|
||||||
src: 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.en.vtt',
|
default: true,
|
||||||
default: true,
|
},
|
||||||
},
|
{
|
||||||
{
|
kind: 'captions',
|
||||||
kind: 'captions',
|
label: 'French',
|
||||||
label: 'French',
|
srclang: 'fr',
|
||||||
srclang: 'fr',
|
src: 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.fr.vtt',
|
||||||
src: 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.fr.vtt',
|
},
|
||||||
},
|
],
|
||||||
],
|
};
|
||||||
};
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case types.audio:
|
case types.audio:
|
||||||
player.source = {
|
player.source = {
|
||||||
type: 'audio',
|
type: 'audio',
|
||||||
title: 'Kishi Bashi – “It All Began With A Burst”',
|
title: 'Kishi Bashi – “It All Began With A Burst”',
|
||||||
sources: [
|
sources: [
|
||||||
{
|
{
|
||||||
src: 'https://cdn.plyr.io/static/demo/Kishi_Bashi_-_It_All_Began_With_a_Burst.mp3',
|
src: 'https://cdn.plyr.io/static/demo/Kishi_Bashi_-_It_All_Began_With_a_Burst.mp3',
|
||||||
type: 'audio/mp3',
|
type: 'audio/mp3',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
src: 'https://cdn.plyr.io/static/demo/Kishi_Bashi_-_It_All_Began_With_a_Burst.ogg',
|
src: 'https://cdn.plyr.io/static/demo/Kishi_Bashi_-_It_All_Began_With_a_Burst.ogg',
|
||||||
type: 'audio/ogg',
|
type: 'audio/ogg',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case types.youtube:
|
case types.youtube:
|
||||||
player.source = {
|
player.source = {
|
||||||
type: 'video',
|
type: 'video',
|
||||||
title: 'View From A Blue Moon',
|
title: 'View From A Blue Moon',
|
||||||
sources: [
|
sources: [{
|
||||||
{
|
|
||||||
src: 'https://youtube.com/watch?v=bTqVqk7FSmY',
|
src: 'https://youtube.com/watch?v=bTqVqk7FSmY',
|
||||||
provider: 'youtube',
|
provider: 'youtube',
|
||||||
},
|
}],
|
||||||
],
|
};
|
||||||
};
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case types.vimeo:
|
case types.vimeo:
|
||||||
player.source = {
|
player.source = {
|
||||||
type: 'video',
|
type: 'video',
|
||||||
sources: [
|
sources: [{
|
||||||
{
|
|
||||||
src: 'https://vimeo.com/76979871',
|
src: 'https://vimeo.com/76979871',
|
||||||
provider: 'vimeo',
|
provider: 'vimeo',
|
||||||
},
|
}],
|
||||||
],
|
};
|
||||||
};
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the current type for next time
|
||||||
|
currentType = type;
|
||||||
|
|
||||||
|
// Remove active classes
|
||||||
|
Array.from(buttons).forEach(button => toggleClass(button.parentElement, 'active', false));
|
||||||
|
|
||||||
|
// Set active on parent
|
||||||
|
toggleClass(document.querySelector(`[data-source="${type}"]`), 'active', true);
|
||||||
|
|
||||||
|
// Show cite
|
||||||
|
Array.from(document.querySelectorAll('.plyr__cite')).forEach(cite => {
|
||||||
|
cite.setAttribute('hidden', '');
|
||||||
|
});
|
||||||
|
document.querySelector(`.plyr__cite--${type}`).removeAttribute('hidden');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the current type for next time
|
// Bind to each button
|
||||||
currentType = type;
|
Array.from(buttons).forEach(button => {
|
||||||
|
button.addEventListener('click', () => {
|
||||||
|
const type = button.getAttribute('data-source');
|
||||||
|
|
||||||
// Remove active classes
|
newSource(type);
|
||||||
Array.from(buttons).forEach(button => toggleClass(button.parentElement, 'active', false));
|
|
||||||
|
|
||||||
// Set active on parent
|
if (historySupport) {
|
||||||
toggleClass(document.querySelector(`[data-source="${type}"]`), 'active', true);
|
window.history.pushState({ type }, '', `#${type}`);
|
||||||
|
}
|
||||||
// Show cite
|
});
|
||||||
Array.from(document.querySelectorAll('.plyr__cite')).forEach(cite => {
|
|
||||||
cite.setAttribute('hidden', '');
|
|
||||||
});
|
});
|
||||||
document.querySelector(`.plyr__cite--${type}`).removeAttribute('hidden');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bind to each button
|
// List for backwards/forwards
|
||||||
Array.from(buttons).forEach(button => {
|
window.addEventListener('popstate', event => {
|
||||||
button.addEventListener('click', () => {
|
if (event.state && 'type' in event.state) {
|
||||||
const type = button.getAttribute('data-source');
|
newSource(event.state.type);
|
||||||
|
|
||||||
newSource(type);
|
|
||||||
|
|
||||||
if (historySupport) {
|
|
||||||
window.history.pushState({ type }, '', `#${type}`);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
// List for backwards/forwards
|
// On load
|
||||||
window.addEventListener('popstate', event => {
|
if (historySupport) {
|
||||||
if (event.state && 'type' in event.state) {
|
const video = !currentType.length;
|
||||||
newSource(event.state.type);
|
|
||||||
|
// If there's no current type set, assume video
|
||||||
|
if (video) {
|
||||||
|
currentType = types.video;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Replace current history state
|
||||||
|
if (currentType in types) {
|
||||||
|
window.history.replaceState(
|
||||||
|
{
|
||||||
|
type: currentType,
|
||||||
|
},
|
||||||
|
'',
|
||||||
|
video ? '' : `#${currentType}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If it's not video, load the source
|
||||||
|
if (currentType !== types.video) {
|
||||||
|
newSource(currentType, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// On load
|
|
||||||
if (historySupport) {
|
|
||||||
const video = !currentType.length;
|
|
||||||
|
|
||||||
// If there's no current type set, assume video
|
|
||||||
if (video) {
|
|
||||||
currentType = types.video;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Replace current history state
|
|
||||||
if (currentType in types) {
|
|
||||||
window.history.replaceState(
|
|
||||||
{
|
|
||||||
type: currentType,
|
|
||||||
},
|
|
||||||
'',
|
|
||||||
video ? '' : `#${currentType}`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If it's not video, load the source
|
|
||||||
if (currentType !== types.video) {
|
|
||||||
newSource(currentType, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
// Google analytics
|
// Google analytics
|
||||||
// For demo site (https://plyr.io) only
|
// For demo site (https://plyr.io) only
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
if (window.location.host === 'plyr.io') {
|
if (isLive) {
|
||||||
(function(i, s, o, g, r, a, m) {
|
(function(i, s, o, g, r, a, m) {
|
||||||
i.GoogleAnalyticsObject = r;
|
i.GoogleAnalyticsObject = r;
|
||||||
i[r] =
|
i[r] =
|
||||||
i[r] ||
|
i[r] ||
|
||||||
function() {
|
function() {
|
||||||
(i[r].q = i[r].q || []).push(arguments);
|
(i[r].q = i[r].q || []).push(arguments);
|
||||||
};
|
};
|
||||||
i[r].l = 1 * new Date();
|
i[r].l = 1 * new Date();
|
||||||
a = s.createElement(o);
|
a = s.createElement(o);
|
||||||
m = s.getElementsByTagName(o)[0];
|
m = s.getElementsByTagName(o)[0];
|
||||||
a.async = 1;
|
a.async = 1;
|
||||||
a.src = g;
|
a.src = g;
|
||||||
m.parentNode.insertBefore(a, m);
|
m.parentNode.insertBefore(a, m);
|
||||||
})(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');
|
})(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');
|
||||||
window.ga('create', 'UA-40881672-11', 'auto');
|
window.ga('create', 'UA-40881672-11', 'auto');
|
||||||
window.ga('send', 'pageview');
|
window.ga('send', 'pageview');
|
||||||
}
|
}
|
||||||
/* eslint-enable */
|
/* eslint-enable */
|
||||||
|
})();
|
||||||
|
41
gulpfile.js
41
gulpfile.js
@ -70,10 +70,11 @@ const paths = {
|
|||||||
root: path.join(root, 'demo/'),
|
root: path.join(root, 'demo/'),
|
||||||
},
|
},
|
||||||
upload: [
|
upload: [
|
||||||
path.join(root, `dist/*${minSuffix}.js`),
|
path.join(root, `dist/*${minSuffix}.*`),
|
||||||
path.join(root, 'dist/*.css'),
|
path.join(root, 'dist/*.css'),
|
||||||
path.join(root, 'dist/*.svg'),
|
path.join(root, 'dist/*.svg'),
|
||||||
path.join(root, 'demo/dist/**'),
|
path.join(root, `demo/dist/*${minSuffix}.*`),
|
||||||
|
path.join(root, 'demo/dist/*.css'),
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -303,22 +304,26 @@ if (Object.keys(aws).includes('cdn') && Object.keys(aws).includes('demo')) {
|
|||||||
console.log(`Uploading '${version}' to ${aws.cdn.domain}...`);
|
console.log(`Uploading '${version}' to ${aws.cdn.domain}...`);
|
||||||
|
|
||||||
// Upload to CDN
|
// Upload to CDN
|
||||||
return gulp
|
return (
|
||||||
.src(paths.upload)
|
gulp
|
||||||
.pipe(
|
.src(paths.upload)
|
||||||
rename(p => {
|
.pipe(
|
||||||
p.basename = p.basename.replace(minSuffix, ''); // eslint-disable-line
|
rename(p => {
|
||||||
p.dirname = p.dirname.replace('.', version); // eslint-disable-line
|
p.basename = p.basename.replace(minSuffix, ''); // eslint-disable-line
|
||||||
}),
|
p.dirname = p.dirname.replace('.', version); // eslint-disable-line
|
||||||
)
|
}),
|
||||||
.pipe(
|
)
|
||||||
size({
|
// Remove min suffix from source map URL
|
||||||
showFiles: true,
|
.pipe(replace(/sourceMappingURL=([\w-?.]+)/, (match, p1) => `sourceMappingURL=${p1.replace(minSuffix, '')}`))
|
||||||
gzip: true,
|
.pipe(
|
||||||
}),
|
size({
|
||||||
)
|
showFiles: true,
|
||||||
.pipe(replace(localPath, versionPath))
|
gzip: true,
|
||||||
.pipe(s3(aws.cdn, options.cdn));
|
}),
|
||||||
|
)
|
||||||
|
.pipe(replace(localPath, versionPath))
|
||||||
|
.pipe(s3(aws.cdn, options.cdn))
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Publish to demo bucket
|
// Publish to demo bucket
|
||||||
|
15
yarn.lock
15
yarn.lock
@ -1690,9 +1690,9 @@ eslint-visitor-keys@^1.0.0:
|
|||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#3f3180fb2e291017716acb4c9d6d5b5c34a6a81d"
|
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#3f3180fb2e291017716acb4c9d6d5b5c34a6a81d"
|
||||||
|
|
||||||
eslint@^4.18.2:
|
eslint@^4.19.0:
|
||||||
version "4.18.2"
|
version "4.19.0"
|
||||||
resolved "https://registry.yarnpkg.com/eslint/-/eslint-4.18.2.tgz#0f81267ad1012e7d2051e186a9004cc2267b8d45"
|
resolved "https://registry.yarnpkg.com/eslint/-/eslint-4.19.0.tgz#9e900efb5506812ac374557034ef6f5c3642fc4c"
|
||||||
dependencies:
|
dependencies:
|
||||||
ajv "^5.3.0"
|
ajv "^5.3.0"
|
||||||
babel-code-frame "^6.22.0"
|
babel-code-frame "^6.22.0"
|
||||||
@ -1703,7 +1703,7 @@ eslint@^4.18.2:
|
|||||||
doctrine "^2.1.0"
|
doctrine "^2.1.0"
|
||||||
eslint-scope "^3.7.1"
|
eslint-scope "^3.7.1"
|
||||||
eslint-visitor-keys "^1.0.0"
|
eslint-visitor-keys "^1.0.0"
|
||||||
espree "^3.5.2"
|
espree "^3.5.4"
|
||||||
esquery "^1.0.0"
|
esquery "^1.0.0"
|
||||||
esutils "^2.0.2"
|
esutils "^2.0.2"
|
||||||
file-entry-cache "^2.0.0"
|
file-entry-cache "^2.0.0"
|
||||||
@ -1725,6 +1725,7 @@ eslint@^4.18.2:
|
|||||||
path-is-inside "^1.0.2"
|
path-is-inside "^1.0.2"
|
||||||
pluralize "^7.0.0"
|
pluralize "^7.0.0"
|
||||||
progress "^2.0.0"
|
progress "^2.0.0"
|
||||||
|
regexpp "^1.0.1"
|
||||||
require-uncached "^1.0.3"
|
require-uncached "^1.0.3"
|
||||||
semver "^5.3.0"
|
semver "^5.3.0"
|
||||||
strip-ansi "^4.0.0"
|
strip-ansi "^4.0.0"
|
||||||
@ -1732,7 +1733,7 @@ eslint@^4.18.2:
|
|||||||
table "4.0.2"
|
table "4.0.2"
|
||||||
text-table "~0.2.0"
|
text-table "~0.2.0"
|
||||||
|
|
||||||
espree@^3.5.2:
|
espree@^3.5.4:
|
||||||
version "3.5.4"
|
version "3.5.4"
|
||||||
resolved "https://registry.yarnpkg.com/espree/-/espree-3.5.4.tgz#b0f447187c8a8bed944b815a660bddf5deb5d1a7"
|
resolved "https://registry.yarnpkg.com/espree/-/espree-3.5.4.tgz#b0f447187c8a8bed944b815a660bddf5deb5d1a7"
|
||||||
dependencies:
|
dependencies:
|
||||||
@ -4488,6 +4489,10 @@ regex-not@^1.0.0, regex-not@^1.0.2:
|
|||||||
extend-shallow "^3.0.2"
|
extend-shallow "^3.0.2"
|
||||||
safe-regex "^1.1.0"
|
safe-regex "^1.1.0"
|
||||||
|
|
||||||
|
regexpp@^1.0.1:
|
||||||
|
version "1.0.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-1.0.1.tgz#d857c3a741dce075c2848dcb019a0a975b190d43"
|
||||||
|
|
||||||
regexpu-core@^2.0.0:
|
regexpu-core@^2.0.0:
|
||||||
version "2.0.0"
|
version "2.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/regexpu-core/-/regexpu-core-2.0.0.tgz#49d038837b8dcf8bfa5b9a42139938e6ea2ae240"
|
resolved "https://registry.yarnpkg.com/regexpu-core/-/regexpu-core-2.0.0.tgz#49d038837b8dcf8bfa5b9a42139938e6ea2ae240"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user