aboutsummaryrefslogtreecommitdiffstats
path: root/demo/src/js/demo.js
diff options
context:
space:
mode:
authorSam Potts <sam@potts.es>2018-11-11 11:05:09 +1100
committerSam Potts <sam@potts.es>2018-11-11 11:05:09 +1100
commitb7b2e3c0aa0749eed53ae91230082cb0482e1f28 (patch)
treef073bde14df6459419323dd6570b2549b8d26c41 /demo/src/js/demo.js
parent3e0a91141822758094b2cbd5f0ecdd8ce4142b5f (diff)
parent2c8a337f265f3f84133bc674f3836802588c0c13 (diff)
downloadplyr-b7b2e3c0aa0749eed53ae91230082cb0482e1f28.tar.lz
plyr-b7b2e3c0aa0749eed53ae91230082cb0482e1f28.tar.xz
plyr-b7b2e3c0aa0749eed53ae91230082cb0482e1f28.zip
Merge branch 'develop' into css-variables
# Conflicts: # demo/dist/demo.css # demo/dist/demo.js # demo/dist/demo.js.map # demo/dist/demo.min.js # demo/dist/demo.min.js.map # dist/plyr.css # dist/plyr.js # dist/plyr.js.map # dist/plyr.min.js # dist/plyr.min.js.map # dist/plyr.polyfilled.js # dist/plyr.polyfilled.js.map # dist/plyr.polyfilled.min.js # dist/plyr.polyfilled.min.js.map # gulpfile.js # src/sass/components/captions.scss # src/sass/components/control.scss
Diffstat (limited to 'demo/src/js/demo.js')
-rw-r--r--demo/src/js/demo.js119
1 files changed, 47 insertions, 72 deletions
diff --git a/demo/src/js/demo.js b/demo/src/js/demo.js
index 003e85d5..accd1371 100644
--- a/demo/src/js/demo.js
+++ b/demo/src/js/demo.js
@@ -7,16 +7,17 @@
import Raven from 'raven-js';
(() => {
- const isLive = window.location.host === 'plyr.io';
-
- // Raven / Sentry
- // For demo site (https://plyr.io) only
- if (isLive) {
- Raven.config('https://d4ad9866ad834437a4754e23937071e4@sentry.io/305555').install();
- }
+ const { host } = window.location;
+ const env = {
+ prod: host === 'plyr.io',
+ dev: host === 'dev.plyr.io',
+ };
document.addEventListener('DOMContentLoaded', () => {
Raven.context(() => {
+ const selector = '#player';
+ const container = document.getElementById('container');
+
if (window.shr) {
window.shr.setup({
count: {
@@ -30,6 +31,10 @@ import Raven from 'raven-js';
// Remove class on blur
document.addEventListener('focusout', event => {
+ if (!event.target.classList || container.contains(event.target)) {
+ return;
+ }
+
event.target.classList.remove(tabClassName);
});
@@ -42,12 +47,18 @@ import Raven from 'raven-js';
// Delay the adding of classname until the focus has changed
// This event fires before the focusin event
setTimeout(() => {
- document.activeElement.classList.add(tabClassName);
- }, 0);
+ const focused = document.activeElement;
+
+ if (!focused || !focused.classList || container.contains(focused)) {
+ return;
+ }
+
+ focused.classList.add(tabClassName);
+ }, 10);
});
// Setup the player
- const player = new Plyr('#player', {
+ const player = new Plyr(selector, {
debug: true,
title: 'View From A Blue Moon',
iconUrl: '../dist/plyr.svg',
@@ -57,56 +68,6 @@ import Raven from 'raven-js';
tooltips: {
controls: true,
},
- /* controls: [
- 'play-large',
- 'restart',
- 'rewind',
- 'play',
- 'fast-forward',
- 'progress',
- 'current-time',
- 'duration',
- 'mute',
- 'volume',
- 'captions',
- 'settings',
- 'pip',
- 'airplay',
- 'fullscreen',
- ], */
- /* i18n: {
- restart: '重新開始',
- rewind: '快退{seektime}秒',
- play: '播放',
- pause: '暫停',
- fastForward: '快進{seektime}秒',
- seek: '尋求',
- played: '發揮',
- buffered: '緩衝的',
- currentTime: '當前時間戳',
- duration: '長短',
- volume: '音量',
- mute: '靜音',
- unmute: '取消靜音',
- enableCaptions: '開啟字幕',
- disableCaptions: '關閉字幕',
- enterFullscreen: '進入全螢幕',
- exitFullscreen: '退出全螢幕',
- frameTitle: '球員為{title}',
- captions: '字幕',
- settings: '設定',
- speed: '速度',
- normal: '正常',
- quality: '質量',
- loop: '循環',
- start: 'Start',
- end: 'End',
- all: 'All',
- reset: '重啟',
- disabled: '殘',
- enabled: '啟用',
- advertisement: '廣告',
- }, */
captions: {
active: true,
},
@@ -114,7 +75,7 @@ import Raven from 'raven-js';
google: 'AIzaSyDrNwtN3nLH_8rjCmu5Wq3ZCm4MNAVdc0c',
},
ads: {
- enabled: true,
+ enabled: env.prod || env.dev,
publisherId: '918848828995742',
},
});
@@ -143,7 +104,11 @@ import Raven from 'raven-js';
// 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)) {
+ if (
+ !(type in types) ||
+ (!init && type === currentType) ||
+ (!currentType.length && type === types.video)
+ ) {
return;
}
@@ -215,10 +180,12 @@ import Raven from 'raven-js';
case types.youtube:
player.source = {
type: 'video',
- sources: [{
- src: 'https://youtube.com/watch?v=bTqVqk7FSmY',
- provider: 'youtube',
- }],
+ sources: [
+ {
+ src: 'https://youtube.com/watch?v=bTqVqk7FSmY',
+ provider: 'youtube',
+ },
+ ],
};
break;
@@ -226,10 +193,12 @@ import Raven from 'raven-js';
case types.vimeo:
player.source = {
type: 'video',
- sources: [{
- src: 'https://vimeo.com/76979871',
- provider: 'vimeo',
- }],
+ sources: [
+ {
+ src: 'https://vimeo.com/76979871',
+ provider: 'vimeo',
+ },
+ ],
};
break;
@@ -302,11 +271,17 @@ import Raven from 'raven-js';
});
});
+ // Raven / Sentry
+ // For demo site (https://plyr.io) only
+ if (env.prod) {
+ Raven.config('https://d4ad9866ad834437a4754e23937071e4@sentry.io/305555').install();
+ }
+
// Google analytics
// For demo site (https://plyr.io) only
/* eslint-disable */
- if (isLive) {
- (function(i, s, o, g, r, a, m) {
+ if (env.prod) {
+ ((i, s, o, g, r, a, m) => {
i.GoogleAnalyticsObject = r;
i[r] =
i[r] ||