Video Embed & Thumbnail Generator - Version 4.6

Version Description

It's safe to update. The plugin is still completely free until version 5.0. Video.js users will notice an updated player design.

Download this release

Release Info

Developer kylegilman
Plugin Icon 128x128 Video Embed & Thumbnail Generator
Version 4.6
Comparing to
See all releases

Code changes from version 4.5.5 to 4.6

Files changed (49) hide show
  1. css/kgvid_styles.css +266 -62
  2. css/video-embed-thumbnail-generator_admin.css +9 -3
  3. js/kgvid_video_embed.js +320 -96
  4. js/kgvid_video_plugin_admin.js +301 -130
  5. js/mep-feature-sourcechooser.js +154 -0
  6. languages/video-embed-thumbnail-generator-es_ES.mo +0 -0
  7. languages/video-embed-thumbnail-generator-es_ES.po +0 -2378
  8. readme.txt +57 -327
  9. video-embed-thumbnail-generator.php +1573 -664
  10. video-js/font/VideoJS.eot +0 -0
  11. video-js/font/VideoJS.svg +99 -0
  12. video-js/font/VideoJS.ttf +0 -0
  13. video-js/font/VideoJS.woff +0 -0
  14. video-js/font/vjs.eot +0 -0
  15. video-js/font/vjs.svg +0 -28
  16. video-js/font/vjs.ttf +0 -0
  17. video-js/font/vjs.woff +0 -0
  18. video-js/kg-video-js-skin.css +81 -1015
  19. video-js/lang/ar.js +5 -5
  20. video-js/lang/ba.js +26 -0
  21. video-js/lang/bg.js +5 -5
  22. video-js/lang/ca.js +5 -5
  23. video-js/lang/cs.js +5 -5
  24. video-js/lang/da.js +26 -0
  25. video-js/lang/de.js +5 -5
  26. video-js/lang/es.js +5 -5
  27. video-js/lang/fi.js +26 -0
  28. video-js/lang/fr.js +5 -5
  29. video-js/lang/hr.js +26 -0
  30. video-js/lang/hu.js +5 -5
  31. video-js/lang/it.js +5 -5
  32. video-js/lang/ja.js +5 -5
  33. video-js/lang/ko.js +5 -5
  34. video-js/lang/nb.js +26 -0
  35. video-js/lang/nl.js +13 -13
  36. video-js/lang/nn.js +26 -0
  37. video-js/lang/pt-BR.js +6 -6
  38. video-js/lang/ru.js +5 -5
  39. video-js/lang/sr.js +26 -0
  40. video-js/lang/sv.js +26 -0
  41. video-js/lang/tr.js +5 -5
  42. video-js/lang/uk.js +5 -5
  43. video-js/lang/vi.js +5 -5
  44. video-js/lang/zh-CN.js +6 -6
  45. video-js/lang/zh-TW.js +6 -6
  46. video-js/video-js.css +1 -5
  47. video-js/video-js.swf +0 -0
  48. video-js/video-quality-selector.js +72 -29
  49. video-js/video.js +24 -202
css/kgvid_styles.css CHANGED
@@ -89,7 +89,6 @@ img.kgvid_ios_novideo {
89
}
90
91
.kgvid_video_meta {
92
- font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
93
line-height: normal;
94
color: white;
95
display: block;
@@ -113,34 +112,155 @@ img.kgvid_ios_novideo {
113
visibility: visible;
114
}
115
116
.kgvid_title {
117
- height: 12pt;
118
- font-size: 10pt;
119
- overflow: hidden;
120
- padding-top: 1px;
121
- padding-left: 4px;
122
- margin: 6px;
123
- width: auto;
124
}
125
126
- .kgvid_video_meta input {
127
- display: inline-block !important;
128
- color: #eee !important;
129
- width: 100px !important;
130
- font: 10px "Helvetica Neue", Helvetica, Arial, sans-serif !important;
131
- line-height: 1.6em !important;
132
- background-color: #999 !important;
133
- border: none !important;
134
- -moz-border-radius: 5px !important;
135
- border-radius: 5px !important;
136
- padding: 2px !important;
137
- margin: 0px !important;
138
}
139
140
- .kgvid_share {
141
- font-size: 10px;
142
- float: right;
143
- margin: 6px 6px 6px 12px;
144
}
145
146
.kgvid_below_video {
@@ -225,43 +345,41 @@ img.kgvid_ios_novideo {
225
#kgvid-simplemodal-container { color:black; background-color:#000; height:auto; }
226
#kgvid-simplemodal-container .simplemodal-data {margin-top:-1em; padding:5px;}
227
#kgvid-simplemodal-container a.modalCloseImg {
228
- width: 17px;
229
- height: 17px;
230
- display: inline;
231
- z-index: 10003;
232
- position: absolute;
233
- top: -22px;
234
- right: 0px;
235
- cursor: pointer;
236
- text-align: center;
237
- font-size: 10px;
238
- border: 1px solid #888;
239
- border-radius: 5px;
240
- background-color: #666;
241
- color: #ccc;
242
- font-family: Arial, sans-serif;
243
- line-height: 17px;
244
- font-weight: 900;
245
- text-decoration: none;
246
}
247
248
#kgvid-simplemodal-container .kgvid_gallery_nav {
249
cursor: pointer;
250
- display: inline-block;
251
- width: 26px;
252
- height: 14px;
253
- background-color: #666;
254
- text-align: center;
255
- color: #ccc;
256
- border-radius: 5px;
257
- font-family: Arial, sans-serif;
258
- font-size: 16px;
259
- font-weight: 900;
260
- border: 1px solid #888;
261
- line-height: 12px;
262
- z-index: 10003;
263
- position: absolute;
264
- text-decoration: none;
265
}
266
267
#kgvid-simplemodal-container .wp-video {
@@ -269,17 +387,16 @@ img.kgvid_ios_novideo {
269
}
270
271
.kgvid_gallery_prev {
272
- top: -20px;
273
- right: 58px;
274
}
275
276
.kgvid_gallery_next {
277
- top: -20px;
278
right: 25px;
279
}
280
281
#kgvid-simplemodal-container a.modalCloseImg:hover, #kgvid-simplemodal-container .kgvid_gallery_nav:hover {
282
- background-color: #555;
283
}
284
285
.kgvid_gallery_pagination span {
@@ -313,6 +430,16 @@ span.kgvid_gallery_pagination_arrow {
313
text-decoration: none;
314
}
315
316
/* video-quality-selector Video.js plugin styles */
317
318
.vjs-res-button span.vjs-control-text {
@@ -320,7 +447,12 @@ span.kgvid_gallery_pagination_arrow {
320
}
321
322
.vjs-res-button:before {
323
- content: "\e600"; /* Gear icon */
324
}
325
326
@@ -341,3 +473,75 @@ ul li.vjs-menu-title.vjs-res-menu-title:hover {
341
height: auto;
342
clip: auto;
343
}
89
}
90
91
.kgvid_video_meta {
92
line-height: normal;
93
color: white;
94
display: block;
112
visibility: visible;
113
}
114
115
+ .kgvid_video_meta.kgvid_no_title_meta {
116
+ background: none;
117
+ }
118
+
119
.kgvid_title {
120
+ font-size: 10pt;
121
+ padding-left: 4px;
122
+ margin: 6px;
123
+ line-height: 23pt;
124
}
125
126
+ .kgvid_meta_icons {
127
+ position: relative;
128
+ float: right;
129
+ margin-top: 5px;
130
+ margin-right: 5px;
131
}
132
133
+ .kgvid_jwplayer_meta .kgvid_meta_icons {
134
+ float: left;
135
+ margin-left: 5px;
136
+ }
137
+
138
+ .kgvid_meta_icons a {
139
+ text-decoration: none;
140
+ border: none;
141
+ box-shadow: none;
142
+ }
143
+
144
+ .kgvid_meta_icons span {
145
+ cursor: pointer;
146
+ color: white;
147
+ margin-right: 5px;
148
+ }
149
+
150
+ .kgvid_no_title_meta .kgvid_meta_icons span {
151
+ font-size: 19pt;
152
+ text-shadow: 1px 1px rgba(20,20,20,0.8);
153
+ }
154
+
155
+ .kgvid_click_trap {
156
+ display: none;
157
+ width: 100%;
158
+ height: 100%;
159
+ background: none;
160
+ position: absolute;
161
+ top: 0;
162
+ z-index: 102;
163
+ }
164
+
165
+ .kgvid_click_trap:before {
166
+ content: '\20';
167
+ }
168
+
169
+ .kgvid_share_container {
170
+ display: none;
171
+ color: white;
172
+ top: 32px;
173
+ padding-top: 18px;
174
+ padding-bottom: 18px;
175
+ width: 100%;
176
+ z-index: 103;
177
+ position: absolute;
178
+ /* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#141414+0,141414+100&0.85+65,0+100 */
179
+ background: -moz-linear-gradient(top, rgba(20,20,20,0.85) 0%, rgba(20,20,20,0.85) 65%, rgba(20,20,20,0) 100%); /* FF3.6+ */
180
+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(20,20,20,0.85)), color-stop(65%,rgba(20,20,20,0.85)), color-stop(100%,rgba(20,20,20,0))); /* Chrome,Safari4+ */
181
+ background: -webkit-linear-gradient(top, rgba(20,20,20,0.85) 0%,rgba(20,20,20,0.85) 65%,rgba(20,20,20,0) 100%); /* Chrome10+,Safari5.1+ */
182
+ background: -o-linear-gradient(top, rgba(20,20,20,0.85) 0%,rgba(20,20,20,0.85) 65%,rgba(20,20,20,0) 100%); /* Opera 11.10+ */
183
+ background: -ms-linear-gradient(top, rgba(20,20,20,0.85) 0%,rgba(20,20,20,0.85) 65%,rgba(20,20,20,0) 100%); /* IE10+ */
184
+ background: linear-gradient(to bottom, rgba(20,20,20,0.85) 0%,rgba(20,20,20,0.85) 65%,rgba(20,20,20,0) 100%); /* W3C */
185
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#d9141414', endColorstr='#00141414',GradientType=0 ); /* IE6-9 */
186
+ }
187
+
188
+ .kgvid_share_container.kgvid_no_title_meta {
189
+ top: 0;
190
+ z-index: 102;
191
+ padding-top: 32px;
192
+ }
193
+
194
+ .kgvid_share_icons {
195
+ text-align: center;
196
+ line-height: 26pt;
197
+ font-size: 22pt;
198
+ font-family: sans-serif;
199
+ word-wrap: normal;
200
+ overflow-wrap: normal;
201
+ }
202
+
203
+ .kgvid_share_icons a {
204
+ text-decoration: none;
205
+ border: none;
206
+ box-shadow: none;
207
+ }
208
+
209
+ .kgvid_share_icons span {
210
+ font-size: 13pt;
211
+ line-height: 29pt;
212
+ width: inherit;
213
+ height: inherit;
214
+ margin: 0;
215
+ padding: 0;
216
+ }
217
+
218
+ .kgvid_share_icons span.dashicons.dashicons-editor-code {
219
+ font-size: 22pt;
220
+ }
221
+
222
+ .kgvid_share_icons input[type="text"] {
223
+ font-family: sans-serif !important;
224
+ font-size: 10pt !important;
225
+ color: white !important;
226
+ width: 50% !important;
227
+ background: #ABACA8 !important;
228
+ padding: 4px !important;
229
+ border-radius: 6px !important;
230
+ border: none !important;
231
+ display: inline-block !important;
232
+ }
233
+
234
+ .kgvid_share_icons .kgvid_social_icons {
235
+ margin-top: 8px;
236
+ font-size: 19pt;
237
+ }
238
+
239
+ .kgvid_share_icons span.dashicons.dashicons-twitter {
240
+ color: #55acee;
241
+ font-size: 32pt;
242
+ }
243
+
244
+ span.kgvid_facebook_icon_holder {
245
+ font-family: sans-serif;
246
+ position: relative;
247
+ vertical-align: middle;
248
+ }
249
+
250
+ .kgvid_share_icons span.dashicons.dashicons-facebook {
251
+ color: #3b5998;
252
+ font-size: 32pt;
253
+ }
254
+
255
+ .kgvid_share_icons span.dashicons.dashicons-facebook:after {
256
+ content: "\20";
257
+ background: white;
258
+ width: 20pt;
259
+ height: 21.25pt;
260
+ position: absolute;
261
+ left: 9px;
262
+ top: -2px;
263
+ z-index: -1;
264
}
265
266
.kgvid_below_video {
345
#kgvid-simplemodal-container { color:black; background-color:#000; height:auto; }
346
#kgvid-simplemodal-container .simplemodal-data {margin-top:-1em; padding:5px;}
347
#kgvid-simplemodal-container a.modalCloseImg {
348
+ display: inline;
349
+ box-sizing: border-box;
350
+ padding: 2px 2px 2px 3px;
351
+ z-index: 10003;
352
+ position: absolute;
353
+ top: -25px;
354
+ right: -5px;
355
+ cursor: pointer;
356
+ text-align: center;
357
+ font-size: 13px;
358
+ border-radius: 8px;
359
+ background-color: rgba(0,0,0,0.5);
360
+ color: #ccc;
361
+ font-family: Arial, sans-serif;
362
+ line-height: 18px;
363
+ font-weight: 900;
364
+ text-decoration: none;
365
}
366
367
#kgvid-simplemodal-container .kgvid_gallery_nav {
368
cursor: pointer;
369
+ display: inline-block;
370
+ padding: 3px 7px 4px 7px;
371
+ background-color: rgba(0,0,0,0.5);
372
+ text-align: center;
373
+ color: white;
374
+ border-radius: 5px;
375
+ font-family: Arial, sans-serif;
376
+ font-size: 16px;
377
+ font-weight: 900;
378
+ line-height: 12px;
379
+ z-index: 10003;
380
+ position: absolute;
381
+ text-decoration: none;
382
+ top: -22px;
383
}
384
385
#kgvid-simplemodal-container .wp-video {
387
}
388
389
.kgvid_gallery_prev {
390
+ right: 59px;
391
}
392
393
.kgvid_gallery_next {
394
right: 25px;
395
}
396
397
#kgvid-simplemodal-container a.modalCloseImg:hover, #kgvid-simplemodal-container .kgvid_gallery_nav:hover {
398
+ background-color: black;
399
+ box-shadow: 0px 0px 4px #fff;
400
}
401
402
.kgvid_gallery_pagination span {
430
text-decoration: none;
431
}
432
433
+ .kgvid_temp_thumb {
434
+ position: absolute;
435
+ top: 0;
436
+ left: 0;
437
+ width: 100%;
438
+ height: 100%;
439
+ margin: 0;
440
+ padding: 0;
441
+ }
442
+
443
/* video-quality-selector Video.js plugin styles */
444
445
.vjs-res-button span.vjs-control-text {
447
}
448
449
.vjs-res-button:before {
450
+ font-family: VideoJs;
451
+ content: "\f110"; /* Gear icon */
452
+ }
453
+
454
+ .vjs-loading-spinner {
455
+ z-index: 1;
456
}
457
458
473
height: auto;
474
clip: auto;
475
}
476
+
477
+ /* mep-feature-sourcechooser plugin styles */
478
+
479
+ .kgvid_wrapper .mejs-controls div.mejs-sourcechooser-button button {
480
+ background: none;
481
+ font-family: dashicons;
482
+ color: white;
483
+ font-size: 11pt;
484
+ line-height: 0pt;
485
+ }
486
+
487
+ .kgvid_wrapper .mejs-controls .mejs-sourcechooser-button button:before {
488
+ content: "\f111";
489
+ }
490
+
491
+ .mejs-container .mejs-controls div.mejs-menu-arrow {
492
+ display: none;
493
+ position: absolute;
494
+ bottom: -7px;
495
+ left: -8px;
496
+ width: 0em;
497
+ height: 0em;
498
+ margin-bottom: 3em;
499
+ border-left: 2em solid transparent;
500
+ border-right: 2em solid transparent;
501
+ border-top: 1.55em solid #000000;
502
+ border-top-color: rgba(40, 40, 40, 0.5);
503
+ }
504
+
505
+ div.mejs-controls .mejs-sourcechooser-button .mejs-sourcechooser-selector {
506
+ visibility: inherit;
507
+ bottom: 17px;
508
+ right: -28px;
509
+ width: auto;
510
+ height: auto;
511
+ padding: 9px 0 0 0;
512
+ text-align: center;
513
+ -webkit-box-shadow: -0.2em -0.2em 0.3em rgba(255, 255, 255, 0.2);
514
+ -moz-box-shadow: -0.2em -0.2em 0.3em rgba(255, 255, 255, 0.2);
515
+ box-shadow: -0.2em -0.2em 0.3em rgba(255, 255, 255, 0.2);
516
+ }
517
+
518
+ div.mejs-controls .mejs-sourcechooser-button .mejs-sourcechooser-selector span {
519
+ color: white;
520
+ padding: 0px 10px 5px 10px;
521
+ display: block;
522
+ white-space: nowrap;
523
+ }
524
+
525
+ div.mejs-controls .mejs-sourcechooser-button .mejs-sourcechooser-selector ul li {
526
+ margin: 3px 0 3px 0;
527
+ padding: 2px 10px 5px 10px;
528
+ cursor: pointer;
529
+ }
530
+
531
+ div.mejs-controls .mejs-sourcechooser-button .mejs-sourcechooser-selector ul li.mejs-sourcechooser-selected {
532
+ background: rgba(20,20,20,0.8);
533
+ }
534
+
535
+ div.mejs-controls .mejs-sourcechooser-button .mejs-sourcechooser-selector ul li:hover {
536
+ color: #111;
537
+ background-color: #ffffff;
538
+ background-color: rgba(255, 255, 255, 0.75);
539
+ }
540
+
541
+ .mejs-controls .mejs-sourcechooser-button .mejs-sourcechooser-selector ul li input {
542
+ display: none;
543
+ }
544
+
545
+ div.mejs-controls .mejs-sourcechooser-button .mejs-sourcechooser-selector ul li label {
546
+ width: auto;
547
+ }
css/video-embed-thumbnail-generator_admin.css CHANGED
@@ -212,7 +212,6 @@ div.kgvid_chosen_thumbnail_box {
212
213
div.kgvid_thumbnail_overlay {
214
width: 100%;
215
- height:100%;
216
background: #fff;
217
opacity: 0.5;
218
filter: alpha(opacity = 50); /* required for opacity to work in IE */
@@ -268,6 +267,13 @@ font-weight: normal;
268
.kgvid_setting_nearvid div {
269
margin: 5px;
270
font-weight: bold;
271
}
272
273
.kgvid_htaccess td {
@@ -295,13 +301,14 @@ font-weight: normal;
295
}
296
297
.kgvid_tooltip:hover span {
298
- font-family: Calibri, Tahoma, Geneva, sans-serif;
299
position: absolute;
300
left: 1em;
301
top: 2em;
302
z-index: 99;
303
margin-left: 0;
304
width: 250px;
305
border-radius: 5px 5px;
306
-moz-border-radius: 5px;
307
-webkit-border-radius: 5px;
@@ -569,7 +576,6 @@ td.media-icon img {
569
570
.kgvid_queue_message {
571
font-size: 129%;
572
- margin-left: 10px;
573
color: #298CBA;
574
}
575
212
213
div.kgvid_thumbnail_overlay {
214
width: 100%;
215
background: #fff;
216
opacity: 0.5;
217
filter: alpha(opacity = 50); /* required for opacity to work in IE */
267
.kgvid_setting_nearvid div {
268
margin: 5px;
269
font-weight: bold;
270
+ white-space: nowrap;
271
+
272
+ }
273
+
274
+ .kgvid_setting_nearvid span {
275
+ display: inline-block;
276
+ width: 33%;
277
}
278
279
.kgvid_htaccess td {
301
}
302
303
.kgvid_tooltip:hover span {
304
position: absolute;
305
left: 1em;
306
top: 2em;
307
z-index: 99;
308
margin-left: 0;
309
width: 250px;
310
+ font-weight: normal;
311
+ white-space: normal;
312
border-radius: 5px 5px;
313
-moz-border-radius: 5px;
314
-webkit-border-radius: 5px;
576
577
.kgvid_queue_message {
578
font-size: 129%;
579
color: #298CBA;
580
}
581
js/kgvid_video_embed.js CHANGED
@@ -1,29 +1,71 @@
1
kgvid_video_vars = {};
2
3
jQuery(document).ready(kgvid_document_ready());
4
5
function kgvid_document_ready() {
6
7
- jQuery('.kgvid_videodiv').each(function(){ //setup individual videos
8
var video_vars = jQuery(this).data('kgvid_video_vars');
9
- if ( video_vars.player_type == "Strobe Media Playback" ) {
10
- swfobject.embedSWF(video_vars.swfurl, 'video_'+video_vars.id, video_vars.width, video_vars.height, '10.1.0', video_vars.expressinstallswfurl, video_vars.flashvars, video_vars.params);
11
}
12
13
- kgvid_setup_video(video_vars.id);
14
15
});
16
17
jQuery('.kgvid_gallerywrapper').each(function(){ //setup gallery thumbnails
18
19
var gallery_id = this.id;
20
kgvid_resize_gallery_play_button(gallery_id);
21
jQuery(window).resize( function(){ kgvid_resize_gallery_play_button(gallery_id) } );
22
-
23
});
24
25
}
26
27
function kgvid_SetVideo(id) { //for galleries
28
29
//set the viewport meta tag so the gallery fits in iOS
@@ -60,7 +102,7 @@ function kgvid_SetVideo(id) { //for galleries
60
minHeight:frame_height,
61
autoResize: false,
62
overlayClose:true,
63
- closeHTML:'<a class="modalCloseImg simplemodal-close" title="Close">X</a>',
64
zIndex:10000,
65
onShow: function(dialog) {
66
@@ -123,12 +165,12 @@ function kgvid_SetVideo(id) { //for galleries
123
jQuery('#kgvid_popup_video_holder_'+id).html(popup_code);
124
jQuery('#video_'+id+'_div').data('kgvid_video_vars', video_vars);
125
126
- if ( video_vars.player_type == "Strobe Media Playback" ) {
127
swfobject.embedSWF(video_vars.swfurl, 'video_'+id, video_vars.width, video_vars.height, '10.1.0', video_vars.expressinstallswfurl, video_vars.flashvars, video_vars.params);
128
}
129
130
jQuery.modal.setContainerDimensions();
131
- kgvid_setup_video(id);
132
jQuery.modal.setPosition();
133
134
dialog.wrap.css('overflow', 'hidden'); //disable scroll bars
@@ -160,7 +202,8 @@ function kgvid_SetVideo(id) { //for galleries
160
}, false);
161
}//end if flash or silverlight
162
else { mediaElement.play(); }
163
- }
164
});
165
}//end if WordPress Default
166
}//end check to make sure video still needs to load
@@ -198,10 +241,34 @@ function kgvid_video_gallery_end_action(id, action) {
198
}
199
}
200
201
- function kgvid_timeupdate() {
202
jQuery('#'+this.id()+' > .vjs-poster').fadeOut();
203
}
204
205
function kgvid_setup_video(id) {
206
207
var video_vars = jQuery('#video_'+id+'_div').data('kgvid_video_vars');
@@ -209,11 +276,13 @@ function kgvid_setup_video(id) {
209
if ( typeof (jQuery) == 'function' ) { jQuery.fn.fitVids=function(){}; }; //disable fitvids
210
211
var iOS = ( navigator.userAgent.match(/(iPad|iPhone|iPod)/i) ? true : false );
212
- if (iOS && video_vars.player_type == "Strobe Media Playback" ) { video_vars.player_type = "Video.js"; }
213
214
jQuery('#video_'+id+'_div').prepend(jQuery('#video_'+id+'_watermark'));
215
jQuery('#video_'+id+'_watermark').attr('style', ''); //shows the hidden watermark div
216
jQuery('#video_'+id+'_div').prepend(jQuery('#video_'+id+'_meta'));
217
jQuery('#video_'+id+'_meta').attr('style', ''); //shows the hidden meta div
218
if ( video_vars.autoplay == "true" ) { jQuery('#video_'+id+'_meta').removeClass('kgvid_video_meta_hover'); }
219
@@ -234,11 +303,11 @@ function kgvid_setup_video(id) {
234
player.on('loadedmetadata', function(){
235
236
var text_tracks = player.textTracks();
237
- var default_track_id = jQuery('#video_'+id+'_div track[default]').first().attr('id');
238
239
- if ( default_track_id != null ) {
240
jQuery(text_tracks).each(function(index, track) {
241
- if ( track.id == default_track_id && track.mode != 'showing' ) { player.textTracks()[index].mode = 'showing'; }
242
});
243
}
244
@@ -248,21 +317,39 @@ function kgvid_setup_video(id) {
248
});
249
250
player.on('play', function kgvid_play_start(){
251
- player.off('timeupdate', kgvid_timeupdate);
252
if ( video_vars.meta ) {
253
- jQuery('#video_'+id+'_div').hover(
254
- function(){
255
- jQuery('#video_'+id+'_meta').addClass('kgvid_video_meta_hover');
256
- },
257
- function(){
258
- jQuery('#video_'+id+'_meta').removeClass('kgvid_video_meta_hover');
259
- }
260
- );
261
jQuery('#video_'+id+'_meta').removeClass('kgvid_video_meta_hover');
262
}
263
if ( video_vars.autoplay == "true" ) { jQuery('#video_'+id+' > .vjs-control-bar').removeClass('vjs-fade-in'); }
264
if ( video_vars.endofvideooverlay != "" ) { jQuery('#video_'+id+' > .vjs-poster').hide(); }
265
kgvid_video_counter(id, 'play');
266
});
267
268
player.on('ended', function kgvid_play_end(){
@@ -273,7 +360,7 @@ function kgvid_setup_video(id) {
273
'background-image':'url('+video_vars.endofvideooverlay+')'
274
}).fadeIn();
275
276
- setTimeout(function() { player.on('timeupdate', kgvid_timeupdate); }, 500);
277
278
}
279
if ( jQuery('#kgvid_video_gallery_thumb_'+id).data('gallery_end') != "" && jQuery('#kgvid_video_gallery_thumb_'+id).data('gallery_end') != null ) {
@@ -308,10 +395,13 @@ function kgvid_setup_video(id) {
308
}
309
}
310
311
- if ( jQuery('#video_'+id).hasClass('vjs-fullscreen') ) {
312
- var resolutions = player.availableRes;
313
- var highest_res = Object.keys(resolutions)[Object.keys(resolutions).length - 1];
314
- player.changeRes(highest_res);
315
}
316
317
if ( fullScreenApi.supportsFullScreen == false ) {
@@ -327,46 +417,88 @@ function kgvid_setup_video(id) {
327
328
});
329
330
- player.on( 'changeRes', function() {
331
- if ( jQuery('#video_'+id).hasClass('vjs-has-started') == true ) {
332
- var poster = jQuery('#video_'+id+' video').attr('poster');
333
- jQuery('#video_'+id+' video').removeAttr('poster'); //prevents poster from showing during resolution switch
334
- player.on ( 'ended', function() { jQuery('#video_'+id+' video').attr('poster', poster); } );
335
- }
336
- });
337
-
338
if ( video_vars.autoplay == "true" && player.paused() ) { player.play(); }
339
340
} //end if Video.js
341
342
- if ( video_vars.player_type == "Strobe Media Playback" || video_vars.player_type == "WordPressDefault" ) {
343
-
344
- jQuery('#video_'+id+'_div').hover(
345
- function(){
346
- jQuery('#video_'+id+'_meta').addClass('kgvid_video_meta_hover');
347
- },
348
- function(){
349
- jQuery('#video_'+id+'_meta').removeClass('kgvid_video_meta_hover');
350
- }
351
- );
352
- } //end if Strobe Media Playback
353
-
354
if ( video_vars.player_type == "WordPressDefault" ) {
355
356
- player = jQuery('#video_'+id+'_div video');
357
358
player.on('loadedmetadata', function() {
359
if ( video_vars.set_volume != "" ) { player[0].volume = video_vars.set_volume; }
360
if ( video_vars.mute == "true" ) { player[0].setMuted(true); }
361
jQuery('#video_'+id+'_div .mejs-container').append(jQuery('#video_'+id+'_watermark'));
362
- });
363
364
- jQuery('#video_'+id+'_div .wp-video').one('click', function(){
365
- jQuery('#video_'+id+'_meta').removeClass('kgvid_video_meta_hover');
366
});
367
368
player.on('play', function(){
369
kgvid_video_counter(id, 'play');
370
});
371
372
player.on('ended', function(){
@@ -393,7 +525,8 @@ function kgvid_setup_video(id) {
393
} //end if WordPress Default
394
395
if ( video_vars.player_type == "JWPlayer" ) {
396
- player_id = jQuery('#video_'+id+'_div').children('div[id^="jwplayer"]').attr('id');
397
var player = jwplayer(player_id);
398
399
if ( video_vars.set_volume != "" ) { player.setVolume(Math.round(video_vars.set_volume*100)); }
@@ -403,17 +536,28 @@ function kgvid_setup_video(id) {
403
kgvid_video_counter(id, 'play');
404
405
if ( video_vars.meta ) {
406
- jQuery('#video_'+id+'_div').hover(
407
- function(){
408
- jQuery('#video_'+id+'_meta').addClass('kgvid_video_meta_hover');
409
- },
410
- function(){
411
- jQuery('#video_'+id+'_meta').removeClass('kgvid_video_meta_hover');
412
- }
413
- );
414
jQuery('#video_'+id+'_meta').removeClass('kgvid_video_meta_hover');
415
}
416
417
});
418
419
player.onComplete( function() {
@@ -437,6 +581,7 @@ function kgvid_setup_video(id) {
437
kgvid_resize_video(id);
438
jQuery(window).resize( function(){ kgvid_resize_video(id) } );
439
}
440
}
441
442
function kgvid_resize_video(id) {
@@ -452,7 +597,7 @@ function kgvid_resize_video(id) {
452
var set_height = video_vars.height;
453
var aspect_ratio = Math.round(set_height/set_width*1000)/1000
454
var reference_div = jQuery('#kgvid_'+id+'_wrapper').parent();
455
- if ( reference_div.is('body') ) { parent_width = window.innerWidth; }
456
else if ( reference_div.attr('id') == 'kgvid_popup_video_holder_'+id ) { //if it's a pop-up video
457
var window_width = jQuery(window).width();
458
var window_height = jQuery(window).height();
@@ -474,7 +619,10 @@ function kgvid_resize_video(id) {
474
set_width = Math.round(set_height / aspect_ratio);
475
}
476
477
- if ( video_vars.player_type == "Video.js" && eval('videojs.players.video_'+id) != null ) {
478
var player = videojs('video_'+id);
479
player.width(set_width).height(set_height);
480
@@ -492,46 +640,59 @@ function kgvid_resize_video(id) {
492
}
493
}
494
else { jQuery('#kgvid_'+id+'_wrapper .vjs-big-play-button').removeAttr('style'); }
495
-
496
- if ( video_vars.auto_res == 'automatic' && player.availableRes !== undefined ) {
497
- var resolutions = player.availableRes;
498
- var resNumbers = [];
499
- jQuery.each(resolutions, function(){
500
- if ( this[0] != undefined && !isNaN(parseInt(this[0]['data-res'])) ) {
501
- resNumbers.push(parseInt(this[0]['data-res']));
502
- }
503
- });
504
- var current_resolution = parseInt(player.getCurrentRes());
505
-
506
- if ( !isNaN(current_resolution) ) {
507
- if ( window.devicePixelRatio != undefined ) { var pixel_height = set_height * window.devicePixelRatio; } //don't shortchange retina displays
508
- else { pixel_height = set_height; }
509
- var res_options = jQuery.map(resNumbers, function(n) {
510
- if ( n >= pixel_height ) { return n; }
511
- });
512
- var set_res = Math.min.apply(Math,res_options);
513
- if ( set_res != current_resolution && !jQuery('#video_'+id).hasClass('vjs-fullscreen') ) {
514
- player.changeRes(set_res+'p');
515
- }
516
- if ( jQuery('#video_'+id).hasClass('vjs-has-started') == false ) {
517
- if ( player.muted() == true ) { player.muted(false); player.muted(true); } // reset volume and mute otherwise player doesn't display properly
518
- if ( player.volume() != 1 ) {
519
- var current_volume = player.volume();
520
- player.volume(1);
521
- player.volume(current_volume);
522
- }
523
- }
524
- }
525
- }
526
-
527
}
528
- if ( video_vars.player_type == "Strobe Media Playback" ) {
529
jQuery('#video_'+id+'_div').height(set_height);
530
jQuery('#video_'+id).attr('width',set_width).attr('height',set_height);
531
jQuery('#video_'+id+'_html5_api').attr('width',set_width).attr('height',set_height);
532
}
533
if ( video_vars.player_type == "WordPressDefault" ) {
534
jQuery('#kgvid_'+id+'_wrapper').find('.wp-video').attr('style', 'width:'+set_width+'px; height:'+set_height+'px;');
535
}
536
537
var meta = jQuery('#kgvid_video_gallery_thumb_'+id).data('meta');
@@ -620,6 +781,14 @@ function kgvid_video_counter(id, event) {
620
else if (typeof _gaq != "undefined") { _gaq.push(["_trackEvent", "Videos", kgvidL10n_frontend.playstart, title]); }
621
622
}
623
if ( event == "end" ) {
624
if (video_vars.countable) { //video is in the db
625
changed = true;
@@ -668,3 +837,58 @@ function kgvid_switch_gallery_page(obj, post_action) {
668
}, "json");
669
670
}
1
kgvid_video_vars = {};
2
3
+ jQuery('.kgvid_videodiv').each(function(){ //setup individual videos. WordPress Default has its own success callback
4
+
5
+ var video_vars = jQuery(this).data('kgvid_video_vars');
6
+
7
+ if ( video_vars.player_type == "Video.js" ) {
8
+
9
+ var videojs_options = { "html5": { "nativeTextTracks" : false }, "language": video_vars.locale };
10
+ if ( video_vars.resize == "true" ) {
11
+ videojs_options.fluid = true;
12
+ }
13
+ if ( video_vars.nativecontrolsfortouch == "true" ) {
14
+ videojs_options.nativeControlsForTouch = true;
15
+ }
16
+ if ( video_vars.enable_resolutions_plugin == "true" ) {
17
+ videojs_options.plugins = { "resolutionSelector" : { "force_types" : ["video/mp4"] } };
18
+ if ( video_vars.default_res ) {
19
+ videojs_options.plugins.resolutionSelector.default_res = video_vars.default_res;
20
+ }
21
+ }
22
+
23
+ videojs('video_'+video_vars.id, videojs_options ).ready(function(){ kgvid_setup_video(video_vars.id); });
24
+ }
25
+ });
26
+
27
jQuery(document).ready(kgvid_document_ready());
28
+ jQuery(window).load(kgvid_window_load());
29
30
function kgvid_document_ready() {
31
32
+ jQuery('.kgvid_videodiv').each(function(){ //setup individual videos. WordPress Default has its own success callback
33
+
34
var video_vars = jQuery(this).data('kgvid_video_vars');
35
+
36
+ if ( video_vars.player_type == "JWPlayer" ) {
37
+ var player_id = jQuery('#video_'+video_vars.id+'_div').children('div[id^="jwplayer"]').attr('id');
38
+ player_id = player_id.replace('_wrapper', ''); //Flash JW Players have wrapper in the id
39
+ var player = jwplayer(player_id);
40
+ player.onReady( kgvid_setup_video(video_vars.id) );
41
}
42
43
+ if ( video_vars.player_type == "StrobeMediaPlayback" ) {
44
+ swfobject.embedSWF(video_vars.swfurl, 'video_'+video_vars.id, video_vars.width, video_vars.height, '10.1.0', video_vars.expressinstallswfurl, video_vars.flashvars, video_vars.params);
45
+ kgvid_setup_video(video_vars.id);
46
+ }
47
48
});
49
50
+ }
51
+
52
+ function kgvid_window_load() {
53
+
54
jQuery('.kgvid_gallerywrapper').each(function(){ //setup gallery thumbnails
55
56
var gallery_id = this.id;
57
kgvid_resize_gallery_play_button(gallery_id);
58
jQuery(window).resize( function(){ kgvid_resize_gallery_play_button(gallery_id) } );
59
+ setTimeout(function(){ kgvid_resize_gallery_play_button(gallery_id) }, 200);
60
});
61
62
}
63
64
+ function kgvid_mejs_success(mediaElement, domObject) {
65
+ var id = jQuery(domObject).parents('.kgvid_videodiv').data('id');
66
+ kgvid_setup_video(id);
67
+ }
68
+
69
function kgvid_SetVideo(id) { //for galleries
70
71
//set the viewport meta tag so the gallery fits in iOS
102
minHeight:frame_height,
103
autoResize: false,
104
overlayClose:true,
105
+ closeHTML:'<a class="modalCloseImg simplemodal-close" title="Close"><span class="dashicons dashicons-no-alt"></span></a>',
106
zIndex:10000,
107
onShow: function(dialog) {
108
165
jQuery('#kgvid_popup_video_holder_'+id).html(popup_code);
166
jQuery('#video_'+id+'_div').data('kgvid_video_vars', video_vars);
167
168
+ if ( video_vars.player_type == "StrobeMediaPlayback" ) {
169
swfobject.embedSWF(video_vars.swfurl, 'video_'+id, video_vars.width, video_vars.height, '10.1.0', video_vars.expressinstallswfurl, video_vars.flashvars, video_vars.params);
170
}
171
172
jQuery.modal.setContainerDimensions();
173
+ setTimeout(function() { kgvid_setup_video(id); }, 0);
174
jQuery.modal.setPosition();
175
176
dialog.wrap.css('overflow', 'hidden'); //disable scroll bars
202
}, false);
203
}//end if flash or silverlight
204
else { mediaElement.play(); }
205
+ },
206
+ features : [ 'playpause', 'progress', 'volume', 'tracks', 'sourcechooser', 'fullscreen' ]
207
});
208
}//end if WordPress Default
209
}//end check to make sure video still needs to load
241
}
242
}
243
244
+ function kgvid_timeupdate_poster() {
245
jQuery('#'+this.id()+' > .vjs-poster').fadeOut();
246
}
247
248
+ function kgvid_add_hover(id) {
249
+
250
+ jQuery('#video_'+id+'_div').hover(
251
+ function(){
252
+ jQuery('#video_'+id+'_meta').addClass('kgvid_video_meta_hover');
253
+ },
254
+ function(){
255
+ jQuery('#video_'+id+'_meta').removeClass('kgvid_video_meta_hover');
256
+ }
257
+ );
258
+
259
+ jQuery('#video_'+id+'_div').focus(
260
+ function(){
261
+ jQuery('#video_'+id+'_meta').addClass('kgvid_video_meta_hover');
262
+ }
263
+ )
264
+ .focusout(
265
+ function(){
266
+ jQuery('#video_'+id+'_meta').removeClass('kgvid_video_meta_hover');
267
+ }
268
+ );
269
+
270
+ }
271
+
272
function kgvid_setup_video(id) {
273
274
var video_vars = jQuery('#video_'+id+'_div').data('kgvid_video_vars');
276
if ( typeof (jQuery) == 'function' ) { jQuery.fn.fitVids=function(){}; }; //disable fitvids
277
278
var iOS = ( navigator.userAgent.match(/(iPad|iPhone|iPod)/i) ? true : false );
279
+ if (iOS && video_vars.player_type == "StrobeMediaPlayback" ) { video_vars.player_type = "Video.js"; }
280
281
jQuery('#video_'+id+'_div').prepend(jQuery('#video_'+id+'_watermark'));
282
jQuery('#video_'+id+'_watermark').attr('style', ''); //shows the hidden watermark div
283
jQuery('#video_'+id+'_div').prepend(jQuery('#video_'+id+'_meta'));
284
+ jQuery('#video_'+id+'_embed, #click_trap_'+id).appendTo('#video_'+id+'_div');
285
+ jQuery('#click_trap_'+id).on('click', function(){ kgvid_share_icon_click(id); });
286
jQuery('#video_'+id+'_meta').attr('style', ''); //shows the hidden meta div
287
if ( video_vars.autoplay == "true" ) { jQuery('#video_'+id+'_meta').removeClass('kgvid_video_meta_hover'); }
288
303
player.on('loadedmetadata', function(){
304
305
var text_tracks = player.textTracks();
306
+ var track_elements = player.options_.tracks;
307
308
+ if ( track_elements != null ) {
309
jQuery(text_tracks).each(function(index, track) {
310
+ if ( track_elements[index].default == true && track.mode != 'showing' ) { player.textTracks()[index].mode = 'showing'; }
311
});
312
}
313
317
});
318
319
player.on('play', function kgvid_play_start(){
320
+ player.off('timeupdate', kgvid_timeupdate_poster);
321
if ( video_vars.meta ) {
322
+ kgvid_add_hover(id);
323
jQuery('#video_'+id+'_meta').removeClass('kgvid_video_meta_hover');
324
}
325
if ( video_vars.autoplay == "true" ) { jQuery('#video_'+id+' > .vjs-control-bar').removeClass('vjs-fade-in'); }
326
if ( video_vars.endofvideooverlay != "" ) { jQuery('#video_'+id+' > .vjs-poster').hide(); }
327
kgvid_video_counter(id, 'play');
328
+
329
+ player.on('timeupdate', function(){
330
+
331
+ var percent_duration = Math.round(player.currentTime() / player.duration() * 100);
332
+
333
+ if ( jQuery('#video_'+id+'_div').data("25") == undefined && percent_duration >= 25 && percent_duration < 50 ) {
334
+ jQuery('#video_'+id+'_div').data("25", true);
335
+ kgvid_video_counter(id, '25');
336
+ }
337
+ else if ( jQuery('#video_'+id+'_div').data("50") == undefined && percent_duration >= 50 && percent_duration < 75 ) {
338
+ jQuery('#video_'+id+'_div').data("50", true);
339
+ kgvid_video_counter(id, '50');
340
+ }
341
+ else if ( jQuery('#video_'+id+'_div').data("75") == undefined && percent_duration >= 75 && percent_duration < 100 ) {
342
+ jQuery('#video_'+id+'_div').data("75", true);
343
+ kgvid_video_counter(id, '75');
344
+
345
+ }
346
+
347
+ });
348
+
349
+ });
350
+
351
+ player.on('pause', function kgvid_play_pause(){
352
+ jQuery('#video_'+id+'_meta').addClass('kgvid_video_meta_hover');
353
});
354
355
player.on('ended', function kgvid_play_end(){
360
'background-image':'url('+video_vars.endofvideooverlay+')'
361
}).fadeIn();
362
363
+ setTimeout(function() { player.on('timeupdate', kgvid_timeupdate_poster); }, 500);
364
365
}
366
if ( jQuery('#kgvid_video_gallery_thumb_'+id).data('gallery_end') != "" && jQuery('#kgvid_video_gallery_thumb_'+id).data('gallery_end') != null ) {
395
}
396
}
397
398
+ if ( player.availableRes != undefined ) {
399
+ if ( jQuery('#video_'+id).hasClass('vjs-fullscreen') ) {
400
+ var resolutions = player.availableRes;
401
+ var highest_res = Object.keys(resolutions)[Object.keys(resolutions).length - 1];
402
+ player.changeRes(highest_res);
403
+ }
404
+ else { kgvid_resize_video(id); }
405
}
406
407
if ( fullScreenApi.supportsFullScreen == false ) {
417
418
});
419
420
if ( video_vars.autoplay == "true" && player.paused() ) { player.play(); }
421
422
} //end if Video.js
423
424
if ( video_vars.player_type == "WordPressDefault" ) {
425
426
+ var player = jQuery('#video_'+id+'_div video');
427
+ var mejs_id = jQuery('#video_'+id+'_div .mejs-container').attr('id');
428
429
player.on('loadedmetadata', function() {
430
+
431
+ var mejs_player = eval('mejs.players.'+mejs_id);
432
+ var resolutions = player.availableRes;
433
+ var played = jQuery('#video_'+id+'_div').data("played") || "not played";
434
+
435
if ( video_vars.set_volume != "" ) { player[0].volume = video_vars.set_volume; }
436
if ( video_vars.mute == "true" ) { player[0].setMuted(true); }
437
jQuery('#video_'+id+'_div .mejs-container').append(jQuery('#video_'+id+'_watermark'));
438
439
+ if ( played == "not played" ) { //only turn on the default captions on first load
440
+
441
+
442
+ jQuery.each(mejs_player.tracks, function(key, item) {
443
+ if ( item.srclang == jQuery('#'+mejs_id+' track[default]').attr('srclang') ) {
444
+ mejs_player.setTrack(item.srclang);
445
+ jQuery('#'+mejs_id+' .mejs-captions-selector input[value="en"]').prop('checked',true);
446
+ }
447
+ });
448
+
449
+ }
450
+
451
});
452
453
player.on('play', function(){
454
+ kgvid_add_hover(id);
455
+ jQuery('#video_'+id+'_meta').removeClass('kgvid_video_meta_hover');
456
+
457
kgvid_video_counter(id, 'play');
458
+
459
+ player.on('timeupdate', function(){
460
+
461
+ var percent_duration = Math.round(player[0].currentTime / player[0].duration * 100);
462
+
463
+ if ( jQuery('#video_'+id+'_div').data("25") == undefined && percent_duration >= 25 && percent_duration < 50 ) {
464
+ jQuery('#video_'+id+'_div').data("25", true);
465
+ kgvid_video_counter(id, '25');
466
+ }
467
+ else if ( jQuery('#video_'+id+'_div').data("50") == undefined && percent_duration >= 50 && percent_duration < 75 ) {
468
+ jQuery('#video_'+id+'_div').data("50", true);
469
+ kgvid_video_counter(id, '50');
470
+ }
471
+ else if ( jQuery('#video_'+id+'_div').data("75") == undefined && percent_duration >= 75 && percent_duration < 100 ) {
472
+ jQuery('#video_'+id+'_div').data("75", true);
473
+ kgvid_video_counter(id, '75');
474
+ }
475
+
476
+ });
477
+
478
+ });
479
+
480
+ player.on('pause', function(){
481
+ jQuery('#video_'+id+'_meta').addClass('kgvid_video_meta_hover');
482
+ });
483
+
484
+ jQuery(document).on('mozfullscreenchange webkitfullscreenchange fullscreenchange', function(){
485
+
486
+ var mejs_player = eval('mejs.players.'+mejs_id);
487
+
488
+ if ( mejs_player.isFullScreen && mejs_player.hasOwnProperty('availableRes') ) {
489
+ var resolutions = mejs_player.availableRes;
490
+
491
+ var resNumbers = new Array();
492
+ jQuery.each(resolutions, function(key, value){
493
+ if ( typeof key !== 'undefined' && !isNaN(parseInt(key)) ) {
494
+ resNumbers.push(parseInt(key));
495
+ }
496
+ });
497
+ var highest_res = Math.max.apply( Math, resNumbers );
498
+
499
+ mejs_player.changeRes(highest_res+'p');
500
+
501
+ }
502
});
503
504
player.on('ended', function(){
525
} //end if WordPress Default
526
527
if ( video_vars.player_type == "JWPlayer" ) {
528
+ var player_id = jQuery('#video_'+id+'_div').children('div[id^="jwplayer"]').attr('id');
529
+ player_id = player_id.replace('_wrapper', ''); //Flash JW Players have wrapper in the id
530
var player = jwplayer(player_id);
531
532
if ( video_vars.set_volume != "" ) { player.setVolume(Math.round(video_vars.set_volume*100)); }
536
kgvid_video_counter(id, 'play');
537
538
if ( video_vars.meta ) {
539
+ kgvid_add_hover(id);
540
jQuery('#video_'+id+'_meta').removeClass('kgvid_video_meta_hover');
541
}
542
543
+ player.on('timeupdate', function(){
544
+
545
+ if ( jQuery('#video_'+id+'_div').data("25") == undefined && Math.round(player.currentTime() / player.duration() * 100) == 25 ) {
546
+ jQuery('#video_'+id+'_div').data("25", true);
547
+ kgvid_video_counter(id, '25');
548
+ }
549
+ else if ( jQuery('#video_'+id+'_div').data("50") == undefined && Math.round(player.currentTime() / player.duration() * 100) == 50 ) {
550
+ jQuery('#video_'+id+'_div').data("50", true);
551
+ kgvid_video_counter(id, '50');
552
+ }
553
+ else if ( jQuery('#video_'+id+'_div').data("75") == undefined && Math.round(player.currentTime() / player.duration() * 100) == 75 ) {
554
+ jQuery('#video_'+id+'_div').data("75", true);
555
+ kgvid_video_counter(id, '75');
556
+
557
+ }
558
+
559
+ });
560
+
561
});
562
563
player.onComplete( function() {
581
kgvid_resize_video(id);
582
jQuery(window).resize( function(){ kgvid_resize_video(id) } );
583
}
584
+
585
}
586
587
function kgvid_resize_video(id) {
597
var set_height = video_vars.height;
598
var aspect_ratio = Math.round(set_height/set_width*1000)/1000
599
var reference_div = jQuery('#kgvid_'+id+'_wrapper').parent();
600
+ if ( reference_div.is('body') ) { parent_width = window.innerWidth; set_width = window.innerWidth; }
601
else if ( reference_div.attr('id') == 'kgvid_popup_video_holder_'+id ) { //if it's a pop-up video
602
var window_width = jQuery(window).width();
603
var window_height = jQuery(window).height();
619
set_width = Math.round(set_height / aspect_ratio);
620
}
621
622
+ if ( ( video_vars.player_type == "Video.js" && eval('videojs.getPlayers()["video_'+id+'"]') != null ) ) {
623
+
624
+ video_vars.player_type == "Video.js"
625
+
626
var player = videojs('video_'+id);
627
player.width(set_width).height(set_height);
628
640
}
641
}
642
else { jQuery('#kgvid_'+id+'_wrapper .vjs-big-play-button').removeAttr('style'); }
643
}
644
+
645
+ if ( video_vars.player_type == "StrobeMediaPlayback" ) {
646
jQuery('#video_'+id+'_div').height(set_height);
647
jQuery('#video_'+id).attr('width',set_width).attr('height',set_height);
648
jQuery('#video_'+id+'_html5_api').attr('width',set_width).attr('height',set_height);
649
}
650
+
651
if ( video_vars.player_type == "WordPressDefault" ) {
652
jQuery('#kgvid_'+id+'_wrapper').find('.wp-video').attr('style', 'width:'+set_width+'px; height:'+set_height+'px;');
653
+ if ( typeof mejs !== 'undefined' ) { player = eval('mejs.players.'+jQuery('#kgvid_'+id+'_wrapper div.wp-video-shortcode').attr('id')); }
654
+ }
655
+
656
+ if ( ( video_vars.player_type == "Video.js" && eval('videojs.getPlayers()["video_'+id+'"]') != null )
657
+ || ( video_vars.player_type == "WordPressDefault" && typeof mejs !== 'undefined' )
658
+ ) {
659
+ if ( player.availableRes !== undefined ) {
660
+
661
+ var resolutions = player.availableRes;
662
+
663
+ if ( video_vars.auto_res == 'automatic' ) {
664
+
665
+ var resNumbers = new Array();
666
+ jQuery.each(resolutions, function(key, value){
667
+ if ( typeof key !== 'undefined' && !isNaN(parseInt(key)) ) {
668
+ resNumbers.push(parseInt(key));
669
+ }
670
+ });
671
+ var current_resolution = parseInt(player.getCurrentRes());
672
+ if ( !isNaN(current_resolution) ) {
673
+ if ( video_vars.pixel_ratio == "true" && window.devicePixelRatio != undefined ) { var pixel_height = set_height * window.devicePixelRatio; } //for retina displays
674
+ else { pixel_height = set_height; }
675
+ var res_options = jQuery.map(resNumbers, function(n) {
676
+ if ( n >= pixel_height ) { return n; }
677
+ });
678
+ var set_res = Math.min.apply(Math,res_options);
679
+
680
+ if ( set_res != current_resolution && !jQuery('#video_'+id).hasClass('vjs-fullscreen') && !jQuery('#video_'+id+'_div .mejs-container').hasClass('mejs-container-fullscreen') ) {
681
+ player.changeRes(set_res+'p');
682
+
683
+ }
684
+
685
+ if ( video_vars.player_type == "Video.js" && jQuery('#video_'+id).hasClass('vjs-has-started') == false ) {
686
+ if ( player.muted() == true ) { player.muted(false); player.muted(true); } // reset volume and mute otherwise player doesn't display properly
687
+ if ( player.volume() != 1 ) {
688
+ var current_volume = player.volume();
689
+ player.volume(1);
690
+ player.volume(current_volume);
691
+ }
692
+ }
693
+ }
694
+ } //automatic
695
+ }
696
}
697
698
var meta = jQuery('#kgvid_video_gallery_thumb_'+id).data('meta');
781
else if (typeof _gaq != "undefined") { _gaq.push(["_trackEvent", "Videos", kgvidL10n_frontend.playstart, title]); }
782
783
}
784
+
785
+ if ( !isNaN(event) ) {
786
+
787
+ if (typeof ga != "undefined") { ga("send", "event", "Videos", event+"%", title); }
788
+ else if (typeof _gaq != "undefined") { _gaq.push(["_trackEvent", "Videos", event+"%", title]); }
789
+
790
+ }
791
+
792
if ( event == "end" ) {
793
if (video_vars.countable) { //video is in the db
794
changed = true;
837
}, "json");
838
839
}
840
+
841
+ function kgvid_share_icon_click(id) {
842
+
843
+ var player_element;
844
+ var event;
845
+
846
+ if ( jQuery('#kgvid_'+id+'_shareicon').hasClass('dashicons-share') ) {
847
+ event = 'turn on';
848
+ jQuery('#kgvid_'+id+'_shareicon').removeClass('dashicons-share').addClass('dashicons-no');
849
+ }
850
+ else {
851
+ event = 'turn off';
852
+ jQuery('#kgvid_'+id+'_shareicon').removeClass('dashicons-no').addClass('dashicons-share');
853
+ }
854
+
855
+ var video_vars = jQuery('#video_'+id+'_div').data('kgvid_video_vars');
856
+
857
+ if ( video_vars.player_type == "Video.js" ) {
858
+
859
+ videojs('video_'+id).pause();
860
+
861
+ if ( jQuery('#video_'+id).hasClass('vjs-has-started') ) {
862
+ player_element = ' .vjs-control-bar';
863
+ }
864
+ else { //hasn't started playing yet
865
+ player_element = ' .vjs-big-play-button';
866
+ }
867
+
868
+ if ( jQuery('#video_'+id+'_div'+player_element).attr('style') == undefined ) {
869
+ jQuery('#video_'+id+'_div'+player_element).hide();
870
+ }
871
+ else {
872
+ jQuery('#video_'+id+'_div'+player_element).removeAttr('style');
873
+ }
874
+
875
+ }// if Video.js player
876
+ else if ( video_vars.player_type == "WordPressDefault" ) {
877
+
878
+ jQuery('#video_'+id+'_div video')[0].pause();
879
+ jQuery('#video_'+id+'_div .mejs-overlay-button').toggle();
880
+
881
+ }//if WordPress Default player
882
+ else if ( video_vars.player_type == "JWPlayer" ) {
883
+ var player_id = jQuery('#video_'+id+'_div').children('div[id^="jwplayer"]').attr('id');
884
+ player_id = player_id.replace('_wrapper', ''); //Flash JW Players have wrapper in the id
885
+ var player = jwplayer(player_id);
886
+ player.pause(true);
887
+ }
888
+
889
+ if ( event == 'turn on' ) { jQuery('#video_'+id+'_div').off('mouseenter mouseleave focus focusout').addClass('kgvid_video_meta_hover'); }
890
+ else { kgvid_add_hover(id); }
891
+
892
+ jQuery('#video_'+id+'_embed, #click_trap_'+id).slideToggle();
893
+
894
+ }
js/kgvid_video_plugin_admin.js CHANGED
@@ -122,6 +122,10 @@ function kgvid_thumb_video_loaded(postID) { //sets up mini custom player for mak
122
}
123
}
124
125
video.removeAttribute("controls");
126
video.muted=true;
127
@@ -199,6 +203,27 @@ function kgvid_thumb_video_loaded(postID) { //sets up mini custom player for mak
199
}
200
}
201
202
function kgvid_reveal_thumb_video(postID) {
203
jQuery('#show-thumb-video-'+postID+' :first').toggleClass( 'kgvid-down-arrow kgvid-right-arrow' );
204
var text = jQuery('#show-thumb-video-'+postID+' :nth-child(2)');
@@ -305,7 +330,7 @@ function kgvid_generate_thumb(postID, buttonPushed) {
305
else { document.getElementById(widthID).value = document.getElementsByName(maxwidthID)[0].value; }
306
document.getElementById(heightID).value = Math.round(kgvid_aspect*parseInt(document.getElementById(widthID).value));
307
308
- kgvid_redraw_encode_checkboxes(attachmentURL, postID, page);
309
310
}, "json");
311
@@ -343,11 +368,7 @@ function kgvid_generate_thumb(postID, buttonPushed) {
343
344
jQuery(thumbnailboxID).append('<div style="display:none;" class="kgvid_thumbnail_select" name="attachments['+postID+'][thumb'+time_id+']" id="attachments-'+postID+'-thumb'+time_id+'"><label for="kgflashmedia-'+postID+'-thumbradio'+time_id+'"><canvas class="kgvid_thumbnail" style="width:200px;height:'+Math.round(200*video_aspect)+'px;" id="'+postID+'_thumb_'+time_id+'"></canvas></label><br /><input type="radio" name="attachments['+postID+'][thumbradio'+time_id+']" id="kgflashmedia-'+postID+'-thumbradio'+time_id+'" value="'+video.currentTime+'" onchange="document.getElementById(\'attachments-'+postID+'-kgflashmediaplayer-thumbtime\').value = \''+time_display+'\'; document.getElementById(\'attachments-'+postID+'-kgflashmediaplayer-numberofthumbs\').value =\'1\';kgvid_save_canvas_thumb(\''+postID+'\', \''+time_id+'\', 1, 1);"></div>');
345
var canvas = document.getElementById(postID+'_thumb_'+time_id);
346
- canvas.width = video_width;
347
- canvas.height = video_height;
348
- var context = canvas.getContext('2d');
349
- context.fillRect(0, 0, video_width, video_height);
350
- context.drawImage(video, 0, 0, video_width, video_height);
351
jQuery('#attachments-'+postID+'-thumb'+time_id).animate({opacity: 'toggle', height: 'toggle', width: 'toggle'}, 1000);
352
353
thumbnail_saved.splice(0,1);
@@ -400,11 +421,43 @@ function kgvid_generate_thumb(postID, buttonPushed) {
400
}
401
}
402
403
- function kgvid_select_thumbnail(thumb_url, post_id, movieoffset) {
404
jQuery('[name="attachments['+post_id+'][kgflashmediaplayer-poster]"]').val(thumb_url); //get this by name because it's the same before WP v3.5
405
var time_display = kgvid_convert_to_timecode(movieoffset);
406
jQuery('#attachments-'+post_id+'-kgflashmediaplayer-thumbtime').val(time_display);
407
jQuery('#attachments-'+post_id+'-kgflashmediaplayer-numberofthumbs').val('1');
408
}
409
410
function kgvid_save_canvas_thumb(postID, time_id, total, index) {
@@ -413,7 +466,7 @@ function kgvid_save_canvas_thumb(postID, time_id, total, index) {
413
414
var video_url = document.getElementsByName('attachments['+postID+'][kgflashmediaplayer-url]')[0].value;
415
var canvas = document.getElementById(postID+'_thumb_'+time_id);
416
- var png64dataURL = canvas.toDataURL(); //this is what saves the image. Do this after selection.
417
418
jQuery('#attachments-'+postID+'-thumbnailplaceholder canvas').fadeTo(500, .25);
419
jQuery('#attachments-'+postID+'-thumbnailplaceholder input').attr('disabled', true);
@@ -422,17 +475,29 @@ function kgvid_save_canvas_thumb(postID, time_id, total, index) {
422
jQuery.ajax({
423
type: "POST",
424
url: ajaxurl,
425
- data: { action:"kgvid_save_html5_thumb", security: kgflashmediaplayersecurity, raw_png: png64dataURL, url: video_url, offset: time_id, postID: postID, total: total, index: index }
426
})
427
.done( function(thumb_url) {
428
if ( total == 1 ) {
429
document.getElementsByName('attachments['+postID+'][kgflashmediaplayer-autothumb-error]')[0].value = '';
430
jQuery('#attachments-'+postID+'-kgflashmediaplayer-poster').val(thumb_url).change();
431
- if ( pagenow == 'attachment' ) { jQuery('#publish').click(); }
432
}
433
else {
434
kgvid_thumbnail_saveall_progress(postID, total);
435
}
436
})
437
.fail( function(xhr, textStatus, errorThrown) {
438
document.getElementsByName('attachments['+postID+'][kgflashmediaplayer-autothumb-error]')[0].value = errorThrown;
@@ -451,8 +516,8 @@ function kgvid_thumbnail_saveall_progress(postID, total) {
451
452
if ( number == total ) {
453
jQuery('#saveallthumbs-'+postID+'-div').slideUp(1000);
454
- jQuery('#attachments-'+postID+'-thumbnailplaceholder .kgvid_save_overlay').fadeOut();
455
- jQuery('#attachments-'+postID+'-kgflashmediaplayer-thumbnailboxoverlay').fadeTo(500, 1);
456
jQuery('#attachments-'+postID+'-thumbnailplaceholder input').removeAttr('disabled');
457
}
458
@@ -510,23 +575,21 @@ function kgvid_thumb_video_manual(postID) {
510
document.getElementById('attachments-'+postID+'-kgflashmediaplayer-thumbtime').value = time_display;
511
jQuery("#attachments-"+postID+"-thumbnailplaceholder").html('<div class="kgvid_thumbnail_box kgvid_chosen_thumbnail_box"><canvas style="height:'+Math.round(200*video_aspect)+'px;" id="'+postID+'_thumb_'+time_id+'"></canvas></div>');
512
var canvas = document.getElementById(postID+'_thumb_'+time_id);
513
- canvas.width = video.videoWidth;
514
- canvas.height = video.videoHeight;
515
- var context = canvas.getContext('2d');
516
- context.fillRect(0, 0, video.videoWidth, video.videoHeight);
517
- context.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);
518
kgvid_save_canvas_thumb(postID, time_id, 1, 1);
519
520
}
521
522
- function kgvid_enqueue_video_encode(postID) {
523
524
- var kgflashmediaplayersecurity = document.getElementsByName('attachments['+postID+'][kgflashmediaplayer-security]')[0].value;
525
- var attachmentURL = document.getElementsByName('attachments['+postID+'][kgflashmediaplayer-url]')[0].value;
526
var parent_post_id = jQuery('#post_ID').val();
527
if ( parent_post_id == undefined ) { parent_post_id = jQuery('#post_ID', window.parent.document).val(); }
528
- var encodeplaceholderid = "#attachments-"+postID+"-encodeplaceholder";
529
- var encodeprogressplaceholderid = "#attachments-"+postID+"-encodeprogressplaceholder";
530
531
var page = "attachment";
532
var document_url = document.URL;
@@ -540,8 +603,8 @@ function kgvid_enqueue_video_encode(postID) {
540
var kgvid_encode = new Object();
541
jQuery.each(formats, function(key,formats) {
542
kgvid_encode[formats] = "";
543
- if ( jQuery('#attachments-'+postID+'-kgflashmediaplayer-encode'+formats).length > 0) {
544
- kgvid_encode[formats] = document.getElementById('attachments-'+postID+'-kgflashmediaplayer-encode'+formats).checked;
545
}
546
});
547
JSON.stringify(kgvid_encode);
@@ -550,7 +613,7 @@ function kgvid_enqueue_video_encode(postID) {
550
jQuery(encodeprogressplaceholderid).empty();
551
jQuery(encodeplaceholderid).append('<strong>'+kgvidL10n.loading+'</strong>');
552
553
- jQuery.post(ajaxurl, { action:"kgvid_callffmpeg", security: kgflashmediaplayersecurity, movieurl: attachmentURL, ffmpeg_action: 'enqueue', encodeformats: kgvid_encode, attachmentID: postID, parent_id: parent_post_id }, function(data) {
554
555
jQuery(encodeplaceholderid).empty();
556
jQuery(encodeprogressplaceholderid).empty();
@@ -560,8 +623,8 @@ function kgvid_enqueue_video_encode(postID) {
560
jQuery(encodeplaceholderid).append(data.embed_display);
561
562
setTimeout(function(){
563
- jQuery('#attachments-'+postID+'-kgflashmediaplayer-encodeboxes').css('opacity', '0.5');
564
- kgvid_redraw_encode_checkboxes(attachmentURL, postID, page);
565
}, 2000);
566
}, "json");
567
@@ -636,7 +699,7 @@ function kgvid_set_singleurl() {
636
url = data.movieurl;
637
kgvid_change_singleurl(url, basename, oldbasename);
638
jQuery('#attachments-'+basename+'-kgflashmediaplayer-encodeboxes').css('opacity', '0.5');
639
- kgvid_redraw_encode_checkboxes(url, basename, 'attachment');
640
}, "json");
641
break;
642
}
@@ -713,16 +776,46 @@ function kgvid_rescan_external_server(movieurl, postID) {
713
jQuery('#attachments-'+postID+'-kgflashmediaplayer-rescanplaceholder').append('<strong>Scanning...</strong>');
714
jQuery.post(ajaxurl, { action:"kgvid_rescan_external_server", security: kgflashmediaplayersecurity, movieurl:movieurl, postID:postID }, function() {
715
jQuery('#attachments-'+postID+'-kgflashmediaplayer-encodeboxes').css('opacity', '0.5');
716
- kgvid_redraw_encode_checkboxes(movieurl, postID, 'queue');
717
jQuery('#attachments-'+postID+'-kgflashmediaplayer-rescanplaceholder').empty();
718
});
719
}
720
721
- function kgvid_cancel_encode(kgvid_pid, postID, video_key, format) {
722
723
- var kgflashmediaplayersecurity = document.getElementsByName('attachments['+postID+'][kgflashmediaplayer-security]')[0].value;
724
- jQuery('#attachments-'+postID+'-kgflashmediaplayer-meta'+format).empty();
725
- jQuery('#attachments-'+postID+'-kgflashmediaplayer-meta'+format).append('<strong>Canceling</strong>');
726
jQuery.post(ajaxurl, { action:"kgvid_cancel_encode", security: kgflashmediaplayersecurity, kgvid_pid: kgvid_pid, video_key: video_key, format: format } );
727
728
}
@@ -733,16 +826,18 @@ function kgvid_delete_video(movieurl, postID, format, childID, blogID) {
733
734
if ( delete_for_sure == true ) {
735
736
- jQuery('#attachments-'+postID+'-kgflashmediaplayer-encode'+format).removeAttr('disabled');
737
- jQuery('#attachments-'+postID+'-kgflashmediaplayer-encode').removeAttr('disabled');
738
- jQuery('#attachments-'+postID+'-kgflashmediaplayer-encode').css('display', 'inline');
739
- jQuery('#attachments-'+postID+'-kgflashmediaplayer-meta'+format).empty();
740
- jQuery('#attachments-'+postID+'-kgflashmediaplayer-meta'+format).append('<strong>Deleted</strong>');
741
- var kgflashmediaplayersecurity = document.getElementsByName('attachments['+postID+'][kgflashmediaplayer-security]')[0].value;
742
743
jQuery.post(ajaxurl, { action: "kgvid_delete_video", security: kgflashmediaplayersecurity, movieurl: movieurl, postid: postID, format: format, childid: childID, blogid: blogID }, function(data) {
744
jQuery('#attachments-'+postID+'-kgflashmediaplayer-encode'+format).change();
745
- if ( pagenow == 'settings_page_kgvid_network_video_encoding_queue-network' || pagenow == 'tools_page_kgvid_video_encoding_queue' ) { page = 'queue'; }
746
else { page = 'attachment'; }
747
kgvid_redraw_encode_checkboxes(movieurl, postID, page, blogID);
748
}, "json" );
@@ -769,7 +864,7 @@ function kgvid_cancel_thumbs(postID) {
769
770
function kgvid_update_encode_queue() {
771
772
- if ( pagenow == 'tools_page_kgvid_video_encoding_queue' || pagenow == 'settings_page_kgvid_network_video_encoding_queue-network' ) {
773
var page = 'queue';
774
var kgflashmediaplayersecurity = document.getElementsByName('attachments[kgflashmediaplayer-security]')[0].value;
775
}
@@ -797,84 +892,89 @@ function kgvid_update_encode_queue() {
797
var queued = false;
798
var time_to_wait = 5000;
799
800
- jQuery.each(data.queue, function(video_key, video_entry) {
801
802
- if ( page != "queue" && jQuery('#attachments-'+video_entry.attachmentID+'-kgflashmediaplayer-encodeboxes').length == 0 ) { return true; }
803
804
- if ( video_entry.hasOwnProperty('encode_formats') ) {
805
806
- var currently_encoding = false;
807
808
- jQuery.each(video_entry.encode_formats, function(format, format_entry) {
809
810
- if ( format_entry.status == 'encoding' ) {
811
812
- currently_encoding = true;
813
- check_again = true;
814
815
- if ( page == "queue" ) {
816
817
- if ( jQuery('#clear_'+video_entry.attachmentID).css("display") != "none" ) {
818
- jQuery('#clear_'+video_entry.attachmentID).css("display", "none");
819
- }
820
- if ( !jQuery('#tr_'+video_entry.attachmentID).hasClass('currently_encoding') ) {
821
- jQuery('#tr_'+video_entry.attachmentID).addClass('currently_encoding');
822
- }
823
- if ( jQuery('#tr_'+video_entry.attachmentID).hasClass('kgvid_complete') ) {
824
- jQuery('#tr_'+video_entry.attachmentID).removeClass('kgvid_complete');
825
}
826
827
}
828
829
- }
830
831
- if ( format_entry.status == 'queued' ) {
832
- queued = true;
833
- }
834
835
- if ( format_entry.hasOwnProperty('meta_array') ) {
836
837
- var meta_entry = jQuery('#attachments-'+video_entry.attachmentID+'-kgflashmediaplayer-meta'+format);
838
- var checkbox = jQuery('#attachments-'+video_entry.attachmentID+'-kgflashmediaplayer-encode'+format);
839
840
- if ( format_entry.status == 'encoding') { time_to_wait = format_entry.meta_array.time_to_wait; }
841
842
- if ( meta_entry.html() != undefined && format_entry.meta_array.meta != meta_entry.html() ) {
843
- check_again = true;
844
- meta_entry.empty();
845
- meta_entry.html(format_entry.meta_array.meta);
846
- }
847
848
- if ( format_entry.meta_array.checked != '' ) {
849
- checkbox.attr('checked', true);
850
- }
851
- else if ( format_entry.status == 'Encoding Complete' ) { checkbox.removeAttr('checked'); }
852
853
- if ( format_entry.meta_array.disabled != '' ) {
854
- checkbox.attr('disabled', true);
855
}
856
- else { checkbox.removeAttr('disabled'); }
857
858
- }
859
860
- }); //end loop through encode formats
861
862
- }
863
864
- if ( page == 'queue' && currently_encoding == false ) {
865
866
- if ( queued == false ) { jQuery('#tr_'+video_entry.attachmentID).addClass('kgvid_complete'); }
867
868
- if ( jQuery('#tr_'+video_entry.attachmentID).hasClass('currently_encoding') ) {
869
- jQuery('#tr_'+video_entry.attachmentID).removeClass('currently_encoding');
870
- }
871
- if ( jQuery('#tr_'+video_entry.attachmentID+' #clear_'+video_entry.attachmentID).css("display") != "block" ) {
872
- jQuery('#tr_'+video_entry.attachmentID+' #clear_'+video_entry.attachmentID).css("display", "block");
873
}
874
875
- }
876
877
- }); //end loop through queue
878
879
if ( check_again == true ) {
880
var encode_queue_timeouts = container_element.data('encode_queue_timeouts');
@@ -892,43 +992,46 @@ function kgvid_update_encode_queue() {
892
893
function kgvid_redraw_encode_checkboxes(movieurl, postID, page, blogID) {
894
895
- var kgflashmediaplayersecurity = jQuery('#attachments-'+postID+'-kgflashmediaplayer-security').val();
896
897
if ( kgflashmediaplayersecurity ) { //sometimes this tries to run after the media modal is closed
898
899
var formats = new Array("fullres", "1080", "720", "mobile", "ogg", "webm");
900
var kgvid_encode = new Object();
901
jQuery.each(formats, function(key,formats) {
902
kgvid_encode[formats] = "";
903
- if ( jQuery('#attachments-'+postID+'-kgflashmediaplayer-encode'+formats).length > 0) {
904
- kgvid_encode[formats] = document.getElementById('attachments-'+postID+'-kgflashmediaplayer-encode'+formats).checked;
905
}
906
});
907
JSON.stringify(kgvid_encode);
908
909
- jQuery.post(ajaxurl, { action:"kgvid_generate_encode_checkboxes", security: kgflashmediaplayersecurity, movieurl: movieurl, post_id: postID, page: page, blog_id: blogID, encodeformats: kgvid_encode }, function(data) {
910
- jQuery('#attachments-'+postID+'-kgflashmediaplayer-encodeboxes').empty();
911
- jQuery('#attachments-'+postID+'-kgflashmediaplayer-encodeboxes').append(data.checkboxes);
912
if ( page == "queue" ) {
913
- jQuery('#tr_'+postID+'.currently_encoding').removeClass('currently_encoding');
914
- jQuery('#tr_'+postID+' #clear_'+postID).css("display", "block");
915
if ( data.encoding == true ) {
916
- jQuery('#clear_'+postID).css("display", "none");
917
- jQuery('#tr_'+postID).addClass('currently_encoding');
918
}
919
920
}
921
922
setTimeout( function(){ kgvid_update_encode_queue() }, 3000 ); //start the loop
923
924
- jQuery('#attachments-'+postID+'-kgflashmediaplayer-encodeboxes').removeAttr('style');
925
}, "json" );
926
}
927
}
928
929
function kgvid_redraw_thumbnail_box(postID) {
930
931
- var kgflashmediaplayersecurity = jQuery('#attachments-'+postID+'-kgflashmediaplayer-security').val();
932
933
if ( kgflashmediaplayersecurity ) {
934
@@ -954,26 +1057,25 @@ function kgvid_redraw_thumbnail_box(postID) {
954
}
955
}
956
957
- function kgvid_encode_queue(action, order, id) {
958
959
- var kgflashmediaplayersecurity = document.getElementsByName('attachments[kgflashmediaplayer-security]')[0].value;
960
961
var CheckboxTimeout = jQuery('#wpwrap').data("KGVIDCheckboxTimeout") || null;
962
if ( CheckboxTimeout ) { clearTimeout(CheckboxTimeout); }
963
964
- var scope = 'blog';
965
- if ( pagenow == 'settings_page_kgvid_network_video_encoding_queue-network' ) { scope = 'network' }
966
967
if ( action == "delete" ) {
968
- jQuery('#tr_'+id).fadeTo('slow', 0.5);
969
- jQuery.post(ajaxurl, { action:"kgvid_clear_queue_entry", security: kgflashmediaplayersecurity, index: order, scope: scope }, function(data) {
970
jQuery('table.widefat > tbody').replaceWith("<tbody class='rows'>"+data+"</tbody>");
971
}, "html" );
972
}
973
974
if ( action == "clear_completed" ) {
975
jQuery('tbody > .kgvid_complete').fadeTo('slow', 0.5);
976
- jQuery.post(ajaxurl, { action:"kgvid_clear_completed_queue", security: kgflashmediaplayersecurity, type:"manual", scope: scope }, function(data) {
977
jQuery('table.widefat > tbody').replaceWith("<tbody class='rows'>"+data+"</tbody>");
978
}, "html" );
979
}
@@ -984,7 +1086,20 @@ function kgvid_encode_queue(action, order, id) {
984
985
if ( clear_for_sure == true ) {
986
jQuery('tbody > .kgvid_queued').fadeTo('slow', 0.5);
987
- jQuery.post(ajaxurl, { action:"kgvid_clear_completed_queue", security: kgflashmediaplayersecurity, type:"queued", scope: scope }, function(data) {
988
jQuery('table.widefat > tbody').replaceWith("<tbody class='rows'>"+data+"</tbody>");
989
}, "html" );
990
}
@@ -1115,10 +1230,16 @@ function kgvid_switch_settings_tab(tab) {
1115
jQuery("#general_tab").removeClass("nav-tab-active");
1116
jQuery("#encoding_tab").addClass("nav-tab-active");
1117
1118
- jQuery('h3:eq(0), h3:eq(2)').hide();
1119
jQuery('table:eq(0), table:eq(1), table:eq(2), table:eq(3)').hide();
1120
jQuery(".kgvid_setting_nearvid").hide();
1121
- jQuery('h3:eq(3)').show();
1122
jQuery('table:eq(4)').show();
1123
1124
if ( jQuery('#app_path').data('ffmpeg_exists') == "on" && jQuery('#ffmpeg_output').html() == "" ) {
@@ -1140,10 +1261,17 @@ function kgvid_switch_settings_tab(tab) {
1140
1141
jQuery("#general_tab").addClass("nav-tab-active");
1142
jQuery("#encoding_tab").removeClass("nav-tab-active");
1143
- jQuery('h3:eq(0), h3:eq(2)').show();
1144
jQuery('table:eq(0), table:eq(1), table:eq(3)').show();
1145
jQuery(".kgvid_setting_nearvid").show();
1146
- jQuery('h3:eq(3)').hide();
1147
jQuery('table:eq(4)').hide();
1148
1149
}
@@ -1162,21 +1290,31 @@ function kgvid_hide_plugin_settings() {
1162
1163
if ( playback_option != "Strobe Media Playback" || encoding_tab ) {
1164
jQuery('table:eq(2)').hide();
1165
- jQuery('h3:eq(1)').hide();
1166
}
1167
1168
if ( general_tab ) {
1169
1170
if ( playback_option == "Strobe Media Playback" ) {
1171
jQuery('table:eq(2)').show();
1172
- jQuery('h3:eq(1)').show();
1173
}
1174
1175
if ( playback_option == "WordPress Default" || playback_option == "JW Player" ) {
1176
jQuery('#nativecontrolsfortouch').parents().eq(1).hide();
1177
jQuery('#js_skin').parents().eq(1).hide();
1178
jQuery('#chromecast').parents().eq(1).hide();
1179
- jQuery('#auto_res').parents().eq(1).hide();
1180
}
1181
1182
if ( playback_option == "Video.js" || playback_option == "Strobe Media Playback" ) {
@@ -1184,10 +1322,16 @@ function kgvid_hide_plugin_settings() {
1184
jQuery('#js_skin').parents().eq(1).show();
1185
jQuery('#chromecast').parents().eq(1).show();
1186
jQuery('#auto_res').parents().eq(1).show();
1187
}
1188
1189
if ( playback_option == "JW Player" ) {
1190
jQuery('#endofvideooverlay').parents().eq(1).hide();
1191
jQuery('#jw_player_id_select').fadeIn();
1192
}
1193
else {
@@ -1195,22 +1339,28 @@ function kgvid_hide_plugin_settings() {
1195
jQuery('#jw_player_id_select').fadeOut();
1196
}
1197
1198
- }
1199
-
1200
- if ( encoding_tab ) {
1201
-
1202
- var moov = jQuery('#moov').val();
1203
1204
- if ( moov == 'none' || moov == 'movflag' ) {
1205
- jQuery('#moov_path_p').hide();
1206
}
1207
else {
1208
- jQuery('.kgvid_moov_option').html(moov);
1209
- jQuery('#moov_path_p').show();
1210
}
1211
1212
}
1213
1214
if ( ffmpeg_exists == "notinstalled" ) {
1215
jQuery(".kgvid_video_app_required").addClass("kgvid_thumbnail_overlay");
1216
jQuery(".kgvid_video_app_required").attr('title', kgvidL10n.ffmpegrequired);
@@ -1242,6 +1392,27 @@ function kgvid_hide_ffmpeg_settings() {
1242
1243
}
1244
1245
function kgvid_hide_watermark_url(obj) {
1246
1247
if ( obj.value == 'custom' ) {
@@ -1452,7 +1623,7 @@ function kgvid_pick_attachment(button) {
1452
1453
}
1454
1455
- function kgvid_pick_format(button, parentID, mime, format, movieurl) {
1456
1457
var frame;
1458
@@ -1493,8 +1664,8 @@ function kgvid_pick_format(button, parentID, mime, format, movieurl) {
1493
var video = frame.state().get('selection').first();
1494
var kgflashmediaplayersecurity = document.getElementsByName('attachments['+parentID+'][kgflashmediaplayer-security]')[0].value;
1495
1496
- jQuery.post(ajaxurl, { action:"kgvid_update_child_format", security: kgflashmediaplayersecurity, parent_id: parentID, video_id: video.id, format: format }, function(data) {
1497
- kgvid_redraw_encode_checkboxes(movieurl, parentID, 'attachment');
1498
}, "json");
1499
1500
});
@@ -1509,7 +1680,7 @@ function kgvid_clear_video(movieurl, postID, video_id, blog_id) {
1509
var kgflashmediaplayersecurity = document.getElementsByName('attachments['+postID+'][kgflashmediaplayer-security]')[0].value;
1510
1511
jQuery.post(ajaxurl, { action:"kgvid_clear_child_format", security: kgflashmediaplayersecurity, video_id: video_id, blog_id: blog_id }, function(data) {
1512
- kgvid_redraw_encode_checkboxes(movieurl, postID, 'attachment');
1513
}, "json");
1514
1515
}
122
}
123
}
124
125
+ video.removeAttribute('height'); //disables changes made by mejs
126
+ video.removeAttribute('style');
127
+ video.setAttribute('width', '200');
128
+
129
video.removeAttribute("controls");
130
video.muted=true;
131
203
}
204
}
205
206
+ function kgvid_draw_thumb_canvas(canvas, canvas_source) {
207
+
208
+ if ( canvas_source.nodeName.toLowerCase() === 'video' ) {
209
+ canvas_width = canvas_source.videoWidth;
210
+ canvas_height = canvas_source.videoHeight;
211
+ }
212
+ else {
213
+ canvas_width = canvas_source.width;
214
+ canvas_height = canvas_source.height;
215
+ }
216
+
217
+ canvas.width = canvas_width;
218
+ canvas.height = canvas_height;
219
+ var context = canvas.getContext('2d');
220
+ context.fillRect(0, 0, canvas_width, canvas_height);
221
+ context.drawImage(canvas_source, 0, 0, canvas_width, canvas_height);
222
+
223
+ return canvas;
224
+
225
+ }
226
+
227
function kgvid_reveal_thumb_video(postID) {
228
jQuery('#show-thumb-video-'+postID+' :first').toggleClass( 'kgvid-down-arrow kgvid-right-arrow' );
229
var text = jQuery('#show-thumb-video-'+postID+' :nth-child(2)');
330
else { document.getElementById(widthID).value = document.getElementsByName(maxwidthID)[0].value; }
331
document.getElementById(heightID).value = Math.round(kgvid_aspect*parseInt(document.getElementById(widthID).value));
332
333
+ kgvid_redraw_encode_checkboxes(attachmentURL, postID, page, false);
334
335
}, "json");
336
368
369
jQuery(thumbnailboxID).append('<div style="display:none;" class="kgvid_thumbnail_select" name="attachments['+postID+'][thumb'+time_id+']" id="attachments-'+postID+'-thumb'+time_id+'"><label for="kgflashmedia-'+postID+'-thumbradio'+time_id+'"><canvas class="kgvid_thumbnail" style="width:200px;height:'+Math.round(200*video_aspect)+'px;" id="'+postID+'_thumb_'+time_id+'"></canvas></label><br /><input type="radio" name="attachments['+postID+'][thumbradio'+time_id+']" id="kgflashmedia-'+postID+'-thumbradio'+time_id+'" value="'+video.currentTime+'" onchange="document.getElementById(\'attachments-'+postID+'-kgflashmediaplayer-thumbtime\').value = \''+time_display+'\'; document.getElementById(\'attachments-'+postID+'-kgflashmediaplayer-numberofthumbs\').value =\'1\';kgvid_save_canvas_thumb(\''+postID+'\', \''+time_id+'\', 1, 1);"></div>');
370
var canvas = document.getElementById(postID+'_thumb_'+time_id);
371
+ canvas = kgvid_draw_thumb_canvas(canvas, video);
372
jQuery('#attachments-'+postID+'-thumb'+time_id).animate({opacity: 'toggle', height: 'toggle', width: 'toggle'}, 1000);
373
374
thumbnail_saved.splice(0,1);
421
}
422
}
423
424
+ function kgvid_select_thumbnail(thumb_url, post_id, movieoffset, thumbnail) {
425
+
426
jQuery('[name="attachments['+post_id+'][kgflashmediaplayer-poster]"]').val(thumb_url); //get this by name because it's the same before WP v3.5
427
+
428
+ var unscaledThumb = new Image();
429
+ unscaledThumb.src = thumbnail.src;
430
+ var canvas = document.createElement("canvas");
431
+ canvas = kgvid_draw_thumb_canvas(canvas, unscaledThumb);
432
+ var thumb_url = canvas.toDataURL('image/jpeg', 0.8);
433
+
434
+ kgvid_change_media_library_video_poster(post_id, thumb_url);
435
+
436
+ /* this breaks the media modal
437
+ setTimeout( function() {
438
+ if(wp.media.frame.content.get()!==null){
439
+ wp.media.frame.content.get().collection.props.set({ignore: (+ new Date())});
440
+ }
441
+ else{
442
+ wp.media.frame.library.props.set({ignore: (+ new Date())});
443
+ }
444
+ }, 2000); */
445
+
446
var time_display = kgvid_convert_to_timecode(movieoffset);
447
jQuery('#attachments-'+post_id+'-kgflashmediaplayer-thumbtime').val(time_display);
448
jQuery('#attachments-'+post_id+'-kgflashmediaplayer-numberofthumbs').val('1');
449
+
450
+
451
+ }
452
+
453
+ function kgvid_change_media_library_video_poster(post_id, thumb_url) {
454
+
455
+ if ( jQuery('div[data-id='+post_id+'] .wp-video-shortcode video').length > 0 ) {
456
+ jQuery('div[data-id='+post_id+'] .mejs-poster').css('background-image', 'url("'+thumb_url+'")');
457
+ jQuery('div[data-id='+post_id+'] .mejs-poster img').attr('src', thumb_url);
458
+ jQuery('div[data-id='+post_id+'] .wp-video-shortcode video').attr('poster', thumb_url);
459
+ }
460
+
461
}
462
463
function kgvid_save_canvas_thumb(postID, time_id, total, index) {
466
467
var video_url = document.getElementsByName('attachments['+postID+'][kgflashmediaplayer-url]')[0].value;
468
var canvas = document.getElementById(postID+'_thumb_'+time_id);
469
+ var png64dataURL = canvas.toDataURL('image/jpeg', 0.8); //this is what saves the image. Do this after selection.
470
471
jQuery('#attachments-'+postID+'-thumbnailplaceholder canvas').fadeTo(500, .25);
472
jQuery('#attachments-'+postID+'-thumbnailplaceholder input').attr('disabled', true);
475
jQuery.ajax({
476
type: "POST",
477
url: ajaxurl,
478
+ data: { action:"kgvid_save_html5_thumb", security: kgflashmediaplayersecurity, url: video_url, offset: time_id, postID: postID, total: total, index: index, raw_png: png64dataURL }
479
})
480
.done( function(thumb_url) {
481
if ( total == 1 ) {
482
document.getElementsByName('attachments['+postID+'][kgflashmediaplayer-autothumb-error]')[0].value = '';
483
jQuery('#attachments-'+postID+'-kgflashmediaplayer-poster').val(thumb_url).change();
484
+ if ( typeof pagenow === 'undefined' || pagenow == 'attachment' ) { jQuery('#publish').click(); }
485
+ kgvid_change_media_library_video_poster(postID, png64dataURL);
486
}
487
else {
488
kgvid_thumbnail_saveall_progress(postID, total);
489
}
490
+
491
+ /* this breaks the media modal
492
+ setTimeout( function() {
493
+ if(wp.media.frame.content.get()!==null){
494
+ wp.media.frame.content.get().collection.props.set({ignore: (+ new Date())});
495
+ }
496
+ else{
497
+ wp.media.frame.library.props.set({ignore: (+ new Date())});
498
+ }
499
+ }, 2000); */
500
+
501
})
502
.fail( function(xhr, textStatus, errorThrown) {
503
document.getElementsByName('attachments['+postID+'][kgflashmediaplayer-autothumb-error]')[0].value = errorThrown;
516
517
if ( number == total ) {
518
jQuery('#saveallthumbs-'+postID+'-div').slideUp(1000);
519
+ jQuery('#attachments-'+postID+'-thumbnailplaceholder .kgvid_save_overlay').fadeOut("normal", function(){ jQuery(this).remove(); });
520
+ jQuery('#attachments-'+postID+'-kgflashmediaplayer-thumbnailboxoverlay, #attachments-'+postID+'-thumbnailplaceholder canvas').fadeTo(500, 1);
521
jQuery('#attachments-'+postID+'-thumbnailplaceholder input').removeAttr('disabled');
522
}
523
575
document.getElementById('attachments-'+postID+'-kgflashmediaplayer-thumbtime').value = time_display;
576
jQuery("#attachments-"+postID+"-thumbnailplaceholder").html('<div class="kgvid_thumbnail_box kgvid_chosen_thumbnail_box"><canvas style="height:'+Math.round(200*video_aspect)+'px;" id="'+postID+'_thumb_'+time_id+'"></canvas></div>');
577
var canvas = document.getElementById(postID+'_thumb_'+time_id);
578
+ canvas = kgvid_draw_thumb_canvas(canvas, video);
579
kgvid_save_canvas_thumb(postID, time_id, 1, 1);
580
581
}
582
583
+ function kgvid_enqueue_video_encode(postID, blogID) {
584
585
+ var blog = kgvid_get_multisite_data(blogID);
586
+
587
+ var kgflashmediaplayersecurity = document.getElementsByName('attachments'+blog.name_text+'['+postID+'][kgflashmediaplayer-security]')[0].value;
588
+ var attachmentURL = document.getElementsByName('attachments'+blog.name_text+'['+postID+'][kgflashmediaplayer-url]')[0].value;
589
var parent_post_id = jQuery('#post_ID').val();
590
if ( parent_post_id == undefined ) { parent_post_id = jQuery('#post_ID', window.parent.document).val(); }
591
+ var encodeplaceholderid = "#attachments-"+blog.id_text+postID+"-encodeplaceholder";
592
+ var encodeprogressplaceholderid = "#attachments-"+blog.id_text+postID+"-encodeprogressplaceholder";
593
594
var page = "attachment";
595
var document_url = document.URL;
603
var kgvid_encode = new Object();
604
jQuery.each(formats, function(key,formats) {
605
kgvid_encode[formats] = "";
606
+ if ( jQuery('#attachments-'+blog.id_text+postID+'-kgflashmediaplayer-encode'+formats).length > 0) {
607
+ kgvid_encode[formats] = document.getElementById('attachments-'+blog.id_text+postID+'-kgflashmediaplayer-encode'+formats).checked;
608
}
609
});
610
JSON.stringify(kgvid_encode);
613
jQuery(encodeprogressplaceholderid).empty();
614
jQuery(encodeplaceholderid).append('<strong>'+kgvidL10n.loading+'</strong>');
615
616
+ jQuery.post(ajaxurl, { action:"kgvid_callffmpeg", security: kgflashmediaplayersecurity, movieurl: attachmentURL, ffmpeg_action: 'enqueue', encodeformats: kgvid_encode, attachmentID: postID, parent_id: parent_post_id, blog_id: blogID }, function(data) {
617
618
jQuery(encodeplaceholderid).empty();
619
jQuery(encodeprogressplaceholderid).empty();
623
jQuery(encodeplaceholderid).append(data.embed_display);
624
625
setTimeout(function(){
626
+ jQuery('#attachments-'+blog.id_text+postID+'-kgflashmediaplayer-encodeboxes').css('opacity', '0.5');
627
+ kgvid_redraw_encode_checkboxes(attachmentURL, postID, page, blogID);
628
}, 2000);
629
}, "json");
630
699
url = data.movieurl;
700
kgvid_change_singleurl(url, basename, oldbasename);
701
jQuery('#attachments-'+basename+'-kgflashmediaplayer-encodeboxes').css('opacity', '0.5');
702
+ kgvid_redraw_encode_checkboxes(url, basename, 'attachment', false);
703
}, "json");
704
break;
705
}
776
jQuery('#attachments-'+postID+'-kgflashmediaplayer-rescanplaceholder').append('<strong>Scanning...</strong>');
777
jQuery.post(ajaxurl, { action:"kgvid_rescan_external_server", security: kgflashmediaplayersecurity, movieurl:movieurl, postID:postID }, function() {
778
jQuery('#attachments-'+postID+'-kgflashmediaplayer-encodeboxes').css('opacity', '0.5');
779
+ kgvid_redraw_encode_checkboxes(movieurl, postID, 'queue', false);
780
jQuery('#attachments-'+postID+'-kgflashmediaplayer-rescanplaceholder').empty();
781
});
782
}
783
784
785
+ function kgvid_get_multisite_data(blogID) {
786
+
787
+ var blog = {};
788
+
789
+ if ( typeof pagenow !== 'undefined' && pagenow == 'settings_page_kgvid_network_video_encoding_queue-network' ) {
790
+ blog.scope = 'network';
791
+ blog.name_text = '['+blogID+']';
792
+ blog.id_text = blogID+'-';
793
+ blog.ID = blogID;
794
+ }
795
+ else if ( typeof pagenow !== 'undefined' && pagenow == 'tools_page_kgvid_video_encoding_queue' && !isNaN(parseInt(blogID)) ) {
796
+ blog.scope = 'site';
797
+ blog.name_text = '['+blogID+']';
798
+ blog.id_text = blogID+'-';
799
+ blog.ID = blogID;
800
+ }
801
+ else {
802
+ blog.scope = 'site';
803
+ blog.name_text = '';
804
+ blog.id_text = '';
805
+ blog.ID = false;
806
+ }
807
+
808
+ return blog;
809
+
810
+ }
811
+
812
+ function kgvid_cancel_encode(kgvid_pid, postID, video_key, format, blogID) {
813
+
814
+ var blog = kgvid_get_multisite_data(blogID);
815
+
816
+ var kgflashmediaplayersecurity = document.getElementsByName('attachments'+blog.name_text+'['+postID+'][kgflashmediaplayer-security]')[0].value;
817
+ jQuery('#attachments-'+blog.id_text+postID+'-kgflashmediaplayer-meta'+format).empty();
818
+ jQuery('#attachments-'+blog.id_text+postID+'-kgflashmediaplayer-meta'+format).append('<strong>Canceling</strong>');
819
jQuery.post(ajaxurl, { action:"kgvid_cancel_encode", security: kgflashmediaplayersecurity, kgvid_pid: kgvid_pid, video_key: video_key, format: format } );
820
821
}
826
827
if ( delete_for_sure == true ) {
828
829
+ var blog = kgvid_get_multisite_data(blogID);
830
+
831
+ jQuery('#attachments-'+blog.id_text+postID+'-kgflashmediaplayer-encode'+format).removeAttr('disabled');
832
+ jQuery('#attachments-'+blog.id_text+postID+'-kgflashmediaplayer-encode').removeAttr('disabled');
833
+ jQuery('#attachments-'+blog.id_text+postID+'-kgflashmediaplayer-encode').css('display', 'inline');
834
+ jQuery('#attachments-'+blog.id_text+postID+'-kgflashmediaplayer-meta'+format).empty();
835
+ jQuery('#attachments-'+blog.id_text+postID+'-kgflashmediaplayer-meta'+format).append('<strong>Deleted</strong>');
836
+ var kgflashmediaplayersecurity = document.getElementsByName('attachments'+blog.name_text+'['+postID+'][kgflashmediaplayer-security]')[0].value;
837
838
jQuery.post(ajaxurl, { action: "kgvid_delete_video", security: kgflashmediaplayersecurity, movieurl: movieurl, postid: postID, format: format, childid: childID, blogid: blogID }, function(data) {
839
jQuery('#attachments-'+postID+'-kgflashmediaplayer-encode'+format).change();
840
+ if ( typeof pagenow !== 'undefined' && ( pagenow == 'settings_page_kgvid_network_video_encoding_queue-network' || pagenow == 'tools_page_kgvid_video_encoding_queue' ) ) { page = 'queue'; }
841
else { page = 'attachment'; }
842
kgvid_redraw_encode_checkboxes(movieurl, postID, page, blogID);
843
}, "json" );
864
865
function kgvid_update_encode_queue() {
866
867
+ if ( typeof pagenow !== 'undefined' && ( pagenow == 'tools_page_kgvid_video_encoding_queue' || pagenow == 'settings_page_kgvid_network_video_encoding_queue-network' ) ) {
868
var page = 'queue';
869
var kgflashmediaplayersecurity = document.getElementsByName('attachments[kgflashmediaplayer-security]')[0].value;
870
}
892
var queued = false;
893
var time_to_wait = 5000;
894
895
+ if ( data.queue.length !== 0 && data.queue.length !== undefined ) {
896
+ jQuery.each(data.queue, function(video_key, video_entry) {
897
898
+ var blog = kgvid_get_multisite_data(video_entry.blog_id);
899
900
+ if ( page != "queue" && jQuery('#attachments-'+blog.id_text+video_entry.attachmentID+'-kgflashmediaplayer-encodeboxes').length == 0 ) { return true; }
901
902
+ if ( video_entry.hasOwnProperty('encode_formats') ) {
903
904
+ var currently_encoding = false;
905
906
+ jQuery.each(video_entry.encode_formats, function(format, format_entry) {
907
908
+ if ( format_entry.status == 'encoding' ) {
909
910
+ currently_encoding = true;
911
+ check_again = true;
912
+
913
+ if ( page == "queue" ) {
914
+
915
+ if ( jQuery('#clear-'+blog.id_text+video_entry.attachmentID).css("display") != "none" ) {
916
+ jQuery('#clear-'+blog.id_text+video_entry.attachmentID).css("display", "none");
917
+ }
918
+ if ( !jQuery('#tr-'+blog.id_text+video_entry.attachmentID).hasClass('currently_encoding') ) {
919
+ jQuery('#tr-'+blog.id_text+video_entry.attachmentID).addClass('currently_encoding');
920
+ }
921
+ if ( jQuery('#tr-'+blog.id_text+video_entry.attachmentID).hasClass('kgvid_complete') ) {
922
+ jQuery('#tr-'+blog.id_text+video_entry.attachmentID).removeClass('kgvid_complete');
923
+ }
924
925
}
926
927
}
928
929
+ if ( format_entry.status == 'queued' ) {
930
+ queued = true;
931
+ }
932
933
+ if ( format_entry.hasOwnProperty('meta_array') ) {
934
935
+ var meta_entry = jQuery('#attachments-'+blog.id_text+video_entry.attachmentID+'-kgflashmediaplayer-meta'+format);
936
+ var checkbox = jQuery('#attachments-'+blog.id_text+video_entry.attachmentID+'-kgflashmediaplayer-encode'+format);
937
938
+ if ( format_entry.status == 'encoding') { time_to_wait = format_entry.meta_array.time_to_wait; }
939
940
+ if ( meta_entry.html() != undefined && format_entry.meta_array.meta != meta_entry.html() ) {
941
+ check_again = true;
942
+ meta_entry.empty();
943
+ meta_entry.html(format_entry.meta_array.meta);
944
+ }
945
946
+ if ( format_entry.meta_array.checked != '' ) {
947
+ checkbox.attr('checked', true);
948
+ }
949
+ else if ( format_entry.status == 'Encoding Complete' ) { checkbox.removeAttr('checked'); }
950
951
+ if ( format_entry.meta_array.disabled != '' ) {
952
+ checkbox.attr('disabled', true);
953
+ }
954
+ else { checkbox.removeAttr('disabled'); }
955
956
}
957
958
+ }); //end loop through encode formats
959
960
+ }
961
962
+ if ( page == 'queue' && currently_encoding == false ) {
963
964
+ if ( queued == false ) { jQuery('#tr-'+blog.id_text+video_entry.attachmentID).addClass('kgvid_complete'); }
965
966
+ if ( jQuery('#tr-'+blog.id_text+video_entry.attachmentID).hasClass('currently_encoding') ) {
967
+ jQuery('#tr-'+blog.id_text+video_entry.attachmentID).removeClass('currently_encoding');
968
+ }
969
+ if ( jQuery('#tr-'+blog.id_text+video_entry.attachmentID+' #clear-'+blog.id_text+video_entry.attachmentID).css("display") != "block" ) {
970
+ jQuery('#tr-'+blog.id_text+video_entry.attachmentID+' #clear-'+blog.id_text+video_entry.attachmentID).css("display", "block");
971
+ }
972
973
}
974
975
+ }); //end loop through queue
976
977
+ }
978
979
if ( check_again == true ) {
980
var encode_queue_timeouts = container_element.data('encode_queue_timeouts');
992
993
function kgvid_redraw_encode_checkboxes(movieurl, postID, page, blogID) {
994
995
+ var blog = kgvid_get_multisite_data(blogID);
996
+
997
+ var kgflashmediaplayersecurity = document.getElementsByName('attachments'+blog.name_text+'['+postID+'][kgflashmediaplayer-security]')[0].value;
998
999
if ( kgflashmediaplayersecurity ) { //sometimes this tries to run after the media modal is closed
1000
1001
var formats = new Array("fullres", "1080", "720", "mobile", "ogg", "webm");
1002
var kgvid_encode = new Object();
1003
+
1004
jQuery.each(formats, function(key,formats) {
1005
kgvid_encode[formats] = "";
1006
+ if ( jQuery('#attachments-'+blog.id_text+postID+'-kgflashmediaplayer-encode'+formats).length > 0) {
1007
+ kgvid_encode[formats] = document.getElementById('attachments-'+blog.id_text+postID+'-kgflashmediaplayer-encode'+formats).checked;
1008
}
1009
});
1010
JSON.stringify(kgvid_encode);
1011
1012
+ jQuery.post(ajaxurl, { action:"kgvid_generate_encode_checkboxes", security: kgflashmediaplayersecurity, movieurl: movieurl, post_id: postID, page: page, blog_id: blog.ID, encodeformats: kgvid_encode }, function(data) {
1013
+ jQuery('#attachments-'+blog.id_text+postID+'-kgflashmediaplayer-encodeboxes').empty();
1014
+ jQuery('#attachments-'+blog.id_text+postID+'-kgflashmediaplayer-encodeboxes').append(data.checkboxes);
1015
if ( page == "queue" ) {
1016
+ jQuery('#tr-'+blog.id_text+postID+'.currently_encoding').removeClass('currently_encoding');
1017
+ jQuery('#tr-'+blog.id_text+postID+' #clear-'+postID).css("display", "block");
1018
if ( data.encoding == true ) {
1019
+ jQuery('#clear-'+blog.id_text+postID).css("display", "none");
1020
+ jQuery('#tr-'+blog.id_text+postID).addClass('currently_encoding');
1021
}
1022
1023
}
1024
1025
setTimeout( function(){ kgvid_update_encode_queue() }, 3000 ); //start the loop
1026
1027
+ jQuery('#attachments-'+blog.id_text+postID+'-kgflashmediaplayer-encodeboxes').removeAttr('style');
1028
}, "json" );
1029
}
1030
}
1031
1032
function kgvid_redraw_thumbnail_box(postID) {
1033
1034
+ var kgflashmediaplayersecurity = document.getElementsByName('attachments['+postID+'][kgflashmediaplayer-security]')[0].value;
1035
1036
if ( kgflashmediaplayersecurity ) {
1037
1057
}
1058
}
1059
1060
+ function kgvid_encode_queue(action, order, id, blogID) {
1061
1062
+ var blog = kgvid_get_multisite_data(blogID);
1063
1064
var CheckboxTimeout = jQuery('#wpwrap').data("KGVIDCheckboxTimeout") || null;
1065
if ( CheckboxTimeout ) { clearTimeout(CheckboxTimeout); }
1066
1067
+ var kgflashmediaplayersecurity = document.getElementsByName('attachments[kgflashmediaplayer-security]')[0].value;
1068
1069
if ( action == "delete" ) {
1070
+ jQuery('#tr-'+blog.id_text+id).fadeTo('slow', 0.5);
1071
+ jQuery.post(ajaxurl, { action:"kgvid_clear_queue_entry", security: kgflashmediaplayersecurity, index: order, scope: blog.scope }, function(data) {
1072
jQuery('table.widefat > tbody').replaceWith("<tbody class='rows'>"+data+"</tbody>");
1073
}, "html" );
1074
}
1075
1076
if ( action == "clear_completed" ) {
1077
jQuery('tbody > .kgvid_complete').fadeTo('slow', 0.5);
1078
+ jQuery.post(ajaxurl, { action:"kgvid_clear_completed_queue", security: kgflashmediaplayersecurity, type:"manual", scope: blog.scope }, function(data) {
1079
jQuery('table.widefat > tbody').replaceWith("<tbody class='rows'>"+data+"</tbody>");
1080
}, "html" );
1081
}
1086
1087
if ( clear_for_sure == true ) {
1088
jQuery('tbody > .kgvid_queued').fadeTo('slow', 0.5);
1089
+ jQuery.post(ajaxurl, { action:"kgvid_clear_completed_queue", security: kgflashmediaplayersecurity, type:"queued", scope: blog.scope }, function(data) {
1090
+ jQuery('table.widefat > tbody').replaceWith("<tbody class='rows'>"+data+"</tbody>");
1091
+ }, "html" );
1092
+ }
1093
+
1094
+ }
1095
+
1096
+ if ( action == "clear_all" ) {
1097
+
1098
+ var clear_for_sure = confirm(kgvidL10n.clearallwarning+"\n"+kgvidL10n.cancel_ok);
1099
+
1100
+ if ( clear_for_sure == true ) {
1101
+ jQuery('tbody > .kgvid_queued').fadeTo('slow', 0.5);
1102
+ jQuery.post(ajaxurl, { action:"kgvid_clear_completed_queue", security: kgflashmediaplayersecurity, type:"all", scope: blog.scope }, function(data) {
1103
jQuery('table.widefat > tbody').replaceWith("<tbody class='rows'>"+data+"</tbody>");
1104
}, "html" );
1105
}
1230
jQuery("#general_tab").removeClass("nav-tab-active");
1231
jQuery("#encoding_tab").addClass("nav-tab-active");
1232
1233
+ if ( jQuery('h3').length < 1 ) { // WP version 4.4 or later
1234
+ jQuery('h2:eq(1), h2:eq(3)').hide();
1235
+ jQuery('h2:eq(4)').show();
1236
+ }
1237
+ else { // before WP version 4.4
1238
+ jQuery('h3:eq(0), h3:eq(2)').hide();
1239
+ jQuery('h3:eq(3)').show();
1240
+ }
1241
jQuery('table:eq(0), table:eq(1), table:eq(2), table:eq(3)').hide();
1242
jQuery(".kgvid_setting_nearvid").hide();
1243
jQuery('table:eq(4)').show();
1244
1245
if ( jQuery('#app_path').data('ffmpeg_exists') == "on" && jQuery('#ffmpeg_output').html() == "" ) {
1261
1262
jQuery("#general_tab").addClass("nav-tab-active");
1263
jQuery("#encoding_tab").removeClass("nav-tab-active");
1264
+ if ( jQuery('h3').length < 1 ) { // WP version 4.4 or later
1265
+ jQuery('h2:eq(1), h2:eq(3)').show();
1266
+ jQuery('h2:eq(4)').hide();
1267
+ }
1268
+ else { // before WP version 4.4
1269
+ jQuery('h3:eq(0), h3:eq(2)').show();
1270
+ jQuery('h3:eq(3)').hide();
1271
+ }
1272
jQuery('table:eq(0), table:eq(1), table:eq(3)').show();
1273
jQuery(".kgvid_setting_nearvid").show();
1274
+
1275
jQuery('table:eq(4)').hide();
1276
1277
}
1290
1291
if ( playback_option != "Strobe Media Playback" || encoding_tab ) {
1292
jQuery('table:eq(2)').hide();
1293
+ if ( jQuery('h3').length < 1 ) { // WP version 4.4 or later
1294
+ jQuery('h2:eq(2)').hide();
1295
+ }
1296
+ else { // before WP version 4.4
1297
+ jQuery('h3:eq(1)').hide();
1298
+ }
1299
}
1300
1301
if ( general_tab ) {
1302
1303
if ( playback_option == "Strobe Media Playback" ) {
1304
jQuery('table:eq(2)').show();
1305
+ if ( jQuery('h3').length < 1 ) { // WP version 4.4 or later
1306
+ jQuery('h2:eq(2)').show();
1307
+ }
1308
+ else {
1309
+ jQuery('h3:eq(1)').show();
1310
+ }
1311
}
1312
1313
if ( playback_option == "WordPress Default" || playback_option == "JW Player" ) {
1314
jQuery('#nativecontrolsfortouch').parents().eq(1).hide();
1315
jQuery('#js_skin').parents().eq(1).hide();
1316
jQuery('#chromecast').parents().eq(1).hide();
1317
+ jQuery('#resize_div').hide();
1318
}
1319
1320
if ( playback_option == "Video.js" || playback_option == "Strobe Media Playback" ) {
1322
jQuery('#js_skin').parents().eq(1).show();
1323
jQuery('#chromecast').parents().eq(1).show();
1324
jQuery('#auto_res').parents().eq(1).show();
1325
+ jQuery('#resize_div').show();
1326
+ }
1327
+
1328
+ if ( playback_option == "WordPress Default" ) {
1329
+ jQuery('#auto_res').parents().eq(1).show();
1330
}
1331
1332
if ( playback_option == "JW Player" ) {
1333
jQuery('#endofvideooverlay').parents().eq(1).hide();
1334
+ jQuery('#auto_res').parents().eq(1).hide();
1335
jQuery('#jw_player_id_select').fadeIn();
1336
}
1337
else {
1339
jQuery('#jw_player_id_select').fadeOut();
1340
}
1341
1342
+ if ( jQuery('#twitter_button').prop('checked') || jQuery('#twitter_card').prop('checked') ) {
1343
+ jQuery('#twitter_username_div').slideDown();
1344
+ }
1345
+ else {
1346
+ jQuery('#twitter_username_div').slideUp();
1347
+ }
1348
1349
+ if ( jQuery('#auto_res').val() == 'automatic' ) {
1350
+ jQuery('#pixel_ratio_p').slideDown();
1351
}
1352
else {
1353
+ jQuery('#pixel_ratio_p').slideUp();
1354
}
1355
1356
}
1357
1358
+ if ( encoding_tab ) {
1359
+
1360
+ kgvid_moov_setting();
1361
+
1362
+ }
1363
+
1364
if ( ffmpeg_exists == "notinstalled" ) {
1365
jQuery(".kgvid_video_app_required").addClass("kgvid_thumbnail_overlay");
1366
jQuery(".kgvid_video_app_required").attr('title', kgvidL10n.ffmpegrequired);
1392
1393
}
1394
1395
+ function kgvid_moov_setting() {
1396
+
1397
+ var moov = jQuery('#moov').val();
1398
+
1399
+ if ( moov == 'none' || moov == 'movflag' ) {
1400
+ jQuery('#moov_path_p').hide();
1401
+ }
1402
+ else {
1403
+ jQuery('.kgvid_moov_option').html(moov);
1404
+ jQuery('#moov_path_p').show();
1405
+ }
1406
+
1407
+ }
1408
+
1409
+ function kgvid_change_replace_format() {
1410
+
1411
+ var replace_format_text = jQuery('#replace_format option:selected').text();
1412
+ jQuery('span.kgvid_replace_format').html(replace_format_text);
1413
+
1414
+ }
1415
+
1416
function kgvid_hide_watermark_url(obj) {
1417
1418
if ( obj.value == 'custom' ) {
1623
1624
}
1625
1626
+ function kgvid_pick_format(button, parentID, mime, format, movieurl, blog_id) {
1627
1628
var frame;
1629
1664
var video = frame.state().get('selection').first();
1665
var kgflashmediaplayersecurity = document.getElementsByName('attachments['+parentID+'][kgflashmediaplayer-security]')[0].value;
1666
1667
+ jQuery.post(ajaxurl, { action:"kgvid_update_child_format", security: kgflashmediaplayersecurity, parent_id: parentID, video_id: video.id, format: format, blog_id: blog_id }, function(data) {
1668
+ kgvid_redraw_encode_checkboxes(movieurl, parentID, 'attachment', blog_id);
1669
}, "json");
1670
1671
});
1680
var kgflashmediaplayersecurity = document.getElementsByName('attachments['+postID+'][kgflashmediaplayer-security]')[0].value;
1681
1682
jQuery.post(ajaxurl, { action:"kgvid_clear_child_format", security: kgflashmediaplayersecurity, video_id: video_id, blog_id: blog_id }, function(data) {
1683
+ kgvid_redraw_encode_checkboxes(movieurl, postID, 'attachment', blog_id);
1684
}, "json");
1685
1686
}
js/mep-feature-sourcechooser.js ADDED
@@ -0,0 +1,154 @@
1
+ // Source Chooser Plugin
2
+ (function($) {
3
+
4
+ $.extend(mejs.MepDefaults, {
5
+ sourcechooserText: 'Source Chooser'
6
+ });
7
+
8
+ $.extend(MediaElementPlayer.prototype, {
9
+ buildsourcechooser: function(player, controls, layers, media) {
10
+
11
+ var t = this;
12
+ var enable_plugin = false;
13
+
14
+ for (var i in this.node.children) {
15
+ var src = this.node.children[i];
16
+ if (src.nodeName === 'SOURCE' && src.dataset.res != undefined && src.dataset.res !== '' && (media.canPlayType(src.type) == 'probably' || media.canPlayType(src.type) == 'maybe')) {
17
+ var enable_plugin = true;
18
+ }
19
+ }
20
+
21
+ if ( enable_plugin == true ) {
22
+
23
+ player.sourcechooserButton =
24
+ $('<div class="mejs-button mejs-sourcechooser-button">'+
25
+ '<button type="button" aria-controls="' + t.id + '" title="' + t.options.sourcechooserText + '" aria-label="' + t.options.sourcechooserText + '"></button>'+
26
+ '<div class="mejs-menu-arrow">'+
27
+ '<div class="mejs-sourcechooser-selector">'+
28
+ '<span>'+kgvidL10n_frontend.quality+'</span>'+
29
+ '<ul>'+
30
+ '</ul>'+
31
+ '</div>'+
32
+ '</div>'+
33
+ '</div>')
34
+ .appendTo(controls)
35
+
36
+ // hover
37
+ .hover(function() {
38
+ $(this).find('.mejs-menu-arrow').show();
39
+ }, function() {
40
+ $(this).find('.mejs-menu-arrow').hide();
41
+ })
42
+
43
+ // handle clicks to the source radio buttons
44
+ .delegate('li', 'click', function() {
45
+
46
+ player.changeRes(this.innerHTML);
47
+
48
+ });
49
+
50
+ // add to list
51
+ player.availableRes = new Object();
52
+ for (var i in this.node.children) {
53
+ var src = this.node.children[i];
54
+ if (src.nodeName === 'SOURCE' && src.dataset.res != undefined && src.dataset.res !== '' && (media.canPlayType(src.type) == 'probably' || media.canPlayType(src.type) == 'maybe')) {
55
+ player.addSourceButton(src.src, src.dataset.res, src.type, media.src == src.src);
56
+ player.availableRes[src.dataset.res] = src.src;
57
+
58
+ if ( src.dataset.default_res != undefined ) {
59
+ if ( this.currentRes != src.dataset.res ) {
60
+ this.changeRes(src.dataset.res);
61
+ }
62
+ }
63
+
64
+ }
65
+ }
66
+
67
+ }
68
+
69
+ },
70
+
71
+ addSourc