Comments and formatting
This commit is contained in:
parent
8348f79742
commit
021f6c8460
2
demo/dist/demo.js
vendored
2
demo/dist/demo.js
vendored
@ -1,3 +1,3 @@
|
||||
document.addEventListener("DOMContentLoaded",function(){window.shr&&window.shr.setup({count:{classname:"button__count"}});var e="tab-focus";document.addEventListener("focusout",function(t){t.target.classList.remove(e)}),document.addEventListener("keydown",function(t){9===t.keyCode&&window.setTimeout(function(){document.activeElement.classList.add(e)},0)});var t=new window.Plyr("#player",{debug:!0,title:"View From A Blue Moon",iconUrl:"../dist/plyr.svg",keyboard:{global:!0},tooltips:{controls:!0},captions:{active:!0},keys:{google:"AIzaSyDrNwtN3nLH_8rjCmu5Wq3ZCm4MNAVdc0c"},ads:{tagUrl:"http://go.aniview.com/api/adserver6/vast/?AV_PUBLISHERID=58c25bb0073ef448b1087ad6&AV_CHANNELID=5a0458dc28a06145e4519d21&AV_URL=127.0.0.1:3000&cb=1&AV_WIDTH=640&AV_HEIGHT=480"}});window.player=t;var o=document.querySelectorAll("[data-source]"),i={video:"video",audio:"audio",youtube:"youtube",vimeo:"vimeo"},a=window.location.hash.replace("#",""),r=window.history&&window.history.pushState;function n(e,t,o){e&&e.classList[o?"add":"remove"](t)}function s(e,r){if(e in i&&(r||e!==a)&&(a.length||e!==i.video)){switch(e){case i.video:t.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:!0},{kind:"captions",label:"French",srclang:"fr",src:"https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.fr.vtt"}]};break;case i.audio:t.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 i.youtube:t.source={type:"video",title:"View From A Blue Moon",sources:[{src:"https://youtube.com/watch?v=bTqVqk7FSmY",provider:"youtube"}]};break;case i.vimeo:t.source={type:"video",sources:[{src:"https://vimeo.com/76979871",provider:"vimeo"}]}}a=e,Array.from(o).forEach(function(e){return n(e.parentElement,"active",!1)}),n(document.querySelector('[data-source="'+e+'"]'),"active",!0),Array.from(document.querySelectorAll(".plyr__cite")).forEach(function(e){e.setAttribute("hidden","")}),document.querySelector(".plyr__cite--"+e).removeAttribute("hidden")}}if(Array.from(o).forEach(function(e){e.addEventListener("click",function(){var t=e.getAttribute("data-source");s(t),r&&window.history.pushState({type:t},"","#"+t)})}),window.addEventListener("popstate",function(e){e.state&&"type"in e.state&&s(e.state.type)}),r){var c=!a.length;c&&(a=i.video),a in i&&window.history.replaceState({type:a},"",c?"":"#"+a),a!==i.video&&s(a,!0)}}),"plyr.io"===window.location.host&&(!function(e,t,o,i,a,r,n){e.GoogleAnalyticsObject=a,e.ga=e.ga||function(){(e.ga.q=e.ga.q||[]).push(arguments)},e.ga.l=1*new Date,r=t.createElement(o),n=t.getElementsByTagName(o)[0],r.async=1,r.src="//www.google-analytics.com/analytics.js",n.parentNode.insertBefore(r,n)}(window,document,"script",0,"ga"),window.ga("create","UA-40881672-11","auto"),window.ga("send","pageview"));
|
||||
document.addEventListener("DOMContentLoaded",function(){window.shr&&window.shr.setup({count:{classname:"button__count"}});document.addEventListener("focusout",function(e){e.target.classList.remove("tab-focus")}),document.addEventListener("keydown",function(e){9===e.keyCode&&window.setTimeout(function(){document.activeElement.classList.add("tab-focus")},0)});var e=new window.Plyr("#player",{debug:!0,title:"View From A Blue Moon",iconUrl:"../dist/plyr.svg",keyboard:{global:!0},tooltips:{controls:!0},captions:{active:!0},keys:{google:"AIzaSyDrNwtN3nLH_8rjCmu5Wq3ZCm4MNAVdc0c"},ads:{tagUrl:"http://go.aniview.com/api/adserver6/vast/?AV_PUBLISHERID=58c25bb0073ef448b1087ad6&AV_CHANNELID=5a0458dc28a06145e4519d21&AV_URL=127.0.0.1:3000&cb=1&AV_WIDTH=640&AV_HEIGHT=480"}});window.player=e;var t=document.querySelectorAll("[data-source]"),o={video:"video",audio:"audio",youtube:"youtube",vimeo:"vimeo"},i=window.location.hash.replace("#",""),a=window.history&&window.history.pushState;function r(e,t,o){e&&e.classList[o?"add":"remove"](t)}function n(a,n){if(a in o&&(n||a!==i)&&(i.length||a!==o.video)){switch(a){case o.video:e.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:!0},{kind:"captions",label:"French",srclang:"fr",src:"https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.fr.vtt"}]};break;case o.audio:e.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 o.youtube:e.source={type:"video",title:"View From A Blue Moon",sources:[{src:"https://youtube.com/watch?v=bTqVqk7FSmY",provider:"youtube"}]};break;case o.vimeo:e.source={type:"video",sources:[{src:"https://vimeo.com/76979871",provider:"vimeo"}]}}i=a,Array.from(t).forEach(function(e){return r(e.parentElement,"active",!1)}),r(document.querySelector('[data-source="'+a+'"]'),"active",!0),Array.from(document.querySelectorAll(".plyr__cite")).forEach(function(e){e.setAttribute("hidden","")}),document.querySelector(".plyr__cite--"+a).removeAttribute("hidden")}}if(Array.from(t).forEach(function(e){e.addEventListener("click",function(){var t=e.getAttribute("data-source");n(t),a&&window.history.pushState({type:t},"","#"+t)})}),window.addEventListener("popstate",function(e){e.state&&"type"in e.state&&n(e.state.type)}),a){var s=!i.length;s&&(i=o.video),i in o&&window.history.replaceState({type:i},"",s?"":"#"+i),i!==o.video&&n(i,!0)}}),"plyr.io"===window.location.host&&(!function(e,t,o,i,a,r,n){e.GoogleAnalyticsObject="ga",e.ga=e.ga||function(){(e.ga.q=e.ga.q||[]).push(arguments)},e.ga.l=1*new Date,r=t.createElement("script"),n=t.getElementsByTagName("script")[0],r.async=1,r.src="//www.google-analytics.com/analytics.js",n.parentNode.insertBefore(r,n)}(window,document),window.ga("create","UA-40881672-11","auto"),window.ga("send","pageview"));
|
||||
|
||||
//# sourceMappingURL=demo.js.map
|
||||
|
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
dist/plyr.js
vendored
2
dist/plyr.js
vendored
File diff suppressed because one or more lines are too long
2
dist/plyr.js.map
vendored
2
dist/plyr.js.map
vendored
File diff suppressed because one or more lines are too long
@ -1,3 +1,11 @@
|
||||
// ==========================================================================
|
||||
// Advertisment plugin
|
||||
// Create an account with our ad partner, vi here:
|
||||
// https://www.vi.ai/publisher-video-monetization/
|
||||
// ==========================================================================
|
||||
|
||||
/* global google */
|
||||
|
||||
import utils from '../utils';
|
||||
|
||||
// Events are different on various devices. We set the correct events, based on userAgent.
|
||||
@ -53,7 +61,7 @@ class Ads {
|
||||
|
||||
// Setup a simple promise to resolve if the IMA loader is ready.
|
||||
this.adsLoaderResolve = () => {};
|
||||
this.adsLoaderPromise = new Promise((resolve) => {
|
||||
this.adsLoaderPromise = new Promise(resolve => {
|
||||
this.adsLoaderResolve = resolve;
|
||||
});
|
||||
this.adsLoaderPromise.then(() => {
|
||||
@ -62,7 +70,7 @@ class Ads {
|
||||
|
||||
// Setup a promise to resolve if the IMA manager is ready.
|
||||
this.adsManagerResolve = () => {};
|
||||
this.adsManagerPromise = new Promise((resolve) => {
|
||||
this.adsManagerPromise = new Promise(resolve => {
|
||||
// Resolve our promise.
|
||||
this.adsManagerResolve = resolve;
|
||||
});
|
||||
@ -113,7 +121,6 @@ class Ads {
|
||||
}
|
||||
|
||||
onAdsManagerLoaded(adsManagerLoadedEvent) {
|
||||
|
||||
// Get the ads manager.
|
||||
const settings = new google.ima.AdsRenderingSettings();
|
||||
|
||||
@ -158,11 +165,13 @@ class Ads {
|
||||
// let intervalTimer;
|
||||
|
||||
switch (event.type) {
|
||||
|
||||
case google.ima.AdEvent.Type.AD_BREAK_READY:
|
||||
// This event indicates that a mid-roll ad is ready to start.
|
||||
// We pause the player and tell the adsManager to start playing the ad.
|
||||
this.player.debug.log(`[${(Date.now() - this.time) / 1000}s][IMA SDK] AD_BREAK_READY |`, 'Fired when an ad rule or a VMAP ad break would have played if autoPlayAdBreaks is false.');
|
||||
this.player.debug.log(
|
||||
`[${(Date.now() - this.time) / 1000}s][IMA SDK] AD_BREAK_READY |`,
|
||||
'Fired when an ad rule or a VMAP ad break would have played if autoPlayAdBreaks is false.',
|
||||
);
|
||||
// this.handleEventListeners('AD_BREAK_READY');
|
||||
// this.playing = true;
|
||||
// this.adsManager.start();
|
||||
@ -171,7 +180,10 @@ class Ads {
|
||||
this.player.debug.log(`[${(Date.now() - this.time) / 1000}s][IMA SDK] AD_METADATA |`, 'Fired when an ads list is loaded.');
|
||||
break;
|
||||
case google.ima.AdEvent.Type.ALL_ADS_COMPLETED:
|
||||
this.player.debug.log(`[${(Date.now() - this.time) / 1000}s][IMA SDK] ALL_ADS_COMPLETED |`, 'Fired when the ads manager is done playing all the ads.');
|
||||
this.player.debug.log(
|
||||
`[${(Date.now() - this.time) / 1000}s][IMA SDK] ALL_ADS_COMPLETED |`,
|
||||
'Fired when the ads manager is done playing all the ads.',
|
||||
);
|
||||
this.handleEventListeners('ALL_ADS_COMPLETED');
|
||||
break;
|
||||
case google.ima.AdEvent.Type.CLICK:
|
||||
@ -193,13 +205,19 @@ class Ads {
|
||||
}
|
||||
break;
|
||||
case google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED:
|
||||
this.player.debug.log(`[${(Date.now() - this.time) / 1000}s][IMA SDK] CONTENT_PAUSE_REQUESTED |`, 'Fired when content should be paused. This usually happens right before an ad is about to cover the content.');
|
||||
this.player.debug.log(
|
||||
`[${(Date.now() - this.time) / 1000}s][IMA SDK] CONTENT_PAUSE_REQUESTED |`,
|
||||
'Fired when content should be paused. This usually happens right before an ad is about to cover the content.',
|
||||
);
|
||||
this.handleEventListeners('CONTENT_PAUSE_REQUESTED');
|
||||
this.player.pause();
|
||||
break;
|
||||
|
||||
case google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED:
|
||||
this.player.debug.log(`[${(Date.now() - this.time) / 1000}s][IMA SDK] CONTENT_RESUME_REQUESTED |`, 'Fired when content should be resumed. This usually happens when an ad finishes or collapses.');
|
||||
this.player.debug.log(
|
||||
`[${(Date.now() - this.time) / 1000}s][IMA SDK] CONTENT_RESUME_REQUESTED |`,
|
||||
'Fired when content should be resumed. This usually happens when an ad finishes or collapses.',
|
||||
);
|
||||
this.handleEventListeners('CONTENT_RESUME_REQUESTED');
|
||||
if (this.player.currentTime < this.player.duration) {
|
||||
this.player.play();
|
||||
@ -233,7 +251,7 @@ class Ads {
|
||||
this.handleEventListeners('STARTED');
|
||||
break;
|
||||
case google.ima.AdEvent.Type.DURATION_CHANGE:
|
||||
this.player.debug.log(`[${(Date.now() - this.time) / 1000}s][IMA SDK] DURATION_CHANGE |`, 'Fired when the ad\'s duration changes.');
|
||||
this.player.debug.log(`[${(Date.now() - this.time) / 1000}s][IMA SDK] DURATION_CHANGE |`, "Fired when the ad's duration changes.");
|
||||
break;
|
||||
case google.ima.AdEvent.Type.FIRST_QUARTILE:
|
||||
this.player.debug.log(`[${(Date.now() - this.time) / 1000}s][IMA SDK] FIRST_QUARTILE |`, 'Fired when the ad playhead crosses first quartile.');
|
||||
@ -242,10 +260,16 @@ class Ads {
|
||||
this.player.debug.log(`[${(Date.now() - this.time) / 1000}s][IMA SDK] IMPRESSION |`, 'Fired when the impression URL has been pinged.');
|
||||
break;
|
||||
case google.ima.AdEvent.Type.INTERACTION:
|
||||
this.player.debug.log(`[${(Date.now() - this.time) / 1000}s][IMA SDK] INTERACTION |`, 'Fired when an ad triggers the interaction callback. Ad interactions contain an interaction ID string in the ad data.');
|
||||
this.player.debug.log(
|
||||
`[${(Date.now() - this.time) / 1000}s][IMA SDK] INTERACTION |`,
|
||||
'Fired when an ad triggers the interaction callback. Ad interactions contain an interaction ID string in the ad data.',
|
||||
);
|
||||
break;
|
||||
case google.ima.AdEvent.Type.LINEAR_CHANGED:
|
||||
this.player.debug.log(`[${(Date.now() - this.time) / 1000}s][IMA SDK] LINEAR_CHANGED |`, 'Fired when the displayed ad changes from linear to nonlinear, or vice versa.');
|
||||
this.player.debug.log(
|
||||
`[${(Date.now() - this.time) / 1000}s][IMA SDK] LINEAR_CHANGED |`,
|
||||
'Fired when the displayed ad changes from linear to nonlinear, or vice versa.',
|
||||
);
|
||||
break;
|
||||
case google.ima.AdEvent.Type.MIDPOINT:
|
||||
this.player.debug.log(`[${(Date.now() - this.time) / 1000}s][IMA SDK] MIDPOINT |`, 'Fired when the ad playhead crosses midpoint.');
|
||||
@ -257,7 +281,10 @@ class Ads {
|
||||
this.player.debug.log(`[${(Date.now() - this.time) / 1000}s][IMA SDK] RESUMED |`, 'Fired when the ad is resumed.');
|
||||
break;
|
||||
case google.ima.AdEvent.Type.SKIPPABLE_STATE_CHANGED:
|
||||
this.player.debug.log(`[${(Date.now() - this.time) / 1000}s][IMA SDK] SKIPPABLE_STATE_CHANGED |`, 'Fired when the displayed ads skippable state is changed.');
|
||||
this.player.debug.log(
|
||||
`[${(Date.now() - this.time) / 1000}s][IMA SDK] SKIPPABLE_STATE_CHANGED |`,
|
||||
'Fired when the displayed ads skippable state is changed.',
|
||||
);
|
||||
break;
|
||||
case google.ima.AdEvent.Type.SKIPPED:
|
||||
this.player.debug.log(`[${(Date.now() - this.time) / 1000}s][IMA SDK] SKIPPED |`, 'Fired when the ad is skipped by the user.');
|
||||
@ -367,7 +394,6 @@ class Ads {
|
||||
this.adsManagerPromise.then(() => {
|
||||
try {
|
||||
if (!this.initialized) {
|
||||
|
||||
// Initialize the ads manager. Ad rules playlist will start at this time.
|
||||
this.adsManager.init(container.offsetWidth, container.offsetHeight, google.ima.ViewMode.NORMAL);
|
||||
|
||||
@ -484,4 +510,3 @@ class Ads {
|
||||
}
|
||||
|
||||
export default Ads;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user