j1-template 2024.3.13 → 2024.3.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/_includes/themes/j1/layouts/content_generator_news_panel_posts.html +1 -1
- data/_includes/themes/j1/layouts/layout_resource_generator.html +1 -4
- data/_includes/themes/j1/procedures/blocks/footer/boxes/social_media_icons.proc +24 -23
- data/_includes/themes/j1/procedures/layouts/content_writer.proc +4 -3
- data/_includes/themes/j1/procedures/layouts/default_writer.proc +37 -6
- data/_includes/themes/j1/procedures/layouts/module_writer.proc +31 -95
- data/_includes/themes/j1/procedures/layouts/resource_writer.proc +51 -29
- data/assets/data/amplitude.28.html +887 -0
- data/assets/data/amplitude.29.html +923 -0
- data/assets/data/amplitude.html +311 -46
- data/assets/data/banner.html +9 -7
- data/assets/data/masterslider.html +128 -7
- data/assets/data/panel.html +16 -65
- data/assets/theme/j1/adapter/js/amplitude.23.js +1165 -0
- data/assets/theme/j1/adapter/js/amplitude.24.js +1164 -0
- data/assets/theme/j1/adapter/js/amplitude.25.js +1268 -0
- data/assets/theme/j1/adapter/js/amplitude.js +294 -117
- data/assets/theme/j1/adapter/js/attic.js +14 -11
- data/assets/theme/j1/adapter/js/docsearch.js +2 -2
- data/assets/theme/j1/adapter/js/fab.js +2 -2
- data/assets/theme/j1/adapter/js/j1.js +8 -8
- data/assets/theme/j1/adapter/js/lazyLoader.js +60 -10
- data/assets/theme/j1/adapter/js/masonry.js +1 -1
- data/assets/theme/j1/adapter/js/masterslider.js +2 -2
- data/assets/theme/j1/adapter/js/particles.js +2 -2
- data/assets/theme/j1/adapter/js/scroller.js +2 -2
- data/assets/theme/j1/adapter/js/slick.js +2 -2
- data/assets/theme/j1/adapter/js/themes.js +1 -1
- data/assets/theme/j1/adapter/js/translator.js +2 -2
- data/assets/theme/j1/adapter/js/waves.js +1 -1
- data/assets/theme/j1/core/css/animate.css +1634 -1070
- data/assets/theme/j1/core/css/animate.css.map +1 -0
- data/assets/theme/j1/core/css/animate.min.css +2 -1
- data/assets/theme/j1/core/css/animate.min.css.map +1 -0
- data/assets/theme/j1/core/css/icon-fonts/fontawesome.css +3060 -1538
- data/assets/theme/j1/core/css/icon-fonts/fontawesome.css.map +1 -0
- data/assets/theme/j1/core/css/icon-fonts/fontawesome.min.css +2 -1
- data/assets/theme/j1/core/css/icon-fonts/fontawesome.min.css.map +1 -0
- data/assets/theme/j1/core/css/icon-fonts/iconify.css +2308 -1153
- data/assets/theme/j1/core/css/icon-fonts/iconify.css.map +1 -0
- data/assets/theme/j1/core/css/icon-fonts/iconify.min.css +2 -1
- data/assets/theme/j1/core/css/icon-fonts/iconify.min.css.map +1 -0
- data/assets/theme/j1/core/css/icon-fonts/mdi.css +16716 -8423
- data/assets/theme/j1/core/css/icon-fonts/mdi.css.map +1 -0
- data/assets/theme/j1/core/css/icon-fonts/mdi.min.css +2 -1
- data/assets/theme/j1/core/css/icon-fonts/mdi.min.css.map +1 -0
- data/assets/theme/j1/core/css/icon-fonts/mdib.css +5554 -2766
- data/assets/theme/j1/core/css/icon-fonts/mdib.css.map +1 -0
- data/assets/theme/j1/core/css/icon-fonts/mdib.min.css +2 -1
- data/assets/theme/j1/core/css/icon-fonts/mdib.min.css.map +1 -0
- data/assets/theme/j1/core/css/icon-fonts/mdil.css +742 -441
- data/assets/theme/j1/core/css/icon-fonts/mdil.css.map +1 -0
- data/assets/theme/j1/core/css/icon-fonts/mdil.min.css +2 -1
- data/assets/theme/j1/core/css/icon-fonts/mdil.min.css.map +1 -0
- data/assets/theme/j1/core/css/themes/bootstrap/bootstrap.css +6552 -3980
- data/assets/theme/j1/core/css/themes/bootstrap/bootstrap.css.map +1 -0
- data/assets/theme/j1/core/css/themes/bootstrap/bootstrap.min.css +2 -5
- data/assets/theme/j1/core/css/themes/bootstrap/bootstrap.min.css.map +1 -0
- data/assets/theme/j1/core/css/themes/unodark/bootstrap.css +6818 -4131
- data/assets/theme/j1/core/css/themes/unodark/bootstrap.css.map +1 -0
- data/assets/theme/j1/core/css/themes/unodark/bootstrap.min.css +2 -5
- data/assets/theme/j1/core/css/themes/unodark/bootstrap.min.css.map +1 -0
- data/assets/theme/j1/core/css/themes/unolight/bootstrap.css +18568 -11577
- data/assets/theme/j1/core/css/themes/unolight/bootstrap.css.map +1 -0
- data/assets/theme/j1/core/css/themes/unolight/bootstrap.min.css +2 -35
- data/assets/theme/j1/core/css/themes/unolight/bootstrap.min.css.map +1 -0
- data/assets/theme/j1/core/css/vendor.css +1771 -1043
- data/assets/theme/j1/core/css/vendor.css.map +1 -0
- data/assets/theme/j1/core/css/vendor.min.css +2 -1
- data/assets/theme/j1/core/css/vendor.min.css.map +1 -0
- data/assets/theme/j1/core/js/template.js +399 -447
- data/assets/theme/j1/core/js/template.min.js +7 -7
- data/assets/theme/j1/core/js/template.min.js.map +1 -1
- data/assets/theme/j1/modules/amplitudejs/css/theme/uno/dark/amplitude.css +4 -2
- data/assets/theme/j1/modules/amplitudejs/css/theme/uno/dark/player/compact.css +39 -4
- data/assets/theme/j1/modules/amplitudejs/css/theme/uno/dark/player/compact.min.css +1 -1
- data/assets/theme/j1/modules/amplitudejs/css/theme/uno/dark/player/large.css +57 -17
- data/assets/theme/j1/modules/amplitudejs/css/theme/uno/dark/player/large.min.css +1 -1
- data/assets/theme/j1/modules/amplitudejs/icons/player/blue/pause.png +0 -0
- data/assets/theme/j1/modules/amplitudejs/icons/player/blue/play.png +0 -0
- data/assets/theme/j1/modules/amplitudejs/icons/player/blue/play.svg +87 -0
- data/assets/theme/j1/modules/amplitudejs/icons/player/dark/skip-backward.svg +60 -0
- data/assets/theme/j1/modules/amplitudejs/icons/player/dark/skip-forward.svg +59 -0
- data/assets/theme/j1/modules/amplitudejs/js/amplitude.js +65 -21
- data/assets/theme/j1/modules/amplitudejs/js/amplitude.min.js +1 -1
- data/assets/theme/j1/modules/amplitudejs/js/tech/ytp.js +113 -0
- data/assets/theme/j1/modules/iconPicker/js/universal-icon-picker.js +471 -471
- data/assets/theme/j1/modules/j1LazyLoader/LICENSE +21 -0
- data/assets/theme/j1/modules/j1LazyLoader/js/j1Lazy.js +870 -0
- data/assets/theme/j1/modules/js-cookies/js/js.cookie.js +3 -3
- data/assets/theme/j1/modules/lazyCssLoader/js/main.0.js +166 -0
- data/assets/theme/j1/modules/lazyCssLoader/js/main.1.js +65 -0
- data/assets/theme/j1/modules/lazyCssLoader/js/main.js +66 -0
- data/assets/theme/j1/modules/lazyCssLoader/js/plugins/examplePlugin.js +13 -0
- data/assets/theme/j1/modules/lazyCssLoader/js/plugins/my-plugin.js +25 -0
- data/assets/theme/j1/modules/lazyCssLoader/js/plugins/plugin-interface.js +9 -0
- data/assets/theme/j1/modules/lazyCssLoader/js/plugins/pluginA.js +46 -0
- data/assets/theme/j1/modules/lazyLoader/js/plugins/README.md +324 -0
- data/assets/theme/j1/modules/lazyLoader/js/plugins/jquery.lazy.picture.js +188 -0
- data/assets/theme/j1/modules/lightGallery/js/lightgallery.js +1 -1
- data/assets/theme/j1/modules/lightGallery/js/plugins/lg-video.0.js +794 -0
- data/assets/theme/j1/modules/lightGallery/js/plugins/lg-video.js +151 -67
- data/assets/theme/j1/modules/slimSelect/js/select.js +1 -1
- data/assets/theme/j1/modules/slimSelect/js/select.min.js +3 -3
- data/assets/theme/j1/modules/themeSwitcher/js/switcher.js +2 -1
- data/assets/theme/j1/modules/videojs/js/plugins/players/dm/dailymotion.min.js +1 -1
- data/assets/theme/j1/modules/videojs/js/plugins/players/dm/icon/scalable/dailymotion.svg +62 -0
- data/assets/theme/j1/modules/videojs/js/plugins/players/yt/v3.0.0/youtube.js +832 -0
- data/assets/theme/j1/modules/videojs/js/plugins/players/yt/v3.0.0/youtube.min.js +17 -0
- data/assets/theme/j1/modules/videojs/js/plugins/players/yt/youtube.min.js +1 -1
- data/assets/theme/j1/modules/videojs/js/video.js +2 -2
- data/lib/j1/version.rb +1 -1
- data/lib/starter_web/README.md +577 -560
- data/lib/starter_web/_config.yml +2 -2
- data/lib/starter_web/_data/blocks/footer.yml +10 -5
- data/lib/starter_web/_data/blocks/panel.yml +2 -2
- data/lib/starter_web/_data/layouts/default.yml +14 -3
- data/lib/starter_web/_data/modules/amplitude.yml +145 -0
- data/lib/starter_web/_data/modules/defaults/amplitude.yml +29 -7
- data/lib/starter_web/_data/modules/defaults/lazyLoader.yml +2 -2
- data/lib/starter_web/_data/modules/gallery.yml +136 -0
- data/lib/starter_web/_data/modules/lazyLoader.0.yml +118 -0
- data/lib/starter_web/_data/modules/lazyLoader.yml +68 -31
- data/lib/starter_web/_data/modules/masonry.yml +4 -4
- data/lib/starter_web/_data/modules/masterslider.yml +118 -12
- data/lib/starter_web/_data/modules/navigator_menu.yml +831 -803
- data/lib/starter_web/_data/resources.yml +154 -190
- data/lib/starter_web/_data/templates/feed.xml +1 -1
- data/lib/starter_web/_includes/attributes.asciidoc +1 -0
- data/lib/starter_web/_plugins/asciidoctor/amplitude-block.rb +1 -1
- data/lib/starter_web/_plugins/asciidoctor/dailymotion-block.rb +1 -1
- data/lib/starter_web/_plugins/asciidoctor/gallery-block.rb +4 -2
- data/lib/starter_web/_plugins/asciidoctor/masonry-block.rb +1 -1
- data/lib/starter_web/_plugins/asciidoctor/videojs-block.rb +58 -46
- data/lib/starter_web/_plugins/asciidoctor/vimeo-block.rb +26 -19
- data/lib/starter_web/_plugins/asciidoctor/youtube-block.rb +30 -40
- data/lib/starter_web/_plugins/index/lunr.rb +1 -1
- data/lib/starter_web/assets/image/icons/lanus/favicon.ico +0 -0
- data/lib/starter_web/assets/image/icons/lanus/lanus-512x512.png +0 -0
- data/lib/starter_web/assets/image/icons/lanus/lanus.ico +0 -0
- data/lib/starter_web/assets/image/icons/lanus/lanus.png +0 -0
- data/lib/starter_web/assets/image/icons/lanus/scalable/lanus.svg +76 -0
- data/lib/starter_web/assets/image/icons/lanus/scalable/lanus_sw.svg +62 -0
- data/lib/starter_web/assets/image/modules/icons/social/scalable/icon-twitter-x-28 - social.svg +86 -0
- data/lib/starter_web/assets/image/modules/icons/social/scalable/icon-twitter-x-28.svg +64 -0
- data/lib/starter_web/assets/image/modules/icons/social/scalable/icon-twitter-x.svg +1 -0
- data/lib/starter_web/assets/image/modules/icons/social/twitter_x.png +0 -0
- data/lib/starter_web/package.json +7 -18
- data/lib/starter_web/pages/public/amplitude_yt_tester.adoc +218 -0
- data/lib/starter_web/pages/public/features/template.adoc +18 -8
- data/lib/starter_web/pages/public/features/template.asciidoc +758 -0
- data/lib/starter_web/pages/public/lazy_loader_tester.adoc +402 -0
- data/lib/starter_web/pages/public/manuals/ytdl/man.adoc +3020 -0
- data/lib/starter_web/pages/public/manuals/ytdl/man.md +2378 -0
- data/lib/starter_web/pages/public/tools/previewer/_includes/attributes.asciidoc +0 -16
- data/lib/starter_web/pages/public/tools/previewer/_includes/documents/amplitudejs.large.css.asciidoc +505 -0
- data/lib/starter_web/pages/public/tools/previewer/_includes/documents/frame.hover.html +69 -0
- data/lib/starter_web/pages/public/tools/previewer/_includes/documents/frame.nested.html +75 -0
- data/lib/starter_web/pages/public/tools/previewer/_includes/documents/frame.textarea.html +57 -0
- data/lib/starter_web/pages/public/tools/previewer/_includes/documents/my.content.html +112 -0
- data/lib/starter_web/pages/public/tools/previewer/preview_amplitudejs.adoc +172 -0
- data/lib/starter_web/pages/public/tour/_includes/attributes.asciidoc +2 -2
- data/lib/starter_web/pages/public/tour/_includes/documents/419_advanced_modals_demo.asciidoc +16 -16
- data/lib/starter_web/pages/public/tour/asciidoc_extensions.adoc +13 -3
- data/lib/starter_web/pages/public/tour/bootstrap_themes.adoc +12 -3
- data/lib/starter_web/pages/public/tour/highlghter_rouge.adoc +13 -3
- data/lib/starter_web/pages/public/tour/icon_fonts.adoc +12 -3
- data/lib/starter_web/pages/public/tour/modal_extentions.adoc +12 -6
- data/lib/starter_web/pages/public/tour/{playback_audio.adoc → play_audio.adoc} +207 -188
- data/lib/starter_web/pages/public/tour/{playback_video.adoc → play_video.adoc} +49 -51
- data/lib/starter_web/pages/public/tour/present_images.adoc +27 -5
- data/lib/starter_web/pages/public/tour/quicksearch.adoc +13 -3
- data/lib/starter_web/pages/public/tour/responsive_tables.adoc +13 -4
- data/lib/starter_web/pages/public/tour/typography.adoc +12 -3
- metadata +90 -22
- /data/assets/theme/j1/modules/{lazyLoader → j1LazyLoader/js}/plugins/README.md +0 -0
- /data/assets/theme/j1/modules/{lazyLoader/plugins/jquery.lazy.picture.js → j1LazyLoader/js/plugins/picture.js} +0 -0
- /data/assets/theme/j1/modules/lazyLoader/{plugins → js/plugins}/jquery.lazy.ajax.js +0 -0
- /data/assets/theme/j1/modules/lazyLoader/{plugins → js/plugins}/jquery.lazy.ajax.min.js +0 -0
- /data/assets/theme/j1/modules/lazyLoader/{plugins → js/plugins}/jquery.lazy.av.js +0 -0
- /data/assets/theme/j1/modules/lazyLoader/{plugins → js/plugins}/jquery.lazy.av.min.js +0 -0
- /data/assets/theme/j1/modules/lazyLoader/{plugins → js/plugins}/jquery.lazy.iframe.js +0 -0
- /data/assets/theme/j1/modules/lazyLoader/{plugins → js/plugins}/jquery.lazy.iframe.min.js +0 -0
- /data/assets/theme/j1/modules/lazyLoader/{plugins → js/plugins}/jquery.lazy.noop.js +0 -0
- /data/assets/theme/j1/modules/lazyLoader/{plugins → js/plugins}/jquery.lazy.noop.min.js +0 -0
- /data/assets/theme/j1/modules/lazyLoader/{plugins → js/plugins}/jquery.lazy.picture.min.js +0 -0
- /data/assets/theme/j1/modules/lazyLoader/{plugins → js/plugins}/jquery.lazy.script.js +0 -0
- /data/assets/theme/j1/modules/lazyLoader/{plugins → js/plugins}/jquery.lazy.script.min.js +0 -0
- /data/assets/theme/j1/modules/lazyLoader/{plugins → js/plugins}/jquery.lazy.vimeo.js +0 -0
- /data/assets/theme/j1/modules/lazyLoader/{plugins → js/plugins}/jquery.lazy.vimeo.min.js +0 -0
- /data/assets/theme/j1/modules/lazyLoader/{plugins → js/plugins}/jquery.lazy.youtube.js +0 -0
- /data/assets/theme/j1/modules/lazyLoader/{plugins → js/plugins}/jquery.lazy.youtube.min.js +0 -0
@@ -0,0 +1,832 @@
|
|
1
|
+
/*
|
2
|
+
# -----------------------------------------------------------------------------
|
3
|
+
# ~/assets/theme/j1/modules/videojs/js/yt/youtube.js
|
4
|
+
# Provides YiuTube Playback Technology (Tech) for Video.js V8 and newer
|
5
|
+
#
|
6
|
+
# Product/Info:
|
7
|
+
# http://jekyll.one
|
8
|
+
#
|
9
|
+
# Copyright (C) 2023, 2024 Juergen Adams
|
10
|
+
# Copyright (C) 2014-2015 Benoit Tremblay
|
11
|
+
#
|
12
|
+
# J1 Theme is licensed under MIT License.
|
13
|
+
# See: https://github.com/jekyll-one-org/j1-template/blob/main/LICENSE
|
14
|
+
# -----------------------------------------------------------------------------
|
15
|
+
*/
|
16
|
+
|
17
|
+
/*
|
18
|
+
The MIT License (MIT)
|
19
|
+
|
20
|
+
Copyright (c) 2014-2015 Benoit Tremblay <trembl.ben@gmail.com>
|
21
|
+
|
22
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
23
|
+
of this software and associated documentation files (the "Software"), to deal
|
24
|
+
in the Software without restriction, including without limitation the rights
|
25
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
26
|
+
copies of the Software, and to permit persons to whom the Software is
|
27
|
+
furnished to do so, subject to the following conditions:
|
28
|
+
|
29
|
+
The above copyright notice and this permission notice shall be included in
|
30
|
+
all copies or substantial portions of the Software.
|
31
|
+
|
32
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
33
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
34
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
35
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
36
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
37
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
38
|
+
THE SOFTWARE.
|
39
|
+
*/
|
40
|
+
|
41
|
+
/*global define, YT*/
|
42
|
+
(function (root, factory) {
|
43
|
+
if(typeof exports==='object' && typeof module!=='undefined') {
|
44
|
+
var videojs = require('video.js');
|
45
|
+
module.exports = factory(videojs.default || videojs);
|
46
|
+
} else if(typeof define === 'function' && define.amd) {
|
47
|
+
define(['videojs'], function(videojs){
|
48
|
+
return (root.Youtube = factory(videojs));
|
49
|
+
});
|
50
|
+
} else {
|
51
|
+
root.Youtube = factory(root.videojs);
|
52
|
+
}
|
53
|
+
}(this, function(videojs) {
|
54
|
+
'use strict';
|
55
|
+
|
56
|
+
var _isOnMobile = videojs.browser.IS_IOS || videojs.browser.IS_ANDROID;
|
57
|
+
var Tech = videojs.getTech('Tech');
|
58
|
+
|
59
|
+
class Youtube extends Tech {
|
60
|
+
|
61
|
+
constructor(options, ready) {
|
62
|
+
super(options, ready);
|
63
|
+
|
64
|
+
this.setPoster(options.poster);
|
65
|
+
this.setSrc(this.options_.source, true);
|
66
|
+
|
67
|
+
// Set the vjs-youtube class to the player
|
68
|
+
// Parent is not set yet so we have to wait a tick
|
69
|
+
this.setTimeout(function() {
|
70
|
+
if (this.el_) {
|
71
|
+
this.el_.parentNode.className += ' vjs-youtube';
|
72
|
+
|
73
|
+
if (_isOnMobile) {
|
74
|
+
this.el_.parentNode.className += ' vjs-youtube-mobile';
|
75
|
+
}
|
76
|
+
|
77
|
+
if (Youtube.isApiReady) {
|
78
|
+
this.initYTPlayer();
|
79
|
+
} else {
|
80
|
+
Youtube.apiReadyQueue.push(this);
|
81
|
+
}
|
82
|
+
}
|
83
|
+
}.bind(this));
|
84
|
+
}
|
85
|
+
|
86
|
+
dispose() {
|
87
|
+
if (this.ytPlayer) {
|
88
|
+
//Dispose of the YouTube Player
|
89
|
+
if (this.ytPlayer.stopVideo) {
|
90
|
+
this.ytPlayer.stopVideo();
|
91
|
+
}
|
92
|
+
if (this.ytPlayer.destroy) {
|
93
|
+
this.ytPlayer.destroy();
|
94
|
+
}
|
95
|
+
} else {
|
96
|
+
//YouTube API hasn't finished loading or the player is already disposed
|
97
|
+
var index = Youtube.apiReadyQueue.indexOf(this);
|
98
|
+
if (index !== -1) {
|
99
|
+
Youtube.apiReadyQueue.splice(index, 1);
|
100
|
+
}
|
101
|
+
}
|
102
|
+
this.ytPlayer = null;
|
103
|
+
|
104
|
+
this.el_.parentNode.className = this.el_.parentNode.className
|
105
|
+
.replace(' vjs-youtube', '')
|
106
|
+
.replace(' vjs-youtube-mobile', '');
|
107
|
+
this.el_.parentNode.removeChild(this.el_);
|
108
|
+
|
109
|
+
//Needs to be called after the YouTube player is destroyed, otherwise there will be a null reference exception
|
110
|
+
Tech.prototype.dispose.call(this);
|
111
|
+
}
|
112
|
+
|
113
|
+
createEl() {
|
114
|
+
var div = document.createElement('div');
|
115
|
+
div.setAttribute('id', this.options_.techId);
|
116
|
+
div.setAttribute('style', 'width:100%;height:100%;top:0;left:0;position:absolute');
|
117
|
+
div.setAttribute('class', 'vjs-tech');
|
118
|
+
|
119
|
+
var divWrapper = document.createElement('div');
|
120
|
+
divWrapper.appendChild(div);
|
121
|
+
|
122
|
+
if (!_isOnMobile && !this.options_.ytControls) {
|
123
|
+
var divBlocker = document.createElement('div');
|
124
|
+
divBlocker.setAttribute('class', 'vjs-iframe-blocker');
|
125
|
+
divBlocker.setAttribute('style', 'position:absolute;top:0;left:0;width:100%;height:100%');
|
126
|
+
|
127
|
+
// In case the blocker is still there and we want to pause
|
128
|
+
divBlocker.onclick = function() {
|
129
|
+
this.pause();
|
130
|
+
}.bind(this);
|
131
|
+
|
132
|
+
divWrapper.appendChild(divBlocker);
|
133
|
+
}
|
134
|
+
|
135
|
+
return divWrapper;
|
136
|
+
}
|
137
|
+
|
138
|
+
// prevent "Failed to execute 'postMessage' on 'DOMWindow'"
|
139
|
+
// by setting "origin" with "playerVars"
|
140
|
+
// see: https://stackoverflow.com/questions/27573017/failed-to-execute-postmessage-on-domwindow-https-www-youtube-com-http
|
141
|
+
//
|
142
|
+
initYTPlayer() {
|
143
|
+
const origin = window.location.origin;
|
144
|
+
var playerVars = {
|
145
|
+
origin: origin,
|
146
|
+
controls: 0,
|
147
|
+
modestbranding: 1,
|
148
|
+
rel: 0,
|
149
|
+
showinfo: 0,
|
150
|
+
loop: this.options_.loop ? 1 : 0
|
151
|
+
};
|
152
|
+
|
153
|
+
// Let the user set any YouTube parameter
|
154
|
+
// https://developers.google.com/youtube/player_parameters?playerVersion=HTML5#Parameters
|
155
|
+
// To use YouTube controls, you must use ytControls instead
|
156
|
+
// To use the loop or autoplay, use the video.js settings
|
157
|
+
|
158
|
+
if (typeof this.options_.autohide !== 'undefined') {
|
159
|
+
playerVars.autohide = this.options_.autohide;
|
160
|
+
}
|
161
|
+
|
162
|
+
if (typeof this.options_['cc_load_policy'] !== 'undefined') {
|
163
|
+
playerVars['cc_load_policy'] = this.options_['cc_load_policy'];
|
164
|
+
}
|
165
|
+
|
166
|
+
if (typeof this.options_.ytControls !== 'undefined') {
|
167
|
+
playerVars.controls = this.options_.ytControls;
|
168
|
+
}
|
169
|
+
|
170
|
+
if (typeof this.options_.disablekb !== 'undefined') {
|
171
|
+
playerVars.disablekb = this.options_.disablekb;
|
172
|
+
}
|
173
|
+
|
174
|
+
if (typeof this.options_.color !== 'undefined') {
|
175
|
+
playerVars.color = this.options_.color;
|
176
|
+
}
|
177
|
+
|
178
|
+
if (!playerVars.controls) {
|
179
|
+
// Let video.js handle the fullscreen unless it is the YouTube native controls
|
180
|
+
playerVars.fs = 0;
|
181
|
+
} else if (typeof this.options_.fs !== 'undefined') {
|
182
|
+
playerVars.fs = this.options_.fs;
|
183
|
+
}
|
184
|
+
|
185
|
+
if (this.options_.source.src.indexOf('end=') !== -1) {
|
186
|
+
var srcEndTime = this.options_.source.src.match(/end=([0-9]*)/);
|
187
|
+
this.options_.end = parseInt(srcEndTime[1]);
|
188
|
+
}
|
189
|
+
|
190
|
+
if (typeof this.options_.end !== 'undefined') {
|
191
|
+
playerVars.end = this.options_.end;
|
192
|
+
}
|
193
|
+
|
194
|
+
if (typeof this.options_.hl !== 'undefined') {
|
195
|
+
playerVars.hl = this.options_.hl;
|
196
|
+
} else if (typeof this.options_.language !== 'undefined') {
|
197
|
+
// Set the YouTube player on the same language than video.js
|
198
|
+
playerVars.hl = this.options_.language.substr(0, 2);
|
199
|
+
}
|
200
|
+
|
201
|
+
if (typeof this.options_['iv_load_policy'] !== 'undefined') {
|
202
|
+
playerVars['iv_load_policy'] = this.options_['iv_load_policy'];
|
203
|
+
}
|
204
|
+
|
205
|
+
if (typeof this.options_.list !== 'undefined') {
|
206
|
+
playerVars.list = this.options_.list;
|
207
|
+
} else if (this.url && typeof this.url.listId !== 'undefined') {
|
208
|
+
playerVars.list = this.url.listId;
|
209
|
+
}
|
210
|
+
|
211
|
+
if (typeof this.options_.listType !== 'undefined') {
|
212
|
+
playerVars.listType = this.options_.listType;
|
213
|
+
}
|
214
|
+
|
215
|
+
if (typeof this.options_.modestbranding !== 'undefined') {
|
216
|
+
playerVars.modestbranding = this.options_.modestbranding;
|
217
|
+
}
|
218
|
+
|
219
|
+
if (typeof this.options_.playlist !== 'undefined') {
|
220
|
+
playerVars.playlist = this.options_.playlist;
|
221
|
+
}
|
222
|
+
|
223
|
+
if (typeof this.options_.playsinline !== 'undefined') {
|
224
|
+
playerVars.playsinline = this.options_.playsinline;
|
225
|
+
}
|
226
|
+
|
227
|
+
if (typeof this.options_.rel !== 'undefined') {
|
228
|
+
playerVars.rel = this.options_.rel;
|
229
|
+
}
|
230
|
+
|
231
|
+
if (typeof this.options_.showinfo !== 'undefined') {
|
232
|
+
playerVars.showinfo = this.options_.showinfo;
|
233
|
+
}
|
234
|
+
|
235
|
+
if (this.options_.source.src.indexOf('start=') !== -1) {
|
236
|
+
var srcStartTime = this.options_.source.src.match(/start=([0-9]*)/);
|
237
|
+
this.options_.start = parseInt(srcStartTime[1]);
|
238
|
+
}
|
239
|
+
|
240
|
+
if (typeof this.options_.start !== 'undefined') {
|
241
|
+
playerVars.start = this.options_.start;
|
242
|
+
}
|
243
|
+
|
244
|
+
if (typeof this.options_.theme !== 'undefined') {
|
245
|
+
playerVars.theme = this.options_.theme;
|
246
|
+
}
|
247
|
+
|
248
|
+
// Allow undocumented options to be passed along via customVars
|
249
|
+
if (typeof this.options_.customVars !== 'undefined') {
|
250
|
+
var customVars = this.options_.customVars;
|
251
|
+
Object.keys(customVars).forEach(function(key) {
|
252
|
+
playerVars[key] = customVars[key];
|
253
|
+
});
|
254
|
+
}
|
255
|
+
|
256
|
+
this.activeVideoId = this.url ? this.url.videoId : null;
|
257
|
+
this.activeList = playerVars.list;
|
258
|
+
|
259
|
+
var playerConfig = {
|
260
|
+
videoId: this.activeVideoId,
|
261
|
+
playerVars: playerVars,
|
262
|
+
|
263
|
+
events: {
|
264
|
+
onReady: this.onPlayerReady.bind(this),
|
265
|
+
onPlaybackQualityChange: this.onPlayerPlaybackQualityChange.bind(this),
|
266
|
+
onPlaybackRateChange: this.onPlayerPlaybackRateChange.bind(this),
|
267
|
+
onStateChange: this.onPlayerStateChange.bind(this),
|
268
|
+
onVolumeChange: this.onPlayerVolumeChange.bind(this),
|
269
|
+
onError: this.onPlayerError.bind(this)
|
270
|
+
}
|
271
|
+
};
|
272
|
+
|
273
|
+
if (typeof this.options_.enablePrivacyEnhancedMode !== 'undefined' && this.options_.enablePrivacyEnhancedMode) {
|
274
|
+
playerConfig.host = 'https://www.youtube-nocookie.com';
|
275
|
+
}
|
276
|
+
|
277
|
+
this.ytPlayer = new YT.Player(this.options_.techId, playerConfig);
|
278
|
+
}
|
279
|
+
|
280
|
+
onPlayerReady() {
|
281
|
+
if (this.options_.muted) {
|
282
|
+
this.ytPlayer.mute();
|
283
|
+
}
|
284
|
+
|
285
|
+
var playbackRates = this.ytPlayer.getAvailablePlaybackRates();
|
286
|
+
if (playbackRates.length > 1) {
|
287
|
+
this.featuresPlaybackRate = true;
|
288
|
+
}
|
289
|
+
|
290
|
+
this.playerReady_ = true;
|
291
|
+
this.triggerReady();
|
292
|
+
|
293
|
+
if (this.playOnReady) {
|
294
|
+
this.play();
|
295
|
+
} else if (this.cueOnReady) {
|
296
|
+
this.cueVideoById_(this.url.videoId);
|
297
|
+
this.activeVideoId = this.url.videoId;
|
298
|
+
}
|
299
|
+
}
|
300
|
+
|
301
|
+
onPlayerPlaybackQualityChange() {
|
302
|
+
|
303
|
+
}
|
304
|
+
|
305
|
+
onPlayerPlaybackRateChange() {
|
306
|
+
this.trigger('ratechange');
|
307
|
+
}
|
308
|
+
|
309
|
+
onPlayerStateChange(e) {
|
310
|
+
var state = e.data;
|
311
|
+
|
312
|
+
if (state === this.lastState || this.errorNumber) {
|
313
|
+
return;
|
314
|
+
}
|
315
|
+
|
316
|
+
this.lastState = state;
|
317
|
+
|
318
|
+
switch (state) {
|
319
|
+
case -1:
|
320
|
+
this.trigger('loadstart');
|
321
|
+
this.trigger('loadedmetadata');
|
322
|
+
this.trigger('durationchange');
|
323
|
+
this.trigger('ratechange');
|
324
|
+
break;
|
325
|
+
|
326
|
+
case YT.PlayerState.ENDED:
|
327
|
+
this.trigger('ended');
|
328
|
+
break;
|
329
|
+
|
330
|
+
case YT.PlayerState.PLAYING:
|
331
|
+
this.trigger('timeupdate');
|
332
|
+
this.trigger('durationchange');
|
333
|
+
this.trigger('playing');
|
334
|
+
this.trigger('play');
|
335
|
+
|
336
|
+
if (this.isSeeking) {
|
337
|
+
this.onSeeked();
|
338
|
+
}
|
339
|
+
break;
|
340
|
+
|
341
|
+
case YT.PlayerState.PAUSED:
|
342
|
+
this.trigger('canplay');
|
343
|
+
if (this.isSeeking) {
|
344
|
+
this.onSeeked();
|
345
|
+
} else {
|
346
|
+
this.trigger('pause');
|
347
|
+
}
|
348
|
+
break;
|
349
|
+
|
350
|
+
case YT.PlayerState.BUFFERING:
|
351
|
+
this.player_.trigger('timeupdate');
|
352
|
+
this.player_.trigger('waiting');
|
353
|
+
break;
|
354
|
+
}
|
355
|
+
}
|
356
|
+
|
357
|
+
onPlayerVolumeChange() {
|
358
|
+
this.trigger('volumechange');
|
359
|
+
}
|
360
|
+
|
361
|
+
onPlayerError(e) {
|
362
|
+
this.errorNumber = e.data;
|
363
|
+
this.trigger('pause');
|
364
|
+
this.trigger('error');
|
365
|
+
}
|
366
|
+
|
367
|
+
error() {
|
368
|
+
var code = 1000 + this.errorNumber; // as smaller codes are reserved
|
369
|
+
switch (this.errorNumber) {
|
370
|
+
case 5:
|
371
|
+
return { code: code, message: 'Error while trying to play the video' };
|
372
|
+
|
373
|
+
case 2:
|
374
|
+
case 100:
|
375
|
+
return { code: code, message: 'Unable to find the video' };
|
376
|
+
|
377
|
+
case 101:
|
378
|
+
case 150:
|
379
|
+
return {
|
380
|
+
code: code,
|
381
|
+
message: 'Playback on other Websites has been disabled by the video owner.'
|
382
|
+
};
|
383
|
+
}
|
384
|
+
|
385
|
+
return { code: code, message: 'YouTube unknown error (' + this.errorNumber + ')' };
|
386
|
+
}
|
387
|
+
|
388
|
+
loadVideoById_(id) {
|
389
|
+
var options = {
|
390
|
+
videoId: id
|
391
|
+
};
|
392
|
+
if (this.options_.start) {
|
393
|
+
options.startSeconds = this.options_.start;
|
394
|
+
}
|
395
|
+
if (this.options_.end) {
|
396
|
+
options.endSeconds = this.options_.end;
|
397
|
+
}
|
398
|
+
this.ytPlayer.loadVideoById(options);
|
399
|
+
}
|
400
|
+
|
401
|
+
cueVideoById_(id) {
|
402
|
+
var options = {
|
403
|
+
videoId: id
|
404
|
+
};
|
405
|
+
if (this.options_.start) {
|
406
|
+
options.startSeconds = this.options_.start;
|
407
|
+
}
|
408
|
+
if (this.options_.end) {
|
409
|
+
options.endSeconds = this.options_.end;
|
410
|
+
}
|
411
|
+
this.ytPlayer.cueVideoById(options);
|
412
|
+
}
|
413
|
+
|
414
|
+
src(src) {
|
415
|
+
if (src) {
|
416
|
+
this.setSrc({ src: src });
|
417
|
+
}
|
418
|
+
|
419
|
+
return this.source;
|
420
|
+
}
|
421
|
+
|
422
|
+
poster() {
|
423
|
+
// You can't start programmaticlly a video with a mobile
|
424
|
+
// through the iframe so we hide the poster and the play button (with CSS)
|
425
|
+
if (_isOnMobile) {
|
426
|
+
return null;
|
427
|
+
}
|
428
|
+
|
429
|
+
return this.poster_;
|
430
|
+
}
|
431
|
+
|
432
|
+
setPoster(poster) {
|
433
|
+
this.poster_ = poster;
|
434
|
+
}
|
435
|
+
|
436
|
+
setSrc(source) {
|
437
|
+
if (!source || !source.src) {
|
438
|
+
return;
|
439
|
+
}
|
440
|
+
|
441
|
+
delete this.errorNumber;
|
442
|
+
this.source = source;
|
443
|
+
this.url = Youtube.parseUrl(source.src);
|
444
|
+
|
445
|
+
if (!this.options_.poster) {
|
446
|
+
if (this.url.videoId) {
|
447
|
+
// Set the low resolution first
|
448
|
+
this.poster_ = 'https://img.youtube.com/vi/' + this.url.videoId + '/0.jpg';
|
449
|
+
this.trigger('posterchange');
|
450
|
+
|
451
|
+
// Check if their is a high res
|
452
|
+
this.checkHighResPoster();
|
453
|
+
}
|
454
|
+
}
|
455
|
+
|
456
|
+
if (this.options_.autoplay && !_isOnMobile) {
|
457
|
+
if (this.isReady_) {
|
458
|
+
this.play();
|
459
|
+
} else {
|
460
|
+
this.playOnReady = true;
|
461
|
+
}
|
462
|
+
} else if (this.activeVideoId !== this.url.videoId) {
|
463
|
+
if (this.isReady_) {
|
464
|
+
this.cueVideoById_(this.url.videoId);
|
465
|
+
this.activeVideoId = this.url.videoId;
|
466
|
+
} else {
|
467
|
+
this.cueOnReady = true;
|
468
|
+
}
|
469
|
+
}
|
470
|
+
}
|
471
|
+
|
472
|
+
autoplay() {
|
473
|
+
return this.options_.autoplay;
|
474
|
+
}
|
475
|
+
|
476
|
+
setAutoplay(val) {
|
477
|
+
this.options_.autoplay = val;
|
478
|
+
}
|
479
|
+
|
480
|
+
loop() {
|
481
|
+
return this.options_.loop;
|
482
|
+
}
|
483
|
+
|
484
|
+
setLoop(val) {
|
485
|
+
this.options_.loop = val;
|
486
|
+
}
|
487
|
+
|
488
|
+
play() {
|
489
|
+
if (!this.url || !this.url.videoId) {
|
490
|
+
return;
|
491
|
+
}
|
492
|
+
|
493
|
+
this.wasPausedBeforeSeek = false;
|
494
|
+
|
495
|
+
if (this.isReady_) {
|
496
|
+
if (this.url.listId) {
|
497
|
+
if (this.activeList === this.url.listId) {
|
498
|
+
this.ytPlayer.playVideo();
|
499
|
+
} else {
|
500
|
+
this.ytPlayer.loadPlaylist(this.url.listId);
|
501
|
+
this.activeList = this.url.listId;
|
502
|
+
}
|
503
|
+
}
|
504
|
+
|
505
|
+
if (this.activeVideoId === this.url.videoId) {
|
506
|
+
this.ytPlayer.playVideo();
|
507
|
+
} else {
|
508
|
+
this.loadVideoById_(this.url.videoId);
|
509
|
+
this.activeVideoId = this.url.videoId;
|
510
|
+
}
|
511
|
+
} else {
|
512
|
+
this.trigger('waiting');
|
513
|
+
this.playOnReady = true;
|
514
|
+
}
|
515
|
+
}
|
516
|
+
|
517
|
+
pause() {
|
518
|
+
if (this.ytPlayer) {
|
519
|
+
this.ytPlayer.pauseVideo();
|
520
|
+
}
|
521
|
+
}
|
522
|
+
|
523
|
+
paused() {
|
524
|
+
return (this.ytPlayer) ?
|
525
|
+
(this.lastState !== YT.PlayerState.PLAYING && this.lastState !== YT.PlayerState.BUFFERING)
|
526
|
+
: true;
|
527
|
+
}
|
528
|
+
|
529
|
+
currentTime() {
|
530
|
+
return this.ytPlayer ? this.ytPlayer.getCurrentTime() : 0;
|
531
|
+
}
|
532
|
+
|
533
|
+
setCurrentTime(seconds) {
|
534
|
+
if (this.lastState === YT.PlayerState.PAUSED) {
|
535
|
+
this.timeBeforeSeek = this.currentTime();
|
536
|
+
}
|
537
|
+
|
538
|
+
if (!this.isSeeking) {
|
539
|
+
this.wasPausedBeforeSeek = this.paused();
|
540
|
+
}
|
541
|
+
|
542
|
+
this.ytPlayer.seekTo(seconds, true);
|
543
|
+
this.trigger('timeupdate');
|
544
|
+
this.trigger('seeking');
|
545
|
+
this.isSeeking = true;
|
546
|
+
|
547
|
+
// A seek event during pause does not return an event to trigger a seeked event,
|
548
|
+
// so run an interval timer to look for the currentTime to change
|
549
|
+
if (this.lastState === YT.PlayerState.PAUSED && this.timeBeforeSeek !== seconds) {
|
550
|
+
clearInterval(this.checkSeekedInPauseInterval);
|
551
|
+
this.checkSeekedInPauseInterval = setInterval(function() {
|
552
|
+
if (this.lastState !== YT.PlayerState.PAUSED || !this.isSeeking) {
|
553
|
+
// If something changed while we were waiting for the currentTime to change,
|
554
|
+
// clear the interval timer
|
555
|
+
clearInterval(this.checkSeekedInPauseInterval);
|
556
|
+
} else if (this.currentTime() !== this.timeBeforeSeek) {
|
557
|
+
this.trigger('timeupdate');
|
558
|
+
this.onSeeked();
|
559
|
+
}
|
560
|
+
}.bind(this), 250);
|
561
|
+
}
|
562
|
+
}
|
563
|
+
|
564
|
+
seeking() {
|
565
|
+
return this.isSeeking;
|
566
|
+
}
|
567
|
+
|
568
|
+
// jadams, 2023-10-01: videojs.createTimeRange() deprecated in VideoJS 9
|
569
|
+
//
|
570
|
+
seekable() {
|
571
|
+
if(!this.ytPlayer) {
|
572
|
+
// return videojs.createTimeRange();
|
573
|
+
return videojs.time.createTimeRanges();
|
574
|
+
}
|
575
|
+
// return videojs.createTimeRange(0, this.ytPlayer.getDuration());
|
576
|
+
return videojs.time.createTimeRanges(0, this.ytPlayer.getDuration());
|
577
|
+
}
|
578
|
+
|
579
|
+
onSeeked() {
|
580
|
+
clearInterval(this.checkSeekedInPauseInterval);
|
581
|
+
this.isSeeking = false;
|
582
|
+
|
583
|
+
if (this.wasPausedBeforeSeek) {
|
584
|
+
this.pause();
|
585
|
+
}
|
586
|
+
|
587
|
+
this.trigger('seeked');
|
588
|
+
}
|
589
|
+
|
590
|
+
playbackRate() {
|
591
|
+
return this.ytPlayer ? this.ytPlayer.getPlaybackRate() : 1;
|
592
|
+
}
|
593
|
+
|
594
|
+
setPlaybackRate(suggestedRate) {
|
595
|
+
if (!this.ytPlayer) {
|
596
|
+
return;
|
597
|
+
}
|
598
|
+
|
599
|
+
this.ytPlayer.setPlaybackRate(suggestedRate);
|
600
|
+
}
|
601
|
+
|
602
|
+
duration() {
|
603
|
+
return this.ytPlayer ? this.ytPlayer.getDuration() : 0;
|
604
|
+
}
|
605
|
+
|
606
|
+
currentSrc() {
|
607
|
+
return this.source && this.source.src;
|
608
|
+
}
|
609
|
+
|
610
|
+
ended() {
|
611
|
+
return this.ytPlayer ? (this.lastState === YT.PlayerState.ENDED) : false;
|
612
|
+
}
|
613
|
+
|
614
|
+
volume() {
|
615
|
+
return this.ytPlayer ? this.ytPlayer.getVolume() / 100.0 : 1;
|
616
|
+
}
|
617
|
+
|
618
|
+
setVolume(percentAsDecimal) {
|
619
|
+
if (!this.ytPlayer) {
|
620
|
+
return;
|
621
|
+
}
|
622
|
+
|
623
|
+
this.ytPlayer.setVolume(percentAsDecimal * 100.0);
|
624
|
+
}
|
625
|
+
|
626
|
+
muted() {
|
627
|
+
return this.ytPlayer ? this.ytPlayer.isMuted() : false;
|
628
|
+
}
|
629
|
+
|
630
|
+
setMuted(mute) {
|
631
|
+
if (!this.ytPlayer) {
|
632
|
+
return;
|
633
|
+
}
|
634
|
+
else{
|
635
|
+
this.muted(true);
|
636
|
+
}
|
637
|
+
|
638
|
+
if (mute) {
|
639
|
+
this.ytPlayer.mute();
|
640
|
+
} else {
|
641
|
+
this.ytPlayer.unMute();
|
642
|
+
}
|
643
|
+
this.setTimeout( function(){
|
644
|
+
this.trigger('volumechange');
|
645
|
+
}, 50);
|
646
|
+
}
|
647
|
+
|
648
|
+
// jadams, 2023-10-01: videojs.createTimeRange() deprecated in VideoJS 9
|
649
|
+
//
|
650
|
+
buffered() {
|
651
|
+
if(!this.ytPlayer || !this.ytPlayer.getVideoLoadedFraction) {
|
652
|
+
// return videojs.createTimeRange();
|
653
|
+
return videojs.time.createTimeRanges();
|
654
|
+
}
|
655
|
+
|
656
|
+
var bufferedEnd = this.ytPlayer.getVideoLoadedFraction() * this.ytPlayer.getDuration();
|
657
|
+
|
658
|
+
// return videojs.createTimeRange(0, bufferedEnd);
|
659
|
+
return videojs.time.createTimeRanges(0, bufferedEnd);
|
660
|
+
}
|
661
|
+
|
662
|
+
// TODO: Can we really do something with this on YouTUbe?
|
663
|
+
preload() {}
|
664
|
+
load() {}
|
665
|
+
reset() {}
|
666
|
+
networkState() {
|
667
|
+
if (!this.ytPlayer) {
|
668
|
+
return 0; //NETWORK_EMPTY
|
669
|
+
}
|
670
|
+
switch (this.ytPlayer.getPlayerState()) {
|
671
|
+
case -1: //unstarted
|
672
|
+
return 0; //NETWORK_EMPTY
|
673
|
+
case 3: //buffering
|
674
|
+
return 2; //NETWORK_LOADING
|
675
|
+
default:
|
676
|
+
return 1; //NETWORK_IDLE
|
677
|
+
}
|
678
|
+
}
|
679
|
+
readyState() {
|
680
|
+
if (!this.ytPlayer) {
|
681
|
+
return 0; //HAVE_NOTHING
|
682
|
+
}
|
683
|
+
switch (this.ytPlayer.getPlayerState()) {
|
684
|
+
case -1: //unstarted
|
685
|
+
return 0; //HAVE_NOTHING
|
686
|
+
case 5: //video cued
|
687
|
+
return 1; //HAVE_METADATA
|
688
|
+
case 3: //buffering
|
689
|
+
return 2; //HAVE_CURRENT_DATA
|
690
|
+
default:
|
691
|
+
return 4; //HAVE_ENOUGH_DATA
|
692
|
+
}
|
693
|
+
}
|
694
|
+
|
695
|
+
supportsFullScreen() {
|
696
|
+
return document.fullscreenEnabled ||
|
697
|
+
document.webkitFullscreenEnabled ||
|
698
|
+
document.mozFullScreenEnabled ||
|
699
|
+
document.msFullscreenEnabled;
|
700
|
+
}
|
701
|
+
|
702
|
+
// Tries to get the highest resolution thumbnail available for the video
|
703
|
+
checkHighResPoster(){
|
704
|
+
var uri = 'https://img.youtube.com/vi/' + this.url.videoId + '/maxresdefault.jpg';
|
705
|
+
|
706
|
+
try {
|
707
|
+
var image = new Image();
|
708
|
+
image.onload = function(){
|
709
|
+
// Onload may still be called if YouTube returns the 120x90 error thumbnail
|
710
|
+
if('naturalHeight' in image){
|
711
|
+
if (image.naturalHeight <= 90 || image.naturalWidth <= 120) {
|
712
|
+
return;
|
713
|
+
}
|
714
|
+
} else if(image.height <= 90 || image.width <= 120) {
|
715
|
+
return;
|
716
|
+
}
|
717
|
+
|
718
|
+
this.poster_ = uri;
|
719
|
+
this.trigger('posterchange');
|
720
|
+
}.bind(this);
|
721
|
+
image.onerror = function(){};
|
722
|
+
image.src = uri;
|
723
|
+
}
|
724
|
+
catch(e){}
|
725
|
+
}
|
726
|
+
}
|
727
|
+
|
728
|
+
Youtube.isSupported = function() {
|
729
|
+
return true;
|
730
|
+
};
|
731
|
+
|
732
|
+
Youtube.canPlaySource = function(e) {
|
733
|
+
return Youtube.canPlayType(e.type);
|
734
|
+
};
|
735
|
+
|
736
|
+
Youtube.canPlayType = function(e) {
|
737
|
+
return (e === 'video/youtube');
|
738
|
+
};
|
739
|
+
|
740
|
+
Youtube.parseUrl = function(url) {
|
741
|
+
var result = {
|
742
|
+
videoId: null
|
743
|
+
};
|
744
|
+
|
745
|
+
var regex = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/;
|
746
|
+
var match = url.match(regex);
|
747
|
+
|
748
|
+
if (match && match[2].length === 11) {
|
749
|
+
result.videoId = match[2];
|
750
|
+
}
|
751
|
+
|
752
|
+
var regPlaylist = /[?&]list=([^#\&\?]+)/;
|
753
|
+
match = url.match(regPlaylist);
|
754
|
+
|
755
|
+
if(match && match[1]) {
|
756
|
+
result.listId = match[1];
|
757
|
+
}
|
758
|
+
|
759
|
+
return result;
|
760
|
+
};
|
761
|
+
|
762
|
+
function apiLoaded() {
|
763
|
+
YT.ready(function() {
|
764
|
+
Youtube.isApiReady = true;
|
765
|
+
|
766
|
+
for (var i = 0; i < Youtube.apiReadyQueue.length; ++i) {
|
767
|
+
Youtube.apiReadyQueue[i].initYTPlayer();
|
768
|
+
}
|
769
|
+
});
|
770
|
+
}
|
771
|
+
|
772
|
+
function loadScript(src, callback) {
|
773
|
+
var loaded = false;
|
774
|
+
var tag = document.createElement('script');
|
775
|
+
var firstScriptTag = document.getElementsByTagName('script')[0];
|
776
|
+
if (!firstScriptTag) {
|
777
|
+
// when loaded in jest without jsdom setup it doesn't get any element.
|
778
|
+
// In jest it doesn't really make sense to do anything, because no one is watching youtube in jest
|
779
|
+
return;
|
780
|
+
}
|
781
|
+
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
|
782
|
+
tag.onload = function () {
|
783
|
+
if (!loaded) {
|
784
|
+
loaded = true;
|
785
|
+
callback();
|
786
|
+
}
|
787
|
+
};
|
788
|
+
tag.onreadystatechange = function () {
|
789
|
+
if (!loaded && (this.readyState === 'complete' || this.readyState === 'loaded')) {
|
790
|
+
loaded = true;
|
791
|
+
callback();
|
792
|
+
}
|
793
|
+
};
|
794
|
+
tag.src = src;
|
795
|
+
}
|
796
|
+
|
797
|
+
function injectCss() {
|
798
|
+
var css = // iframe blocker to catch mouse events
|
799
|
+
'.vjs-youtube .vjs-iframe-blocker { display: none; }' +
|
800
|
+
'.vjs-youtube.vjs-user-inactive .vjs-iframe-blocker { display: block; }' +
|
801
|
+
'.vjs-youtube .vjs-poster { background-size: cover; }' +
|
802
|
+
'.vjs-youtube-mobile .vjs-big-play-button { display: none; }';
|
803
|
+
|
804
|
+
var head = document.head || document.getElementsByTagName('head')[0];
|
805
|
+
|
806
|
+
var style = document.createElement('style');
|
807
|
+
style.type = 'text/css';
|
808
|
+
|
809
|
+
if (style.styleSheet){
|
810
|
+
style.styleSheet.cssText = css;
|
811
|
+
} else {
|
812
|
+
style.appendChild(document.createTextNode(css));
|
813
|
+
}
|
814
|
+
|
815
|
+
head.appendChild(style);
|
816
|
+
}
|
817
|
+
|
818
|
+
Youtube.apiReadyQueue = [];
|
819
|
+
|
820
|
+
if (typeof document !== 'undefined'){
|
821
|
+
// loadScript('/assets/theme/j1/modules/videojs/js/plugins/yt/api/youtube.min.js', apiLoaded);
|
822
|
+
loadScript('//www.youtube.com/iframe_api', apiLoaded);
|
823
|
+
injectCss();
|
824
|
+
}
|
825
|
+
|
826
|
+
// Older versions of VJS5 doesn't have the registerTech function
|
827
|
+
if (typeof videojs.registerTech !== 'undefined') {
|
828
|
+
videojs.registerTech('Youtube', Youtube);
|
829
|
+
} else {
|
830
|
+
videojs.registerComponent('Youtube', Youtube);
|
831
|
+
}
|
832
|
+
}));
|