Video Embed & Thumbnail Generator - Version 3.0

Version Description

Fixes thumbnails & encodes in WP 3.5. Not compatible with earlier WP versions.

Download this release

Release Info

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

Code changes from version 2.0.6 to 3.0

css/images/ui-bg_flat_0_000000_40x100.png ADDED
Binary file
css/images/ui-bg_glass_95_fef1ec_1x400.png ADDED
Binary file
css/images/ui-bg_gloss-wave_16_121212_500x100.png ADDED
Binary file
css/images/ui-bg_highlight-hard_15_888888_1x100.png ADDED
Binary file
css/images/ui-bg_highlight-hard_55_555555_1x100.png ADDED
Binary file
css/images/ui-bg_highlight-soft_35_adadad_1x100.png ADDED
Binary file
css/images/ui-bg_highlight-soft_60_000000_1x100.png ADDED
Binary file
css/images/ui-bg_inset-soft_15_121212_1x100.png ADDED
Binary file
css/images/ui-icons_00a2f2_256x240.png ADDED
Binary file
css/images/ui-icons_aaaaaa_256x240.png ADDED
Binary file
css/images/ui-icons_bbbbbb_256x240.png ADDED
Binary file
css/images/ui-icons_cccccc_256x240.png ADDED
Binary file
css/images/ui-icons_cd0a0a_256x240.png ADDED
Binary file
css/images/ui-icons_ffffff_256x240.png ADDED
Binary file
css/kgvid_video_gallery.css ADDED
@@ -0,0 +1,599 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .kgvid_video_gallery_thumb {
2
+ position: relative;
3
+ display:inline-block;
4
+ margin:10px;
5
+ }
6
+
7
+ .kgvid_video_gallery_thumb img {
8
+ width: 100%;
9
+ max-width:none !important; //fixes conflict with some themes
10
+ padding:0px;
11
+ margins:0px;
12
+ }
13
+
14
+ .kgvid_video_gallery_thumb span {
15
+ position:absolute;
16
+ padding-top:10px;
17
+ bottom:4px;
18
+ left:0px;
19
+ height:25px;
20
+ width:100%;
21
+ text-align:center;
22
+ color:white;
23
+ background-color: rgba(0,0,0,0.5);
24
+ vertical-align:middle;
25
+ letter-spacing:0.05em;
26
+ font-size:10pt;
27
+ }
28
+
29
+ #kgvid_GalleryVideo {
30
+ position:relative;
31
+ top:5px;
32
+ left:5px;
33
+ }
34
+
35
+
36
+
37
+ /*!
38
+ * jQuery UI CSS Framework 1.8.22
39
+ *
40
+ * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
41
+ * Dual licensed under the MIT or GPL Version 2 licenses.
42
+ * http://jquery.org/license
43
+ *
44
+ * http://docs.jquery.com/UI/Theming/API
45
+ */
46
+
47
+ /* Layout helpers
48
+ ----------------------------------*/
49
+ .ui-helper-hidden { display: none; }
50
+ .ui-helper-hidden-accessible { position: absolute !important; clip: rect(1px 1px 1px 1px); clip: rect(1px,1px,1px,1px); }
51
+ .ui-helper-reset { margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none; }
52
+ .ui-helper-clearfix:before, .ui-helper-clearfix:after { content: ""; display: table; }
53
+ .ui-helper-clearfix:after { clear: both; }
54
+ .ui-helper-clearfix { zoom: 1; }
55
+ .ui-helper-zfix { width: 100%; height: 100%; top: 0; left: 0; position: absolute; opacity: 0; filter:Alpha(Opacity=0); }
56
+
57
+
58
+ /* Interaction Cues
59
+ ----------------------------------*/
60
+ .ui-state-disabled { cursor: default !important; }
61
+
62
+
63
+ /* Icons
64
+ ----------------------------------*/
65
+
66
+ /* states and images */
67
+ .ui-icon { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; }
68
+
69
+
70
+ /* Misc visuals
71
+ ----------------------------------*/
72
+
73
+ /* Overlays */
74
+ .ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
75
+
76
+
77
+ /*!
78
+ * jQuery UI CSS Framework 1.8.22
79
+ *
80
+ * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
81
+ * Dual licensed under the MIT or GPL Version 2 licenses.
82
+ * http://jquery.org/license
83
+ *
84
+ * http://docs.jquery.com/UI/Theming/API
85
+ *
86
+ * To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=Verdana,Arial,sans-serif&fwDefault=normal&fsDefault=1.1em&cornerRadius=4px&bgColorHeader=cccccc&bgTextureHeader=03_highlight_soft.png&bgImgOpacityHeader=75&borderColorHeader=aaaaaa&fcHeader=222222&iconColorHeader=222222&bgColorContent=ffffff&bgTextureContent=01_flat.png&bgImgOpacityContent=75&borderColorContent=aaaaaa&fcContent=222222&iconColorContent=222222&bgColorDefault=e6e6e6&bgTextureDefault=02_glass.png&bgImgOpacityDefault=75&borderColorDefault=d3d3d3&fcDefault=555555&iconColorDefault=888888&bgColorHover=dadada&bgTextureHover=02_glass.png&bgImgOpacityHover=75&borderColorHover=999999&fcHover=212121&iconColorHover=454545&bgColorActive=ffffff&bgTextureActive=02_glass.png&bgImgOpacityActive=65&borderColorActive=aaaaaa&fcActive=212121&iconColorActive=454545&bgColorHighlight=fbf9ee&bgTextureHighlight=02_glass.png&bgImgOpacityHighlight=55&borderColorHighlight=fcefa1&fcHighlight=363636&iconColorHighlight=2e83ff&bgColorError=fef1ec&bgTextureError=05_inset_soft.png&bgImgOpacityError=95&borderColorError=cd0a0a&fcError=cd0a0a&iconColorError=cd0a0a&bgColorOverlay=000000&bgTextureOverlay=01_flat.png&bgImgOpacityOverlay=0&opacityOverlay=80&bgColorShadow=aaaaaa&bgTextureShadow=01_flat.png&bgImgOpacityShadow=0&opacityShadow=20&thicknessShadow=8px&offsetTopShadow=-8px&offsetLeftShadow=-8px&cornerRadiusShadow=8px
87
+ */
88
+
89
+
90
+ /* Component containers
91
+ ----------------------------------*/
92
+ .ui-widget { font-family: Verdana,Arial,sans-serif; font-size: 1.1em; }
93
+ .ui-widget .ui-widget { font-size: 1em; }
94
+ .ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { font-family: Verdana,Arial,sans-serif; font-size: 1em; }
95
+ .ui-widget-content { }
96
+ .ui-widget-content a { color: #222222; }
97
+ .ui-widget-header { color: #222222; font-weight: bold; }
98
+ .ui-widget-header a { color: #222222; }
99
+
100
+ /* Interaction states
101
+ ----------------------------------*/
102
+ .ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { border: 1px solid #d3d3d3; background: #e6e6e6 url(images/ui-bg_glass_75_e6e6e6_1x400.png) 50% 50% repeat-x; font-weight: normal; color: #555555; }
103
+ .ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited { color: #555555; text-decoration: none; }
104
+ .ui-state-hover, .ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus { border: 1px solid #7a7a7a; background: #000000 url(images/ui-bg_highlight-soft_60_000000_1x100.png) 50% 50% repeat-x; font-weight: normal; color: #ebebeb; }
105
+ .ui-state-hover a, .ui-state-hover a:hover { color: #212121; text-decoration: none; }
106
+ .ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active { border: 1px solid #aaaaaa; background: #ffffff url(images/ui-bg_glass_65_ffffff_1x400.png) 50% 50% repeat-x; font-weight: normal; color: #212121; }
107
+ .ui-state-active a, .ui-state-active a:link, .ui-state-active a:visited { color: #212121; text-decoration: none; }
108
+ .ui-widget :active { outline: none; }
109
+
110
+ /* Interaction Cues
111
+ ----------------------------------*/
112
+ .ui-state-highlight, .ui-widget-content .ui-state-highlight, .ui-widget-header .ui-state-highlight {border: 1px solid #fcefa1; background: #fbf9ee url(images/ui-bg_glass_55_fbf9ee_1x400.png) 50% 50% repeat-x; color: #363636; }
113
+ .ui-state-highlight a, .ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a { color: #363636; }
114
+ .ui-state-error, .ui-widget-content .ui-state-error, .ui-widget-header .ui-state-error {border: 1px solid #cd0a0a; background: #fef1ec url(images/ui-bg_inset-soft_95_fef1ec_1x100.png) 50% bottom repeat-x; color: #cd0a0a; }
115
+ .ui-state-error a, .ui-widget-content .ui-state-error a, .ui-widget-header .ui-state-error a { color: #cd0a0a; }
116
+ .ui-state-error-text, .ui-widget-content .ui-state-error-text, .ui-widget-header .ui-state-error-text { color: #cd0a0a; }
117
+ .ui-priority-primary, .ui-widget-content .ui-priority-primary, .ui-widget-header .ui-priority-primary { font-weight: bold; }
118
+ .ui-priority-secondary, .ui-widget-content .ui-priority-secondary, .ui-widget-header .ui-priority-secondary { opacity: .7; filter:Alpha(Opacity=70); font-weight: normal; }
119
+ .ui-state-disabled, .ui-widget-content .ui-state-disabled, .ui-widget-header .ui-state-disabled { opacity: .35; filter:Alpha(Opacity=35); background-image: none; }
120
+
121
+ /* Icons
122
+ ----------------------------------*/
123
+
124
+ /* states and images */
125
+ .ui-icon { width: 16px; height: 16px; background-image: url(images/ui-icons_bbbbbb_256x240.png); }
126
+ .ui-widget-content .ui-icon {background-image: url(images/ui-icons_bbbbbb_256x240.png); }
127
+ .ui-widget-header .ui-icon {background-image: url(images/ui-icons_cccccc_256x240.png); }
128
+ .ui-state-default .ui-icon { background-image: url(images/ui-icons_ffffff_256x240.png); }
129
+ .ui-state-hover .ui-icon, .ui-state-focus .ui-icon {background-image: url(images/ui-icons_00a2f2_256x240.png); }
130
+ .ui-state-active .ui-icon {background-image: url(images/ui-icons_00a2f2_256x240.png); }
131
+ .ui-state-highlight .ui-icon {background-image: url(images/ui-icons_aaaaaa_256x240.png); }
132
+ .ui-state-error .ui-icon, .ui-state-error-text .ui-icon {background-image: url(images/ui-icons_cd0a0a_256x240.png); }
133
+
134
+ /* positioning */
135
+ .ui-icon-carat-1-n { background-position: 0 0; }
136
+ .ui-icon-carat-1-ne { background-position: -16px 0; }
137
+ .ui-icon-carat-1-e { background-position: -32px 0; }
138
+ .ui-icon-carat-1-se { background-position: -48px 0; }
139
+ .ui-icon-carat-1-s { background-position: -64px 0; }
140
+ .ui-icon-carat-1-sw { background-position: -80px 0; }
141
+ .ui-icon-carat-1-w { background-position: -96px 0; }
142
+ .ui-icon-carat-1-nw { background-position: -112px 0; }
143
+ .ui-icon-carat-2-n-s { background-position: -128px 0; }
144
+ .ui-icon-carat-2-e-w { background-position: -144px 0; }
145
+ .ui-icon-triangle-1-n { background-position: 0 -16px; }
146
+ .ui-icon-triangle-1-ne { background-position: -16px -16px; }
147
+ .ui-icon-triangle-1-e { background-position: -32px -16px; }
148
+ .ui-icon-triangle-1-se { background-position: -48px -16px; }
149
+ .ui-icon-triangle-1-s { background-position: -64px -16px; }
150
+ .ui-icon-triangle-1-sw { background-position: -80px -16px; }
151
+ .ui-icon-triangle-1-w { background-position: -96px -16px; }
152
+ .ui-icon-triangle-1-nw { background-position: -112px -16px; }
153
+ .ui-icon-triangle-2-n-s { background-position: -128px -16px; }
154
+ .ui-icon-triangle-2-e-w { background-position: -144px -16px; }
155
+ .ui-icon-arrow-1-n { background-position: 0 -32px; }
156
+ .ui-icon-arrow-1-ne { background-position: -16px -32px; }
157
+ .ui-icon-arrow-1-e { background-position: -32px -32px; }
158
+ .ui-icon-arrow-1-se { background-position: -48px -32px; }
159
+ .ui-icon-arrow-1-s { background-position: -64px -32px; }
160
+ .ui-icon-arrow-1-sw { background-position: -80px -32px; }
161
+ .ui-icon-arrow-1-w { background-position: -96px -32px; }
162
+ .ui-icon-arrow-1-nw { background-position: -112px -32px; }
163
+ .ui-icon-arrow-2-n-s { background-position: -128px -32px; }
164
+ .ui-icon-arrow-2-ne-sw { background-position: -144px -32px; }
165
+ .ui-icon-arrow-2-e-w { background-position: -160px -32px; }
166
+ .ui-icon-arrow-2-se-nw { background-position: -176px -32px; }
167
+ .ui-icon-arrowstop-1-n { background-position: -192px -32px; }
168
+ .ui-icon-arrowstop-1-e { background-position: -208px -32px; }
169
+ .ui-icon-arrowstop-1-s { background-position: -224px -32px; }
170
+ .ui-icon-arrowstop-1-w { background-position: -240px -32px; }
171
+ .ui-icon-arrowthick-1-n { background-position: 0 -48px; }
172
+ .ui-icon-arrowthick-1-ne { background-position: -16px -48px; }
173
+ .ui-icon-arrowthick-1-e { background-position: -32px -48px; }
174
+ .ui-icon-arrowthick-1-se { background-position: -48px -48px; }
175
+ .ui-icon-arrowthick-1-s { background-position: -64px -48px; }
176
+ .ui-icon-arrowthick-1-sw { background-position: -80px -48px; }
177
+ .ui-icon-arrowthick-1-w { background-position: -96px -48px; }
178
+ .ui-icon-arrowthick-1-nw { background-position: -112px -48px; }
179
+ .ui-icon-arrowthick-2-n-s { background-position: -128px -48px; }
180
+ .ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; }
181
+ .ui-icon-arrowthick-2-e-w { background-position: -160px -48px; }
182
+ .ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; }
183
+ .ui-icon-arrowthickstop-1-n { background-position: -192px -48px; }
184
+ .ui-icon-arrowthickstop-1-e { background-position: -208px -48px; }
185
+ .ui-icon-arrowthickstop-1-s { background-position: -224px -48px; }
186
+ .ui-icon-arrowthickstop-1-w { background-position: -240px -48px; }
187
+ .ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; }
188
+ .ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; }
189
+ .ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; }
190
+ .ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; }
191
+ .ui-icon-arrowreturn-1-w { background-position: -64px -64px; }
192
+ .ui-icon-arrowreturn-1-n { background-position: -80px -64px; }
193
+ .ui-icon-arrowreturn-1-e { background-position: -96px -64px; }
194
+ .ui-icon-arrowreturn-1-s { background-position: -112px -64px; }
195
+ .ui-icon-arrowrefresh-1-w { background-position: -128px -64px; }
196
+ .ui-icon-arrowrefresh-1-n { background-position: -144px -64px; }
197
+ .ui-icon-arrowrefresh-1-e { background-position: -160px -64px; }
198
+ .ui-icon-arrowrefresh-1-s { background-position: -176px -64px; }
199
+ .ui-icon-arrow-4 { background-position: 0 -80px; }
200
+ .ui-icon-arrow-4-diag { background-position: -16px -80px; }
201
+ .ui-icon-extlink { background-position: -32px -80px; }
202
+ .ui-icon-newwin { background-position: -48px -80px; }
203
+ .ui-icon-refresh { background-position: -64px -80px; }
204
+ .ui-icon-shuffle { background-position: -80px -80px; }
205
+ .ui-icon-transfer-e-w { background-position: -96px -80px; }
206
+ .ui-icon-transferthick-e-w { background-position: -112px -80px; }
207
+ .ui-icon-folder-collapsed { background-position: 0 -96px; }
208
+ .ui-icon-folder-open { background-position: -16px -96px; }
209
+ .ui-icon-document { background-position: -32px -96px; }
210
+ .ui-icon-document-b { background-position: -48px -96px; }
211
+ .ui-icon-note { background-position: -64px -96px; }
212
+ .ui-icon-mail-closed { background-position: -80px -96px; }
213
+ .ui-icon-mail-open { background-position: -96px -96px; }
214
+ .ui-icon-suitcase { background-position: -112px -96px; }
215
+ .ui-icon-comment { background-position: -128px -96px; }
216
+ .ui-icon-person { background-position: -144px -96px; }
217
+ .ui-icon-print { background-position: -160px -96px; }
218
+ .ui-icon-trash { background-position: -176px -96px; }
219
+ .ui-icon-locked { background-position: -192px -96px; }
220
+ .ui-icon-unlocked { background-position: -208px -96px; }
221
+ .ui-icon-bookmark { background-position: -224px -96px; }
222
+ .ui-icon-tag { background-position: -240px -96px; }
223
+ .ui-icon-home { background-position: 0 -112px; }
224
+ .ui-icon-flag { background-position: -16px -112px; }
225
+ .ui-icon-calendar { background-position: -32px -112px; }
226
+ .ui-icon-cart { background-position: -48px -112px; }
227
+ .ui-icon-pencil { background-position: -64px -112px; }
228
+ .ui-icon-clock { background-position: -80px -112px; }
229
+ .ui-icon-disk { background-position: -96px -112px; }
230
+ .ui-icon-calculator { background-position: -112px -112px; }
231
+ .ui-icon-zoomin { background-position: -128px -112px; }
232
+ .ui-icon-zoomout { background-position: -144px -112px; }
233
+ .ui-icon-search { background-position: -160px -112px; }
234
+ .ui-icon-wrench { background-position: -176px -112px; }
235
+ .ui-icon-gear { background-position: -192px -112px; }
236
+ .ui-icon-heart { background-position: -208px -112px; }
237
+ .ui-icon-star { background-position: -224px -112px; }
238
+ .ui-icon-link { background-position: -240px -112px; }
239
+ .ui-icon-cancel { background-position: 0 -128px; }
240
+ .ui-icon-plus { background-position: -16px -128px; }
241
+ .ui-icon-plusthick { background-position: -32px -128px; }
242
+ .ui-icon-minus { background-position: -48px -128px; }
243
+ .ui-icon-minusthick { background-position: -64px -128px; }
244
+ .ui-icon-close { background-position: -80px -128px; }
245
+ .ui-icon-closethick { background-position: -96px -128px; }
246
+ .ui-icon-key { background-position: -112px -128px; }
247
+ .ui-icon-lightbulb { background-position: -128px -128px; }
248
+ .ui-icon-scissors { background-position: -144px -128px; }
249
+ .ui-icon-clipboard { background-position: -160px -128px; }
250
+ .ui-icon-copy { background-position: -176px -128px; }
251
+ .ui-icon-contact { background-position: -192px -128px; }
252
+ .ui-icon-image { background-position: -208px -128px; }
253
+ .ui-icon-video { background-position: -224px -128px; }
254
+ .ui-icon-script { background-position: -240px -128px; }
255
+ .ui-icon-alert { background-position: 0 -144px; }
256
+ .ui-icon-info { background-position: -16px -144px; }
257
+ .ui-icon-notice { background-position: -32px -144px; }
258
+ .ui-icon-help { background-position: -48px -144px; }
259
+ .ui-icon-check { background-position: -64px -144px; }
260
+ .ui-icon-bullet { background-position: -80px -144px; }
261
+ .ui-icon-radio-off { background-position: -96px -144px; }
262
+ .ui-icon-radio-on { background-position: -112px -144px; }
263
+ .ui-icon-pin-w { background-position: -128px -144px; }
264
+ .ui-icon-pin-s { background-position: -144px -144px; }
265
+ .ui-icon-play { background-position: 0 -160px; }
266
+ .ui-icon-pause { background-position: -16px -160px; }
267
+ .ui-icon-seek-next { background-position: -32px -160px; }
268
+ .ui-icon-seek-prev { background-position: -48px -160px; }
269
+ .ui-icon-seek-end { background-position: -64px -160px; }
270
+ .ui-icon-seek-start { background-position: -80px -160px; }
271
+ /* ui-icon-seek-first is deprecated, use ui-icon-seek-start instead */
272
+ .ui-icon-seek-first { background-position: -80px -160px; }
273
+ .ui-icon-stop { background-position: -96px -160px; }
274
+ .ui-icon-eject { background-position: -112px -160px; }
275
+ .ui-icon-volume-off { background-position: -128px -160px; }
276
+ .ui-icon-volume-on { background-position: -144px -160px; }
277
+ .ui-icon-power { background-position: 0 -176px; }
278
+ .ui-icon-signal-diag { background-position: -16px -176px; }
279
+ .ui-icon-signal { background-position: -32px -176px; }
280
+ .ui-icon-battery-0 { background-position: -48px -176px; }
281
+ .ui-icon-battery-1 { background-position: -64px -176px; }
282
+ .ui-icon-battery-2 { background-position: -80px -176px; }
283
+ .ui-icon-battery-3 { background-position: -96px -176px; }
284
+ .ui-icon-circle-plus { background-position: 0 -192px; }
285
+ .ui-icon-circle-minus { background-position: -16px -192px; }
286
+ .ui-icon-circle-close { background-position: -32px -192px; }
287
+ .ui-icon-circle-triangle-e { background-position: -48px -192px; }
288
+ .ui-icon-circle-triangle-s { background-position: -64px -192px; }
289
+ .ui-icon-circle-triangle-w { background-position: -80px -192px; }
290
+ .ui-icon-circle-triangle-n { background-position: -96px -192px; }
291
+ .ui-icon-circle-arrow-e { background-position: -112px -192px; }
292
+ .ui-icon-circle-arrow-s { background-position: -128px -192px; }
293
+ .ui-icon-circle-arrow-w { background-position: -144px -192px; }
294
+ .ui-icon-circle-arrow-n { background-position: -160px -192px; }
295
+ .ui-icon-circle-zoomin { background-position: -176px -192px; }
296
+ .ui-icon-circle-zoomout { background-position: -192px -192px; }
297
+ .ui-icon-circle-check { background-position: -208px -192px; }
298
+ .ui-icon-circlesmall-plus { background-position: 0 -208px; }
299
+ .ui-icon-circlesmall-minus { background-position: -16px -208px; }
300
+ .ui-icon-circlesmall-close { background-position: -32px -208px; }
301
+ .ui-icon-squaresmall-plus { background-position: -48px -208px; }
302
+ .ui-icon-squaresmall-minus { background-position: -64px -208px; }
303
+ .ui-icon-squaresmall-close { background-position: -80px -208px; }
304
+ .ui-icon-grip-dotted-vertical { background-position: 0 -224px; }
305
+ .ui-icon-grip-dotted-horizontal { background-position: -16px -224px; }
306
+ .ui-icon-grip-solid-vertical { background-position: -32px -224px; }
307
+ .ui-icon-grip-solid-horizontal { background-position: -48px -224px; }
308
+ .ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; }
309
+ .ui-icon-grip-diagonal-se { background-position: -80px -224px; }
310
+
311
+
312
+ /* Misc visuals
313
+ ----------------------------------*/
314
+
315
+ /* Corner radius */
316
+ .ui-corner-all, .ui-corner-top, .ui-corner-left, .ui-corner-tl { -moz-border-radius-topleft: 4px; -webkit-border-top-left-radius: 4px; -khtml-border-top-left-radius: 4px; border-top-left-radius: 4px; }
317
+ .ui-corner-all, .ui-corner-top, .ui-corner-right, .ui-corner-tr { -moz-border-radius-topright: 4px; -webkit-border-top-right-radius: 4px; -khtml-border-top-right-radius: 4px; border-top-right-radius: 4px; }
318
+ .ui-corner-all, .ui-corner-bottom, .ui-corner-left, .ui-corner-bl { -moz-border-radius-bottomleft: 4px; -webkit-border-bottom-left-radius: 4px; -khtml-border-bottom-left-radius: 4px; border-bottom-left-radius: 4px; }
319
+ .ui-corner-all, .ui-corner-bottom, .ui-corner-right, .ui-corner-br { -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 4px; -khtml-border-bottom-right-radius: 4px; border-bottom-right-radius: 4px; }
320
+
321
+ /* Overlays */
322
+ .ui-widget-overlay { background-color: black; opacity: .80;filter:Alpha(Opacity=80); }
323
+ .ui-widget-shadow { margin: -8px 0 0 -8px; padding: 8px; background: #000000 url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x; opacity: .20;filter:Alpha(Opacity=20); -moz-border-radius: 8px; -khtml-border-radius: 8px; -webkit-border-radius: 8px; border-radius: 8px; }/*!
324
+ * jQuery UI Resizable 1.8.22
325
+ *
326
+ * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
327
+ * Dual licensed under the MIT or GPL Version 2 licenses.
328
+ * http://jquery.org/license
329
+ *
330
+ * http://docs.jquery.com/UI/Resizable#theming
331
+ */
332
+ .ui-resizable { position: relative;}
333
+ .ui-resizable-handle { position: absolute;font-size: 0.1px; display: block; }
334
+ .ui-resizable-disabled .ui-resizable-handle, .ui-resizable-autohide .ui-resizable-handle { display: none; }
335
+ .ui-resizable-n { cursor: n-resize; height: 7px; width: 100%; top: -5px; left: 0; }
336
+ .ui-resizable-s { cursor: s-resize; height: 7px; width: 100%; bottom: -5px; left: 0; }
337
+ .ui-resizable-e { cursor: e-resize; width: 7px; right: -5px; top: 0; height: 100%; }
338
+ .ui-resizable-w { cursor: w-resize; width: 7px; left: -5px; top: 0; height: 100%; }
339
+ .ui-resizable-se { cursor: se-resize; width: 12px; height: 12px; right: 1px; bottom: 1px; }
340
+ .ui-resizable-sw { cursor: sw-resize; width: 9px; height: 9px; left: -5px; bottom: -5px; }
341
+ .ui-resizable-nw { cursor: nw-resize; width: 9px; height: 9px; left: -5px; top: -5px; }
342
+ .ui-resizable-ne { cursor: ne-resize; width: 9px; height: 9px; right: -5px; top: -5px;}/*!
343
+ * jQuery UI Selectable 1.8.22
344
+ *
345
+ * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
346
+ * Dual licensed under the MIT or GPL Version 2 licenses.
347
+ * http://jquery.org/license
348
+ *
349
+ * http://docs.jquery.com/UI/Selectable#theming
350
+ */
351
+ .ui-selectable-helper { position: absolute; z-index: 100; border:1px dotted black; }
352
+ /*!
353
+ * jQuery UI Accordion 1.8.22
354
+ *
355
+ * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
356
+ * Dual licensed under the MIT or GPL Version 2 licenses.
357
+ * http://jquery.org/license
358
+ *
359
+ * http://docs.jquery.com/UI/Accordion#theming
360
+ */
361
+ /* IE/Win - Fix animation bug - #4615 */
362
+ .ui-accordion { width: 100%; }
363
+ .ui-accordion .ui-accordion-header { cursor: pointer; position: relative; margin-top: 1px; zoom: 1; }
364
+ .ui-accordion .ui-accordion-li-fix { display: inline; }
365
+ .ui-accordion .ui-accordion-header-active { border-bottom: 0 !important; }
366
+ .ui-accordion .ui-accordion-header a { display: block; font-size: 1em; padding: .5em .5em .5em .7em; }
367
+ .ui-accordion-icons .ui-accordion-header a { padding-left: 2.2em; }
368
+ .ui-accordion .ui-accordion-header .ui-icon { position: absolute; left: .5em; top: 50%; margin-top: -8px; }
369
+ .ui-accordion .ui-accordion-content { padding: 1em 2.2em; border-top: 0; margin-top: -2px; position: relative; top: 1px; margin-bottom: 2px; overflow: auto; display: none; zoom: 1; }
370
+ .ui-accordion .ui-accordion-content-active { display: block; }
371
+ /*!
372
+ * jQuery UI Autocomplete 1.8.22
373
+ *
374
+ * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
375
+ * Dual licensed under the MIT or GPL Version 2 licenses.
376
+ * http://jquery.org/license
377
+ *
378
+ * http://docs.jquery.com/UI/Autocomplete#theming
379
+ */
380
+ .ui-autocomplete { position: absolute; cursor: default; }
381
+
382
+ /* workarounds */
383
+ * html .ui-autocomplete { width:1px; } /* without this, the menu expands to 100% in IE6 */
384
+
385
+ /*
386
+ * jQuery UI Menu 1.8.22
387
+ *
388
+ * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
389
+ * Dual licensed under the MIT or GPL Version 2 licenses.
390
+ * http://jquery.org/license
391
+ *
392
+ * http://docs.jquery.com/UI/Menu#theming
393
+ */
394
+ .ui-menu {
395
+ list-style:none;
396
+ padding: 2px;
397
+ margin: 0;
398
+ display:block;
399
+ float: left;
400
+ }
401
+ .ui-menu .ui-menu {
402
+ margin-top: -3px;
403
+ }
404
+ .ui-menu .ui-menu-item {
405
+ margin:0;
406
+ padding: 0;
407
+ zoom: 1;
408
+ float: left;
409
+ clear: left;
410
+ width: 100%;
411
+ }
412
+ .ui-menu .ui-menu-item a {
413
+ text-decoration:none;
414
+ display:block;
415
+ padding:.2em .4em;
416
+ line-height:1.5;
417
+ zoom:1;
418
+ }
419
+ .ui-menu .ui-menu-item a.ui-state-hover,
420
+ .ui-menu .ui-menu-item a.ui-state-active {
421
+ font-weight: normal;
422
+ margin: -1px;
423
+ }
424
+ /*!
425
+ * jQuery UI Button 1.8.22
426
+ *
427
+ * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
428
+ * Dual licensed under the MIT or GPL Version 2 licenses.
429
+ * http://jquery.org/license
430
+ *
431
+ * http://docs.jquery.com/UI/Button#theming
432
+ */
433
+ .ui-button { display: inline-block; position: relative; padding: 0; margin-right: .1em; text-decoration: none !important; cursor: pointer; text-align: center; zoom: 1; overflow: visible; } /* the overflow property removes extra width in IE */
434
+ .ui-button-icon-only { width: 2.2em; } /* to make room for the icon, a width needs to be set here */
435
+ button.ui-button-icon-only { width: 2.4em; } /* button elements seem to need a little more width */
436
+ .ui-button-icons-only { width: 3.4em; }
437
+ button.ui-button-icons-only { width: 3.7em; }
438
+
439
+ /*button text element */
440
+ .ui-button .ui-button-text { display: block; line-height: 1.4; }
441
+ .ui-button-text-only .ui-button-text { padding: .4em 1em; }
442
+ .ui-button-icon-only .ui-button-text, .ui-button-icons-only .ui-button-text { padding: .4em; text-indent: -9999999px; }
443
+ .ui-button-text-icon-primary .ui-button-text, .ui-button-text-icons .ui-button-text { padding: .4em 1em .4em 2.1em; }
444
+ .ui-button-text-icon-secondary .ui-button-text, .ui-button-text-icons .ui-button-text { padding: .4em 2.1em .4em 1em; }
445
+ .ui-button-text-icons .ui-button-text { padding-left: 2.1em; padding-right: 2.1em; }
446
+ /* no icon support for input elements, provide padding by default */
447
+ input.ui-button { padding: .4em 1em; }
448
+
449
+ /*button icon element(s) */
450
+ .ui-button-icon-only .ui-icon, .ui-button-text-icon-primary .ui-icon, .ui-button-text-icon-secondary .ui-icon, .ui-button-text-icons .ui-icon, .ui-button-icons-only .ui-icon { position: absolute; top: 50%; margin-top: -8px; }
451
+ .ui-button-icon-only .ui-icon { left: 50%; margin-left: -8px; }
452
+ .ui-button-text-icon-primary .ui-button-icon-primary, .ui-button-text-icons .ui-button-icon-primary, .ui-button-icons-only .ui-button-icon-primary { left: .5em; }
453
+ .ui-button-text-icon-secondary .ui-button-icon-secondary, .ui-button-text-icons .ui-button-icon-secondary, .ui-button-icons-only .ui-button-icon-secondary { right: .5em; }
454
+ .ui-button-text-icons .ui-button-icon-secondary, .ui-button-icons-only .ui-button-icon-secondary { right: .5em; }
455
+
456
+ /*button sets*/
457
+ .ui-buttonset { margin-right: 7px; }
458
+ .ui-buttonset .ui-button { margin-left: 0; margin-right: -.3em; }
459
+
460
+ /* workarounds */
461
+ button.ui-button::-moz-focus-inner { border: 0; padding: 0; } /* reset extra padding in Firefox */
462
+ /*!
463
+ * jQuery UI Dialog 1.8.22
464
+ *
465
+ * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
466
+ * Dual licensed under the MIT or GPL Version 2 licenses.
467
+ * http://jquery.org/license
468
+ *
469
+ * http://docs.jquery.com/UI/Dialog#theming
470
+ */
471
+ .ui-dialog { position: absolute; width: 300px; background-color:black; }
472
+ .ui-dialog .ui-dialog-titlebar { position: relative; float:right; }
473
+ .ui-dialog .ui-dialog-title { float: left; }
474
+ .ui-dialog .ui-dialog-titlebar-close { position: absolute; right: .3em; top: 50%; width: 19px; margin: -10px 0 0 0; padding: 1px; height: 18px; left:10px; top:-10px; }
475
+ .ui-dialog .ui-dialog-titlebar-close span { display: block; margin: 1px; }
476
+ .ui-dialog .ui-dialog-titlebar-close:hover, .ui-dialog .ui-dialog-titlebar-close:focus { padding: 0; }
477
+ .ui-dialog .ui-dialog-content { position: relative; border: 0; padding: 0px; background: none; overflow: hidden; zoom: 1; }
478
+ .ui-dialog .ui-dialog-buttonpane { text-align: left; border-width: 1px 0 0 0; background-image: none; margin: .5em 0 0 0; padding: .3em 1em .5em .4em; }
479
+ .ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset { float: right; }
480
+ .ui-dialog .ui-dialog-buttonpane button { margin: .5em .4em .5em 0; cursor: pointer; }
481
+ .ui-dialog .ui-resizable-se { width: 14px; height: 14px; right: 3px; bottom: 3px; }
482
+ .ui-draggable .ui-dialog-titlebar { }
483
+ /*!
484
+ * jQuery UI Slider 1.8.22
485
+ *
486
+ * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
487
+ * Dual licensed under the MIT or GPL Version 2 licenses.
488
+ * http://jquery.org/license
489
+ *
490
+ * http://docs.jquery.com/UI/Slider#theming
491
+ */
492
+ .ui-slider { position: relative; text-align: left; }
493
+ .ui-slider .ui-slider-handle { position: absolute; z-index: 2; width: 1.2em; height: 1.2em; cursor: default; }
494
+ .ui-slider .ui-slider-range { position: absolute; z-index: 1; font-size: .7em; display: block; border: 0; background-position: 0 0; }
495
+
496
+ .ui-slider-horizontal { height: .8em; }
497
+ .ui-slider-horizontal .ui-slider-handle { top: -.3em; margin-left: -.6em; }
498
+ .ui-slider-horizontal .ui-slider-range { top: 0; height: 100%; }
499
+ .ui-slider-horizontal .ui-slider-range-min { left: 0; }
500
+ .ui-slider-horizontal .ui-slider-range-max { right: 0; }
501
+
502
+ .ui-slider-vertical { width: .8em; height: 100px; }
503
+ .ui-slider-vertical .ui-slider-handle { left: -.3em; margin-left: 0; margin-bottom: -.6em; }
504
+ .ui-slider-vertical .ui-slider-range { left: 0; width: 100%; }
505
+ .ui-slider-vertical .ui-slider-range-min { bottom: 0; }
506
+ .ui-slider-vertical .ui-slider-range-max { top: 0; }/*!
507
+ * jQuery UI Tabs 1.8.22
508
+ *
509
+ * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
510
+ * Dual licensed under the MIT or GPL Version 2 licenses.
511
+ * http://jquery.org/license
512
+ *
513
+ * http://docs.jquery.com/UI/Tabs#theming
514
+ */
515
+ .ui-tabs { position: relative; padding: .2em; zoom: 1; } /* position: relative prevents IE scroll bug (element with position: relative inside container with overflow: auto appear as "fixed") */
516
+ .ui-tabs .ui-tabs-nav { margin: 0; padding: .2em .2em 0; }
517
+ .ui-tabs .ui-tabs-nav li { list-style: none; float: left; position: relative; top: 1px; margin: 0 .2em 1px 0; border-bottom: 0 !important; padding: 0; white-space: nowrap; }
518
+ .ui-tabs .ui-tabs-nav li a { float: left; padding: .5em 1em; text-decoration: none; }
519
+ .ui-tabs .ui-tabs-nav li.ui-tabs-selected { margin-bottom: 0; padding-bottom: 1px; }
520
+ .ui-tabs .ui-tabs-nav li.ui-tabs-selected a, .ui-tabs .ui-tabs-nav li.ui-state-disabled a, .ui-tabs .ui-tabs-nav li.ui-state-processing a { cursor: text; }
521
+ .ui-tabs .ui-tabs-nav li a, .ui-tabs.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-selected a { cursor: pointer; } /* first selector in group seems obsolete, but required to overcome bug in Opera applying cursor: text overall if defined elsewhere... */
522
+ .ui-tabs .ui-tabs-panel { display: block; border-width: 0; padding: 1em 1.4em; background: none; }
523
+ .ui-tabs .ui-tabs-hide { display: none !important; }
524
+ /*!
525
+ * jQuery UI Datepicker 1.8.22
526
+ *
527
+ * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
528
+ * Dual licensed under the MIT or GPL Version 2 licenses.
529
+ * http://jquery.org/license
530
+ *
531
+ * http://docs.jquery.com/UI/Datepicker#theming
532
+ */
533
+ .ui-datepicker { width: 17em; padding: .2em .2em 0; display: none; }
534
+ .ui-datepicker .ui-datepicker-header { position:relative; padding:.2em 0; }
535
+ .ui-datepicker .ui-datepicker-prev, .ui-datepicker .ui-datepicker-next { position:absolute; top: 2px; width: 1.8em; height: 1.8em; }
536
+ .ui-datepicker .ui-datepicker-prev-hover, .ui-datepicker .ui-datepicker-next-hover { top: 1px; }
537
+ .ui-datepicker .ui-datepicker-prev { left:2px; }
538
+ .ui-datepicker .ui-datepicker-next { right:2px; }
539
+ .ui-datepicker .ui-datepicker-prev-hover { left:1px; }
540
+ .ui-datepicker .ui-datepicker-next-hover { right:1px; }
541
+ .ui-datepicker .ui-datepicker-prev span, .ui-datepicker .ui-datepicker-next span { display: block; position: absolute; left: 50%; margin-left: -8px; top: 50%; margin-top: -8px; }
542
+ .ui-datepicker .ui-datepicker-title { margin: 0 2.3em; line-height: 1.8em; text-align: center; }
543
+ .ui-datepicker .ui-datepicker-title select { font-size:1em; margin:1px 0; }
544
+ .ui-datepicker select.ui-datepicker-month-year {width: 100%;}
545
+ .ui-datepicker select.ui-datepicker-month,
546
+ .ui-datepicker select.ui-datepicker-year { width: 49%;}
547
+ .ui-datepicker table {width: 100%; font-size: .9em; border-collapse: collapse; margin:0 0 .4em; }
548
+ .ui-datepicker th { padding: .7em .3em; text-align: center; font-weight: bold; border: 0; }
549
+ .ui-datepicker td { border: 0; padding: 1px; }
550
+ .ui-datepicker td span, .ui-datepicker td a { display: block; padding: .2em; text-align: right; text-decoration: none; }
551
+ .ui-datepicker .ui-datepicker-buttonpane { background-image: none; margin: .7em 0 0 0; padding:0 .2em; border-left: 0; border-right: 0; border-bottom: 0; }
552
+ .ui-datepicker .ui-datepicker-buttonpane button { float: right; margin: .5em .2em .4em; cursor: pointer; padding: .2em .6em .3em .6em; width:auto; overflow:visible; }
553
+ .ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current { float:left; }
554
+
555
+ /* with multiple calendars */
556
+ .ui-datepicker.ui-datepicker-multi { width:auto; }
557
+ .ui-datepicker-multi .ui-datepicker-group { float:left; }
558
+ .ui-datepicker-multi .ui-datepicker-group table { width:95%; margin:0 auto .4em; }
559
+ .ui-datepicker-multi-2 .ui-datepicker-group { width:50%; }
560
+ .ui-datepicker-multi-3 .ui-datepicker-group { width:33.3%; }
561
+ .ui-datepicker-multi-4 .ui-datepicker-group { width:25%; }
562
+ .ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header { border-left-width:0; }
563
+ .ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header { border-left-width:0; }
564
+ .ui-datepicker-multi .ui-datepicker-buttonpane { clear:left; }
565
+ .ui-datepicker-row-break { clear:both; width:100%; font-size:0em; }
566
+
567
+ /* RTL support */
568
+ .ui-datepicker-rtl { direction: rtl; }
569
+ .ui-datepicker-rtl .ui-datepicker-prev { right: 2px; left: auto; }
570
+ .ui-datepicker-rtl .ui-datepicker-next { left: 2px; right: auto; }
571
+ .ui-datepicker-rtl .ui-datepicker-prev:hover { right: 1px; left: auto; }
572
+ .ui-datepicker-rtl .ui-datepicker-next:hover { left: 1px; right: auto; }
573
+ .ui-datepicker-rtl .ui-datepicker-buttonpane { clear:right; }
574
+ .ui-datepicker-rtl .ui-datepicker-buttonpane button { float: left; }
575
+ .ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current { float:right; }
576
+ .ui-datepicker-rtl .ui-datepicker-group { float:right; }
577
+ .ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header { border-right-width:0; border-left-width:1px; }
578
+ .ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header { border-right-width:0; border-left-width:1px; }
579
+
580
+ /* IE6 IFRAME FIX (taken from datepicker 1.5.3 */
581
+ .ui-datepicker-cover {
582
+ position: absolute; /*must have*/
583
+ z-index: -1; /*must have*/
584
+ filter: mask(); /*must have*/
585
+ top: -4px; /*must have*/
586
+ left: -4px; /*must have*/
587
+ width: 200px; /*must have*/
588
+ height: 200px; /*must have*/
589
+ }/*!
590
+ * jQuery UI Progressbar 1.8.22
591
+ *
592
+ * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
593
+ * Dual licensed under the MIT or GPL Version 2 licenses.
594
+ * http://jquery.org/license
595
+ *
596
+ * http://docs.jquery.com/UI/Progressbar#theming
597
+ */
598
+ .ui-progressbar { height:2em; text-align: left; overflow: hidden; }
599
+ .ui-progressbar .ui-progressbar-value {margin: -1px; height:100%; }
css/video-embed-thumbnail-generator_admin.css ADDED
@@ -0,0 +1,275 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .meter, .meter_finished {
2
+ height: 14px;
3
+ width: 100px;
4
+ display: inline-block;
5
+ position: relative;
6
+ background: #e4e4e4;
7
+ -moz-border-radius: 4px;
8
+ -webkit-border-radius: 4px;
9
+ border-radius: 4px;
10
+ padding: 2px;
11
+ }
12
+
13
+ .meter > span {
14
+ text-align: right;
15
+ padding-right: 2px;
16
+ font-weight: bold;
17
+ vertical-align:top;
18
+ color: white;
19
+ font-size: 80%;
20
+ display: inline-block;
21
+ height: 100%;
22
+ -webkit-border-top-right-radius: 4px;
23
+ -webkit-border-bottom-right-radius: 4px;
24
+ -moz-border-radius-topright: 4px;
25
+ -moz-border-radius-bottomright: 4px;
26
+ border-top-right-radius: 4px;
27
+ border-bottom-right-radius: 4px;
28
+ -webkit-border-top-left-radius: 2px;
29
+ -webkit-border-bottom-left-radius: 2px;
30
+ -moz-border-radius-topleft: 2px;
31
+ -moz-border-radius-bottomleft: 2px;
32
+ border-top-left-radius: 2px;
33
+ border-bottom-left-radius: 2px;
34
+ background-color: rgb(41,140,186);
35
+ background-image: -webkit-gradient(
36
+ linear,
37
+ left bottom,
38
+ left top,
39
+ color-stop(0, rgb(41,140,186)),
40
+ color-stop(1, rgb(64,176,228))
41
+ );
42
+ background-image: -webkit-linear-gradient(
43
+ center bottom,
44
+ rgb(41,140,186) 37%,
45
+ rgb(64,176,228) 69%
46
+ );
47
+ background-image: -moz-linear-gradient(
48
+ center bottom,
49
+ rgb(41,140,186) 37%,
50
+ rgb(64,176,228) 69%
51
+ );
52
+ background-image: -ms-linear-gradient(
53
+ center bottom,
54
+ rgb(41,140,186) 37%,
55
+ rgb(64,176,228) 69%
56
+ );
57
+ background-image: -o-linear-gradient(
58
+ center bottom,
59
+ rgb(41,140,186) 37%,
60
+ rgb(64,176,228) 69%
61
+ );
62
+ position: relative;
63
+ overflow: hidden;
64
+ }
65
+
66
+ .kgvid_cancel_button {
67
+ -moz-box-shadow:inset 0px 1px 0px -1px #ffffff;
68
+ -webkit-box-shadow:inset 0px 1px 0px -1px #ffffff;
69
+ box-shadow:inset 0px 1px 0px -1px #ffffff;
70
+ background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #ededed), color-stop(1, #dfdfdf) );
71
+ background:-moz-linear-gradient( center top, #ededed 5%, #dfdfdf 100% );
72
+ filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ededed', endColorstr='#dfdfdf');
73
+ background-color:#ededed;
74
+ -moz-border-radius:5px;
75
+ -webkit-border-radius:5px;
76
+ border-radius:5px;
77
+ border:1px solid #dcdcdc;
78
+ display:inline-block;
79
+ color:#777777;
80
+ font-family:arial;
81
+ font-size:10px;
82
+ font-weight:bold;
83
+ padding:1px 3px 3px 3px;
84
+ margin-left:5px;
85
+ position:relative;
86
+ top:-1px;
87
+ text-decoration:none;
88
+ height:14px;
89
+ }.kgvid_cancel_button:hover {
90
+ background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #dfdfdf), color-stop(1, #ededed) );
91
+ background:-moz-linear-gradient( center top, #dfdfdf 5%, #ededed 100% );
92
+ filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#dfdfdf', endColorstr='#ededed');
93
+ background-color:#dfdfdf;
94
+ }.kgvid_cancel_button:active {
95
+ position:relative;
96
+ top:1px;
97
+ }
98
+ /* This imageless css button was generated by CSSButtonGenerator.com */
99
+
100
+ .meter_finished > span {
101
+ text-align: center;
102
+ font-weight: bold;
103
+ color: white;
104
+ font-size: 80%;
105
+ display: inline-block;
106
+ height: 100%;
107
+ -webkit-border-top-right-radius: 10px;
108
+ -webkit-border-bottom-right-radius: 10px;
109
+ -moz-border-radius-topright: 10px;
110
+ -moz-border-radius-bottomright: 10px;
111
+ border-top-right-radius: 10px;
112
+ border-bottom-right-radius: 10px;
113
+ -webkit-border-top-left-radius: 10px;
114
+ -webkit-border-bottom-left-radius: 10px;
115
+ -moz-border-radius-topleft: 10px;
116
+ -moz-border-radius-bottomleft: 10px;
117
+ border-top-left-radius: 10px;
118
+ border-bottom-left-radius: 10px;
119
+ background-color: rgb(41,140,186);
120
+ background-image: -webkit-gradient(
121
+ linear,
122
+ left bottom,
123
+ left top,
124
+ color-stop(0, rgb(41,140,186)),
125
+ color-stop(1, rgb(41,140,186))
126
+ );
127
+ background-image: -webkit-linear-gradient(
128
+ center bottom,
129
+ rgb(41,140,186) 37%,
130
+ rgb(41,140,186) 69%
131
+ );
132
+ background-image: -moz-linear-gradient(
133
+ center bottom,
134
+ rgb(41,140,186) 37%,
135
+ rgb(41,140,186) 69%
136
+ );
137
+ background-image: -ms-linear-gradient(
138
+ center bottom,
139
+ rgb(41,140,186) 37%,
140
+ rgb(41,140,186) 69%
141
+ );
142
+ background-image: -o-linear-gradient(
143
+ center bottom,
144
+ rgb(41,140,186) 37%,
145
+ rgb(41,140,186) 69%
146
+ );
147
+ -webkit-box-shadow:
148
+ inset 0 2px 9px rgba(255,255,255,0.3),
149
+ inset 0 -2px 6px rgba(0,0,0,0.4);
150
+ -moz-box-shadow:
151
+ inset 0 2px 9px rgba(255,255,255,0.3),
152
+ inset 0 -2px 6px rgba(0,0,0,0.4);
153
+ position: relative;
154
+ overflow: hidden;
155
+ }
156
+
157
+ div.kgvid_cancel_button input {
158
+ font-size: 1pt;
159
+ }
160
+
161
+ .compat-item .field {
162
+ width: 85%;
163
+ }
164
+
165
+ .compat-item .field input {
166
+ width: auto;
167
+ }
168
+
169
+ div.kgvid_thumbnail_box {
170
+ border-style:solid;
171
+ border-color:#ccc;
172
+ border-width:1px;
173
+ text-align:center;
174
+ margin-bottom:10px;
175
+ padding:5px;
176
+ }
177
+
178
+ div.kgvid_thumbnail_overlay {
179
+ width: 100%;
180
+ height:100%;
181
+ background: #fff;
182
+ opacity: 0.5;
183
+ filter: alpha(opacity = 50); /* required for opacity to work in IE */
184
+ }
185
+
186
+ div.kgvid_thumbnail_select {
187
+ text-align:center;
188
+ display:inline-block;
189
+ }
190
+
191
+ img.kgvid_thumbnail {
192
+ margin:2px;
193
+ }
194
+
195
+ .kgvid_embedselect {
196
+ border-left:2px solid #ccc;
197
+ display:inline;
198
+ padding-left:8px;
199
+ }
200
+
201
+ div.kgvid_cancel_button {
202
+ display:inline-block;
203
+ vertical-align:top;
204
+ margin-top:7px;
205
+ padding-left:5px;
206
+ }
207
+
208
+ .kgvid_tooltip {
209
+ color: #000000; outline: none;
210
+ cursor: help; text-decoration: none;
211
+ position: relative;
212
+ }
213
+
214
+ .kgvid_tooltip img {
215
+ width:20px;
216
+ height:20px;
217
+ background-image:url("../../../../wp-includes/images/wpicons.png");
218
+ background-position: -520px 0px;
219
+ position:relative;
220
+ top:6px;
221
+ }
222
+
223
+ .kgvid_tooltip span {
224
+ margin-left: -999em;
225
+ position: absolute;
226
+ color: #000000;
227
+ }
228
+
229
+ .kgvid_tooltip:hover span {
230
+ font-family: Calibri, Tahoma, Geneva, sans-serif;
231
+ position: absolute;
232
+ left: 1em;
233
+ top: 2em;
234
+ z-index: 99;
235
+ margin-left: 0;
236
+ width: 250px;
237
+ border-radius: 5px 5px;
238
+ -moz-border-radius: 5px;
239
+ -webkit-border-radius: 5px;
240
+ box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.1);
241
+ -webkit-box-shadow: 5px 5px rgba(0, 0, 0, 0.1);
242
+ -moz-box-shadow: 5px 5px rgba(0, 0, 0, 0.1);
243
+ }
244
+
245
+ .kgvid_tooltip:hover em {
246
+ font-family: Candara, Tahoma, Geneva, sans-serif;
247
+ font-size: 1.2em;
248
+ font-weight: bold;
249
+ display: block;
250
+ padding: 0.2em 0 0.6em 0;
251
+ }
252
+
253
+ .kgvid_tooltip_classic { padding: 0.8em 1em; background: #FFFFAA; border: 1px solid #FFAD33; }
254
+ .custom { padding: 0.5em 0.8em 0.8em 2em; }
255
+ * html a:hover { background: transparent; }
256
+
257
+ .widefat tr.currently_encoding {
258
+ background-color:#f3f3ff;
259
+ }
260
+
261
+ .widefat td.queue_encode_formats {
262
+ width:40%;
263
+ }
264
+
265
+ a.kgvid_delete-format {
266
+ color: #BC0B0B !important;
267
+ text-decoration: none;
268
+ margin-left: 15px;
269
+ display: block;
270
+ margin-bottom: -10px;
271
+ }
272
+
273
+ a.kgvid_delete-format:hover {
274
+ color: red !important;
275
+ }
images/AndroidPlay.png DELETED
Binary file
images/androidthumb.php DELETED
@@ -1,37 +0,0 @@
1
- <?php
2
-
3
- header('content-type: image/jpeg');
4
-
5
- function imagecopymerge_alpha($dst_im, $src_im, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h, $pct){
6
- $opacity=$pct;
7
- // getting the watermark width
8
- $w = imagesx($src_im);
9
- // getting the watermark height
10
- $h = imagesy($src_im);
11
-
12
- // creating a cut resource
13
- $cut = imagecreatetruecolor($src_w, $src_h);
14
- // copying that section of the background to the cut
15
- imagecopy($cut, $dst_im, 0, 0, $dst_x, $dst_y, $src_w, $src_h);
16
- // inverting the opacity
17
- $opacity = 100 - $opacity;
18
-
19
- // placing the watermark now
20
- imagecopy($cut, $src_im, 0, 0, $src_x, $src_y, $src_w, $src_h);
21
- imagecopymerge($dst_im, $cut, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h, $opacity);
22
- }
23
-
24
-
25
- $watermark = imagecreatefrompng('AndroidPlay.png');
26
- $watermark_width = imagesx($watermark);
27
- $watermark_height = imagesy($watermark);
28
- $image = imagecreatetruecolor($watermark_width, $watermark_height);
29
- $image = imagecreatefromjpeg($_GET['src']);
30
- $size = getimagesize($_GET['src']);
31
- $dest_x = $size[0] / 2 - ($watermark_width / 2) ;
32
- $dest_y = $size[1] / 2 - ($watermark_height / 2);
33
- imagecopymerge_alpha($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 0);
34
- imagejpeg($image);
35
- imagedestroy($image);
36
- imagedestroy($watermark);
37
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
images/nothumbnail.jpg ADDED
Binary file
js/kgvid_video_embed.js ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function kgvid_set_mp4_src(mp4_srcs) {
2
+
3
+ var player = _V_('video_'+mp4_srcs.id);
4
+
5
+ var support_1080 = false;
6
+ var support_720 = false;
7
+
8
+ if ( screen.width >= 1080 || screen.height >= 1080 ) { support_1080 = true; support_720 = true; }
9
+ else if ( screen.width >= 960 || screen.height >= 960 ) { support_720 = true; support_1080 = false; }
10
+ else if ( screen.width < 960 && screen.height < 960 ) { support_1080 = false; support_720 = false; }
11
+
12
+ if ( support_1080 == true ) {
13
+ if ( typeof(mp4_srcs.src_original) != undefined ) { }
14
+ else if ( typeof(mp4_srcs.src_1080) != undefined ) { player.src({ type: "video/mp4", src: mp4_srcs.src_1080 }); }
15
+ else if ( typeof(mp4_srcs.src_720) != undefined ) { player.src({ type: "video/mp4", src: mp4_srcs.src_720 }); }
16
+ }
17
+
18
+ if ( support_720 == true && support_1080 == false ) {
19
+ if ( typeof(mp4_srcs.src_720) != undefined ) { player.src({ type: "video/mp4", src: mp4_srcs.src_720 }); }
20
+ }
21
+
22
+ if ( support_720 == false && support_1080 == false ) {
23
+ if ( typeof(mp4_srcs.mobile) != undefined ) { player.src({ type: "video/mp4", src: mp4_srcs.src_mobile }); }
24
+ }
25
+ alert (support_720);
26
+ }
27
+
28
+ function kgvid_SetVideo(source, width, height) {
29
+ jQuery('#kgvid_GalleryVideo').attr('src', source);
30
+ jQuery('#kgvid_GalleryVideo').attr('width', parseInt(width)+20);
31
+ jQuery('#kgvid_GalleryVideo').attr('height', parseInt(height)+20);
32
+ jQuery('#kgvid_GalleryPlayerDiv').dialog("option", "width", parseInt(width)+30);
33
+ jQuery('#kgvid_GalleryPlayerDiv').closest('.ui-dialog').height(parseInt(height))
34
+ //jQuery('#kgvid_GalleryPlayerDiv').dialog("option", "height", parseInt(height)+30);
35
+ jQuery('#kgvid_GalleryPlayerDiv').dialog('open');
36
+ jQuery('.ui-widget-overlay').click(function () { $('#kgvid_GalleryPlayerDiv').dialog('close'); });
37
+ }
38
+
39
+ function kgvid_video_counter(id, plays, ends, event) {
40
+
41
+ //var player = _V_('video_'+id)
42
+ //if ( player.currentTime() > 1 ) { alert ("Count"); }
43
+ var changed = false;
44
+
45
+ if (plays != "not_countable" ) { //video is in the db
46
+ if ( document.getElementById(id+'_played').value == 'not_played' ) { plays++; changed = true; }
47
+ if ( event == "ended" ) { ends++; changed = true; }
48
+ if ( changed == true ) {
49
+ jQuery.post(ajax_object.ajaxurl, {
50
+ action: 'kgvid_count_play',
51
+ post_id: id,
52
+ video_plays: plays,
53
+ complete_views: ends
54
+ }, function(data) {
55
+ //alert(data);
56
+ });
57
+ }
58
+ }
59
+
60
+ document.getElementById(id+'_played').value = 'played';
61
+
62
+ }
js/kgvid_video_plugin_admin.js ADDED
@@ -0,0 +1,376 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function kgvid_disable_thumb_buttons(postID, event) {
2
+
3
+ if ( jQuery('.compat-item').length > 0 ) { //only do this in the new media modal, not attachment page in media library
4
+ if (event == "onblur") {
5
+ document.getElementById('attachments-'+postID+'-thumbgenerate').disabled = false;
6
+ document.getElementById('attachments-'+postID+'-thumbrandomize').disabled = false;
7
+ }
8
+ else {
9
+ document.getElementById('attachments-'+postID+'-thumbgenerate').disabled = true;
10
+ document.getElementById('attachments-'+postID+'-thumbrandomize').disabled = true;
11
+ }
12
+
13
+ if (event == "onchange") {
14
+ document.getElementById('attachments-'+postID+'-thumbgenerate').value = "Wait";
15
+ document.getElementById('attachments-'+postID+'-thumbrandomize').value = "Wait";
16
+ }
17
+ }
18
+ }
19
+
20
+ function kgvid_set_dimension(postID, valuetochange, currentvalue) {
21
+ var kgvid_aspect = (document.getElementsByName('attachments['+postID+'][kgflashmediaplayer-aspect]')[0].value);
22
+ var changeaspect = kgvid_aspect;
23
+ if (valuetochange == "width") { changeaspect = 1/kgvid_aspect; }
24
+ var changedvalue = Math.round(currentvalue*changeaspect);
25
+ if (document.getElementById('attachments-'+postID+'-kgflashmediaplayer-lockaspect').checked == true && changedvalue != 0) {
26
+ document.getElementById('attachments-'+postID+'-kgflashmediaplayer-'+valuetochange).value = changedvalue;
27
+ }
28
+ }
29
+
30
+ function kgvid_set_aspect(postID, checked) {
31
+ if (checked) { document.getElementsByName('attachments['+postID+'][kgflashmediaplayer-aspect]')[0].value = document.getElementById('attachments-'+postID+'-kgflashmediaplayer-height').value / document.getElementById('attachments-'+postID+'-kgflashmediaplayer-width').value;
32
+ }
33
+ }
34
+
35
+ function kgvid_generate_thumb(postID, buttonPushed) {
36
+
37
+ var kgflashmediaplayersecurity = document.getElementsByName('attachments[kgflashmediaplayer-security]')[0].value;
38
+ var attachmentURL = document.getElementsByName('attachments['+postID+'][kgflashmediaplayer-url]')[0].value;
39
+ var howmanythumbs = document.getElementById('attachments-'+postID+'-numberofthumbs').value;
40
+ var firstframethumb = document.getElementById('attachments-'+postID+'-firstframe').checked;
41
+ var posterurl = document.getElementsByName('attachments['+postID+'][kgflashmediaplayer-poster]')[0].value;
42
+ var specifictimecode = document.getElementsByName('attachments['+postID+'][thumbtime]')[0].value;
43
+ if (specifictimecode === "0") { specifictimecode = "firstframe"; }
44
+ var thumbnailplaceholderid = "#attachments-"+postID+"-thumbnailplaceholder";
45
+ var encodeplaceholderid = "#attachments-"+postID+"-encodeplaceholder";
46
+ var encodeprogressplaceholderid = "#attachments-"+postID+"-encodeprogressplaceholder";
47
+ var altembedselectid = "#attachments-"+postID+"-altembedselect";
48
+ var thumbnailboxID = "#attachments-"+postID+"-kgflashmediaplayer-thumbnailbox";
49
+ var thumbnailboxoverlayID = "#attachments-"+postID+"-kgflashmediaplayer-thumbnailboxoverlay";
50
+ var cancelthumbdivID = '#attachments-'+postID+'-kgflashmediaplayer-cancelthumbsdiv';
51
+ var widthID = 'attachments-'+postID+'-kgflashmediaplayer-width';
52
+ var heightID = 'attachments-'+postID+'-kgflashmediaplayer-height';
53
+ var maxwidthID = 'attachments['+postID+'][kgflashmediaplayer-maxwidth]';
54
+ var maxheightID = 'attachments['+postID+'][kgflashmediaplayer-maxheight]';
55
+ var i=1;
56
+ var increaser = 0;
57
+ var iincreaser = 0;
58
+
59
+ var page = "attachment";
60
+ var document_url = document.URL;
61
+ var page_check = /[?&]page=([^&]+)/i;
62
+ var match = page_check.exec(document_url);
63
+ if (match != null) {
64
+ page = "queue";
65
+ }
66
+
67
+ var formats = new Array("1080", "720", "mobile", "ogg", "webm");
68
+ var kgvid_encode = new Object();
69
+ for ( var key in formats ) {
70
+ kgvid_encode[formats[key]] = "";
71
+ if ( jQuery('#attachments-'+postID+'-kgflashmediaplayer-encode'+formats[key]).length > 0) {
72
+ kgvid_encode[formats[key]] = document.getElementById('attachments-'+postID+'-kgflashmediaplayer-encode'+formats[key]).checked;
73
+ }
74
+ }
75
+ JSON.stringify(kgvid_encode);
76
+
77
+ if (buttonPushed == "generate" || buttonPushed == "random" ) {
78
+ actionName = "generate";
79
+ if (specifictimecode != 0 ) { howmanythumbs = 1; }
80
+ }
81
+ else {
82
+ actionName = buttonPushed;
83
+ howmanythumbs = 1;
84
+ }
85
+
86
+ if (buttonPushed != "enqueue") {
87
+
88
+ jQuery(thumbnailplaceholderid).empty();
89
+ jQuery(thumbnailplaceholderid).append('<strong>Choose Thumbnail: </strong><div style="display:inline-block;" id="attachments-'+postID+'-kgflashmediaplayer-cancelthumbsdiv" name="attachments-'+postID+'-kgflashmediaplayer-cancelthumbsdiv"> <input type="button" id="attachments-'+postID+'-kgflashmediaplayer-cancelencode" class="button-secondary" value="Cancel Generating" name="attachments-'+postID+'-cancelencode" onclick="kgvid_cancel_thumbs(\''+postID+'\');"></div><div id="attachments-'+postID+'-kgflashmediaplayer-thumbnailboxoverlay" name="attachments-'+postID+'-kgflashmediaplayer-thumbnailboxoverlay" class="kgvid_thumbnail_overlay"><div name="attachments-'+postID+'-kgflashmediaplayer-thumbnailbox" id="attachments-'+postID+'-kgflashmediaplayer-thumbnailbox" class="kgvid_thumbnail_box"></div></div>');
90
+ }
91
+
92
+ if (buttonPushed == "enqueue") {
93
+ jQuery(encodeplaceholderid).empty();
94
+ jQuery(encodeprogressplaceholderid).empty();
95
+ jQuery(encodeplaceholderid).append('<strong>Loading...</strong>');
96
+ }
97
+
98
+ function kgvid_do_post() {
99
+
100
+ iincreaser = i + increaser;
101
+
102
+ jQuery.post(ajaxurl, { action:"kgvid_callffmpeg", security: kgflashmediaplayersecurity, movieurl: attachmentURL, numberofthumbs: howmanythumbs, thumbnumber:i, thumbnumberplusincreaser:iincreaser, ffmpeg_action: actionName, encodeformats: kgvid_encode, attachmentID: postID, generate_button: buttonPushed, thumbtimecode: specifictimecode, dofirstframe: firstframethumb, poster: posterurl }, function(data) {
103
+
104
+ if (actionName == "generate") {
105
+ kgthumbnailTimeout = jQuery(thumbnailplaceholderid).data("kgthumbnailTimeouts") || null;
106
+ jQuery(thumbnailboxID).append(data.thumbnaildisplaycode);
107
+ var thumbnailselectID = "#attachments-"+postID+"-thumb"+i;
108
+ jQuery(thumbnailselectID).css({display:"none"});
109
+ jQuery(thumbnailselectID).animate({opacity: 'toggle', height: 'toggle', width: 'toggle'}, 1000);
110
+ if (data.lastthumbnumber == "break" || (kgthumbnailTimeout == null && i != 1) ) { i = parseInt(howmanythumbs) + 1; }
111
+ else { i = parseInt(data.lastthumbnumber); }
112
+ increaser++;
113
+ if ( i <= howmanythumbs ) {
114
+ if ( kgthumbnailTimeout == null ) { kgthumbnailTimeout = new Array(); }
115
+ kgthumbnailTimeout[i] = setTimeout(function(){
116
+ //jQuery(thumbnailplaceholderid).data("kgthumbnailTimeout", null);
117
+ kgvid_do_post();
118
+ }, 750);
119
+ jQuery(thumbnailplaceholderid).data("kgthumbnailTimeouts", kgthumbnailTimeout);
120
+ }
121
+ else {
122
+ jQuery(thumbnailboxoverlayID).fadeTo(2000, 1);
123
+ jQuery(cancelthumbdivID).animate({opacity: 0}, 500);
124
+ jQuery(thumbnailplaceholderid).data("kgthumbnailTimeouts", null);
125
+ }
126
+
127
+ kgvid_aspect = data.movie_height/data.movie_width;
128
+ document.getElementsByName('attachments['+postID+'][kgflashmediaplayer-aspect]')[0].value = kgvid_aspect;
129
+ if (parseInt(data.movie_width) < parseInt(document.getElementsByName(maxwidthID)[0].value) ) { document.getElementById(widthID).value = data.movie_width; }
130
+ else { document.getElementById(widthID).value = document.getElementsByName(maxwidthID)[0].value; }
131
+ if (parseInt(data.movie_width) > parseInt(document.getElementsByName(maxwidthID)[0].value) ) { document.getElementById(heightID).value = Math.round(kgvid_aspect*parseInt(document.getElementsByName(maxwidthID)[0].value)); }
132
+ else { document.getElementById(heightID).value = data.movie_height; }
133
+ jQuery.post( ajaxurl , { action:"kgvid_schedule_cleanup_generated_files", security:kgflashmediaplayersecurity, thumbs:"true" } );
134
+ kgvid_redraw_encode_checkboxes(attachmentURL, postID, page);
135
+ }//if thumbnail button pressed
136
+
137
+ if (buttonPushed == "enqueue") {
138
+ jQuery(encodeplaceholderid).empty();
139
+ jQuery(encodeprogressplaceholderid).empty();
140
+ jQuery(encodeplaceholderid).append(data.embed_display);
141
+ jQuery.post( ajaxurl , { action:"kgvid_ajax_encode_videos", security:kgflashmediaplayersecurity } , function(data) {
142
+ jQuery(encodeprogressplaceholderid).empty();
143
+ jQuery(encodeplaceholderid).append(data.embed_display);
144
+ kgvid_redraw_encode_checkboxes(attachmentURL, postID, page);
145
+ }, "json");
146
+ }//if encode button pressed
147
+ }, "json");
148
+
149
+ }// end kgvid_do_post function
150
+
151
+ kgvid_do_post(); //actually call the loop
152
+ }
153
+
154
+ function kgvid_hide_standard_wordpress_display_settings(postID) {
155
+ if ( jQuery('#attachments['+postID+'][kgflashmediaplayer-embed]').value != "WordPress Default" ) {
156
+ jQuery('.attachment-display-settings').hide();
157
+ }
158
+ }
159
+
160
+ function kgvid_set_singleurl() {
161
+
162
+ var url = document.getElementById('attachments-singleurl-kgflashmediaplayer-url').value;
163
+ var oldbasename = jQuery('#kgflashmediaplayer-table').data("kgvid_attachment_id") || "singleurl";
164
+
165
+ var validExtensions = new Array(".flv", ".f4v", ".mp4", ".mov", ".m4v", ".webm", ".ogg", ".ogv");
166
+ var extensionExists = false;
167
+ for (var i = 0; i < validExtensions.length; i++) {
168
+ if (url.indexOf(validExtensions[i]) != -1) {
169
+ extensionExists = true;
170
+ if ( document.getElementById('attachments-'+oldbasename+'-kgflashmediaplayer-ffmpegexists').value === "true" ) {
171
+ document.getElementById('attachments-'+oldbasename+'-thumbgenerate').disabled = false;
172
+ document.getElementById('attachments-'+oldbasename+'-thumbgenerate').title = "";
173
+ document.getElementById('attachments-'+oldbasename+'-thumbrandomize').disabled = false;
174
+ document.getElementById('attachments-'+oldbasename+'-thumbrandomize').title = "";
175
+ document.getElementById('attachments-'+oldbasename+'-kgflashmediaplayer-encode').disabled = false;
176
+ document.getElementById('attachments-'+oldbasename+'-kgflashmediaplayer-encode').title = "";
177
+ document.getElementById('insertonlybutton').disabled = false;
178
+ document.getElementById('insertonlybutton').title = "";
179
+ var basename = "singleurl_"+url.replace(/^.*\/|\.[^.]*$/g, '');
180
+ //jQuery('#kgflashmediaplayer-table :input').each(function(){
181
+ jQuery('#kgvid-form :input').each(function(){
182
+ var newid = jQuery(this).attr("id").replace(oldbasename, basename);
183
+ jQuery(this).attr("id", newid);
184
+ if ( jQuery(this).attr("name") ) {
185
+ var newname = jQuery(this).attr("name").replace(oldbasename, basename);
186
+ jQuery(this).attr("name", newname);
187
+ }
188
+ });
189
+ jQuery('#kgflashmediaplayer-table').data("kgvid_attachment_id", basename);
190
+ document.getElementById('attachments-'+oldbasename+'-kgflashmediaplayer-encodeboxes').id = 'attachments-'+basename+'-kgflashmediaplayer-encodeboxes';
191
+ document.getElementById('attachments-'+oldbasename+'-thumbnailplaceholder').id = 'attachments-'+basename+'-thumbnailplaceholder';
192
+ jQuery('#attachments-'+basename+'-thumbgenerate').replaceWith('<input type="button" id="attachments-'+basename+'-thumbgenerate" class="button-secondary" value="Generate" name="thumbgenerate" onclick="kgvid_generate_thumb(\''+basename+'\', \'generate\');" >');
193
+ jQuery('#attachments-'+basename+'-thumbrandomize').replaceWith('<input type="button" id="attachments-'+basename+'-thumbgenerate" class="button-secondary" value="Randomize" name="thumbgenerate" onclick="kgvid_generate_thumb(\''+basename+'\', \'random\');" >');
194
+ }
195
+ break;
196
+ }
197
+ }
198
+ if (extensionExists == false) {
199
+ if ( url != "" ) { alert("Please enter a URL that points to a valid video file. Video sharing sites are not supported by this plugin.\nTo embed from YouTube, Vimeo, etc, just paste the link directly into the post window and WordPress will handle the rest."); }
200
+ document.getElementById('attachments-'+oldbasename+'-thumbgenerate').disabled = true;
201
+ document.getElementById('attachments-'+oldbasename+'-thumbgenerate').title = "Please enter a valid video URL";
202
+ document.getElementById('attachments-'+oldbasename+'-thumbrandomize').disabled = true;
203
+ document.getElementById('attachments-'+oldbasename+'-thumbrandomize').title = "Please enter a valid video URL";
204
+ document.getElementById('attachments-'+oldbasename+'-kgflashmediaplayer-encode').disabled = true;
205
+ document.getElementById('attachments-'+oldbasename+'-kgflashmediaplayer-encode').title = "Please enter a valid video URL";
206
+ document.getElementById('insertonlybutton').disabled = true;
207
+ document.getElementById('insertonlybutton').title = "Please enter a valid video URL";
208
+ basename = "singleurl";
209
+ }
210
+ //console.log(basename);
211
+ kgvid_redraw_encode_checkboxes(url, basename, 'attachment');
212
+ }
213
+
214
+ function kgvid_insert_shortcode() {
215
+
216
+ var kgflashmediaplayersecurity = document.getElementsByName('attachments[kgflashmediaplayer-security]')[0].value;
217
+ var basename = jQuery('#kgflashmediaplayer-table').data("kgvid_attachment_id") || "singleurl";
218
+ var url = document.getElementById('attachments-'+basename+'-kgflashmediaplayer-url').value;
219
+ var posterurl = document.getElementById('attachments-'+basename+'-kgflashmediaplayer-poster').value;
220
+
221
+ var iframe_url = document.URL;
222
+ var id_check = /[?&]post_id=([^&]+)/i;
223
+ var match = id_check.exec(iframe_url);
224
+ if (match != null) {
225
+ postid = match[1];
226
+ } else {
227
+ postid = "";
228
+ }
229
+
230
+ jQuery.post(ajaxurl, { action:'kgvid_callffmpeg', security: kgflashmediaplayersecurity, attachmentID: basename, movieurl: url, ffmpeg_action:'submit', poster: posterurl, post_id: postid }, function(data) {
231
+ //jQuery('attachments-singleurl-thumbnailplaceholder').empty();
232
+ }, "json" );
233
+
234
+ var shortcode = "";
235
+ if (document.getElementById('videotitle').value != "") {
236
+ var titlecode = unescape(document.getElementsByName('attachments['+basename+'][kgflashmediaplayer-titlecode]')[0].value);
237
+ titlecode=titlecode.replace(/\\'/g,'\'');
238
+ titlecode=titlecode.replace(/\\"/g,'"');
239
+ titlecode=titlecode.replace(/\\0/g,'\0');
240
+ titlecode=titlecode.replace(/\\\\/g,'\\');
241
+ if ( titlecode.substr(0,1) != '<' ) { titlecode = '<'+titlecode; }
242
+ if ( titlecode.substr(-1,1) != '>' ) { titlecode = titlecode+'>'; }
243
+ var endtitlecode = titlecode.replace('<', '</');
244
+ endtitlecode = endtitlecode.split(' ');
245
+ endtitlecode = endtitlecode[0];
246
+ if ( endtitlecode.substr(-1,1) != '>' ) { endtitlecode = endtitlecode+'>'; }
247
+ shortcode += titlecode + document.getElementById('videotitle').value + endtitlecode + '<br />';
248
+ }
249
+ if (url !="") {
250
+ shortcode += ' [KGVID';
251
+ if (document.getElementById('attachments-'+basename+'-kgflashmediaplayer-poster').value !="") { shortcode += ' poster="' + document.getElementById('attachments-'+basename+'-kgflashmediaplayer-poster').value + '"'; }
252
+ if (document.getElementById('attachments-'+basename+'-kgflashmediaplayer-width').value !="") { shortcode += ' width="' + document.getElementById('attachments-'+basename+'-kgflashmediaplayer-width').value + '"'; }
253
+ if (document.getElementById('attachments-'+basename+'-kgflashmediaplayer-height').value !="") { shortcode += ' height="' + document.getElementById('attachments-'+basename+'-kgflashmediaplayer-height').value + '"'; }
254
+ shortcode += ']' + url + '[/KGVID] '; }
255
+ if (document.getElementById('downloadlink').checked) { shortcode += '<br /><a href="' + document.getElementById('attachments-'+basename+'-kgflashmediaplayer-url').value + '">Right-click or ctrl-click this link to download</a>'; }
256
+
257
+ parent.send_to_editor(shortcode);
258
+ }
259
+
260
+ function kgvid_cancel_encode(kgvid_pid, postID, video_key, format) {
261
+
262
+ var kgflashmediaplayersecurity = document.getElementsByName('attachments[kgflashmediaplayer-security]')[0].value;
263
+ //var cancelbuttonID = '#attachments-'+postID+'-kgflashmediaplayer-cancelencode';
264
+
265
+ //jQuery(cancelbuttonID).empty();
266
+ //jQuery(cancelbuttonID).append("<em>Canceling...</em>");
267
+ jQuery('#attachments-'+postID+'-kgflashmediaplayer-meta'+format).empty();
268
+ jQuery('#attachments-'+postID+'-kgflashmediaplayer-meta'+format).append('<strong>Canceling</strong>');
269
+ jQuery.post(ajaxurl, { action:"kgvid_cancel_encode", security: kgflashmediaplayersecurity, kgvid_pid: kgvid_pid, video_key: video_key, format: format } );
270
+
271
+ }
272
+
273
+ function kgvid_delete_video(movieurl, postID, format) {
274
+
275
+ var delete_for_sure = confirm("You are about to permanently delete the encoded video.\n 'Cancel' to stop, 'OK' to delete.");
276
+
277
+ if ( delete_for_sure == true ) {
278
+
279
+ jQuery('#attachments-'+postID+'-kgflashmediaplayer-encode'+format).removeAttr('disabled');
280
+ jQuery('#attachments-'+postID+'-kgflashmediaplayer-encode').removeAttr('disabled');
281
+ jQuery('#attachments-'+postID+'-kgflashmediaplayer-encode').css('display', 'inline');
282
+ jQuery('#attachments-'+postID+'-kgflashmediaplayer-meta'+format).empty();
283
+ jQuery('#attachments-'+postID+'-kgflashmediaplayer-meta'+format).append('<strong>Deleted</strong>');
284
+ var kgflashmediaplayersecurity = document.getElementsByName('attachments[kgflashmediaplayer-security]')[0].value;
285
+
286
+ jQuery.post(ajaxurl, { action: "kgvid_delete_video", security: kgflashmediaplayersecurity, movieurl: movieurl, postid: postID, format: format }, function(data) {
287
+ //document.getElementById('attachments-'+postID+'-kgflashmediaplayer-encode'+format).checked = true;
288
+ //document.getElementById('attachments-'+postID+'-kgflashmediaplayer-encode'+format).disabled = false;
289
+ //document.getElementById('attachments-'+postID+'-kgflashmediaplayer-encode').disabled = false;
290
+ jQuery('#attachments-'+postID+'-kgflashmediaplayer-encode'+format).change();
291
+ }, "json" );
292
+
293
+ }
294
+ }
295
+
296
+ function kgvid_cancel_thumbs(postID) {
297
+ var thumbnailplaceholderid = "#attachments-"+postID+"-thumbnailplaceholder";
298
+ var thumbnailboxoverlayID = "#attachments-"+postID+"-kgflashmediaplayer-thumbnailboxoverlay";
299
+ var cancelthumbdivID = '#attachments-'+postID+'-kgflashmediaplayer-cancelthumbsdiv';
300
+ var kgthumbnailTimeout = jQuery(thumbnailplaceholderid).data("kgthumbnailTimeouts");
301
+
302
+ for( key in kgthumbnailTimeout ){ clearTimeout(kgthumbnailTimeout[key]); }
303
+
304
+ jQuery(thumbnailplaceholderid).data("kgthumbnailTimeouts", null);
305
+ jQuery(thumbnailboxoverlayID).fadeTo(2000, 1);
306
+ jQuery(cancelthumbdivID).animate({opacity: 0}, 500);
307
+ jQuery(cancelthumbdivID).remove;
308
+ }
309
+
310
+ function kgvid_redraw_encode_checkboxes(movieurl, postID, page) {
311
+ var kgflashmediaplayersecurity = document.getElementsByName('attachments[kgflashmediaplayer-security]')[0].value;
312
+
313
+ var formats = new Array("1080", "720", "mobile", "ogg", "webm");
314
+ var kgvid_encode = new Object();
315
+ for ( var key in formats ) {
316
+ kgvid_encode[formats[key]] = "";
317
+ if ( jQuery('#attachments-'+postID+'-kgflashmediaplayer-encode'+formats[key]).length > 0) {
318
+ kgvid_encode[formats[key]] = document.getElementById('attachments-'+postID+'-kgflashmediaplayer-encode'+formats[key]).checked;
319
+ }
320
+ }
321
+ JSON.stringify(kgvid_encode);
322
+
323
+ jQuery.post(ajaxurl, { action:"kgvid_generate_encode_checkboxes", security: kgflashmediaplayersecurity, movieurl: movieurl, post_id: postID, page: page, encodeformats: kgvid_encode }, function(data) {
324
+ jQuery('#attachments-'+postID+'-kgflashmediaplayer-encodeboxes').empty();
325
+ jQuery('#attachments-'+postID+'-kgflashmediaplayer-encodeboxes').append(data.embed_display);
326
+ if ( page == "queue" && data.embed_display.indexOf('Elapsed') >= 0) {
327
+ jQuery('tr.currently_encoding').removeClass('currently_encoding');
328
+ jQuery('[id^=clear]').css("display", "block");
329
+ jQuery('#clear_'+postID).css("display", "none");
330
+ jQuery('#tr_'+postID).addClass('currently_encoding');
331
+ }
332
+ }, "json" );
333
+ }
334
+
335
+ function kgvid_encode_queue(action, order) {
336
+
337
+ var kgflashmediaplayersecurity = document.getElementsByName('attachments[kgflashmediaplayer-security]')[0].value;
338
+
339
+ var CheckboxTimeout = jQuery('#wpwrap').data("KGVIDCheckboxTimeout") || null;
340
+ if ( CheckboxTimeout ) { clearTimeout(CheckboxTimeout); }
341
+
342
+ if ( action == "delete" ) {
343
+ jQuery.post(ajaxurl, { action:"kgvid_clear_queue_entry", security: kgflashmediaplayersecurity, index: order }, function(data) {
344
+ jQuery('table.widefat > tbody').replaceWith("<tbody class='rows'>"+data+"</tbody>");
345
+ }, "html" );
346
+ }
347
+
348
+ if ( action == "clear_completed" ) {
349
+ jQuery.post(ajaxurl, { action:"kgvid_clear_completed_queue", security: kgflashmediaplayersecurity }, function(data) {
350
+ jQuery('table.widefat > tbody').replaceWith("<tbody class='rows'>"+data+"</tbody>");
351
+ }, "html" );
352
+ }
353
+
354
+ }
355
+
356
+ function kgvid_hide_plugin_settings(selected_option) {
357
+ if (selected_option == "Video.js") {
358
+ jQuery("table:contains(End of video image)").hide();
359
+ jQuery("h3:contains(The following options will only affect Flash playback)").hide();
360
+ jQuery("tr:contains(Skin Class)").show();
361
+ }
362
+ if (selected_option == "Strobe Media Playback") {
363
+ jQuery("table:contains(End of video image)").show();
364
+ jQuery("h3:contains(The following options will only affect Flash playback)").show();
365
+ jQuery("tr:contains(Skin Class)").hide();
366
+ }
367
+ }
368
+
369
+ function kgvid_hide_ffmpeg_settings(video_app) {
370
+ if (video_app == "ffmpeg") {
371
+ jQuery("tr:contains(FFMPEG Options)").show();
372
+ }
373
+ if (video_app == "avconv") {
374
+ jQuery("tr:contains(FFMPEG Options)").hide();
375
+ }
376
+ }
kg_callffmpeg.php DELETED
@@ -1,386 +0,0 @@
1
- <?php
2
- global $ffmpegPath;
3
- $ffmpegPath = get_option('wp_FMP_ffmpeg')."/ffmpeg";
4
- $mobile_res = get_option('wp_FMP_mobile_res');
5
- $uploads = wp_upload_dir();
6
- if (isset($_POST['encodemobile'])) { $encodemobile = $_POST['encodemobile']; }
7
- if (isset($_POST['encodeogg'])) { $encodeogg = $_POST['encodeogg']; }
8
- if (isset($_POST['encodewebm'])) { $encodewebm = $_POST['encodewebm']; }
9
- if (isset($_POST['movieurl'])) { $movieurl = $_POST['movieurl']; }
10
- if (isset($_POST['numberofthumbs'])) { $numberofthumbs = $_POST['numberofthumbs']; }
11
- if (isset($_POST['thumbnumber'])) { $i = $_POST['thumbnumber']; }
12
- if (isset($_POST['thumbnumberplusincreaser'])) { $iincreaser = $_POST['thumbnumberplusincreaser']; }
13
- if (isset($_POST['ffmpeg_action'])) { $action = $_POST['ffmpeg_action']; }
14
- if (isset($_POST['poster'])) { $poster = $_POST['poster']; }
15
- if (isset($_POST['attachmentID'])) { $postID = $_POST['attachmentID']; }
16
- if (isset($_POST['thumbtimecode'])) { $thumbtimecode = $_POST['thumbtimecode']; }
17
- if (isset($_POST['dofirstframe'])) { $dofirstframe = $_POST['dofirstframe']; }
18
- if (isset($_POST['generate_button'])) { $generate_button = $_POST['generate_button']; }
19
-
20
- if ($postID != "singleurl") { $moviefilepath = get_attached_file($postID); }
21
- else { $moviefilepath = str_replace(" ", "%20", $movieurl); }
22
- $movie_extension = pathinfo(parse_url($movieurl, PHP_URL_PATH), PATHINFO_EXTENSION);
23
- $moviefilebasename = basename($movieurl,'.'.$movie_extension);
24
- $thumbnailfilebase = $uploads['url']."/thumb_tmp/".$moviefilebasename;
25
-
26
-
27
- class Process{
28
- private $pid;
29
- private $command;
30
-
31
- public function __construct($cl=false){
32
- if ($cl != false){
33
- $this->command = $cl;
34
- $this->runCom();
35
- }
36
- }
37
- private function runCom(){
38
-
39
- //$command = 'nohup '.$this->command.' > /dev/null 2>&1 & echo $!'; //this is the original command
40
-
41
- $sys = strtoupper(PHP_OS); // Get OS Name
42
- if(substr($sys,0,3) == "WIN") {
43
- $command = $this->command;
44
- $this->OS = "windows";
45
- } //exec this way if it's Windows
46
-
47
- else {
48
- $command = 'nohup nice '.$this->command;
49
- $this->OS = "linux";
50
- }
51
-
52
- exec($command ,$op);
53
- $this->output = $op;
54
- if(substr($sys,0,3) != "WIN") { $this->pid = (int)$op[0]; }
55
- }
56
-
57
- public function setPid($pid){
58
- $this->pid = $pid;
59
- }
60
-
61
- public function getPid(){
62
- return $this->pid;
63
- }
64
-
65
- public function status(){
66
- $command = 'ps -p '.$this->pid;
67
- exec($command,$op);
68
- if (!isset($op[1]))return false;
69
- else return true;
70
- }
71
-
72
- public function start(){
73
- if ($this->command != '')$this->runCom();
74
- else return true;
75
- }
76
-
77
- public function stop(){
78
- $command = 'kill '.$this->pid;
79
- exec($command);
80
- if ($this->status() == false)return true;
81
- else return false;
82
- }
83
- }// class Process
84
-
85
-
86
- /**
87
- * Get the dimensions of a video file
88
- *
89
- * @param unknown_type $video
90
- * @return array(width,height)
91
- * @author Jamie Scott
92
- */
93
- function get_video_dimensions($video = false) {
94
- global $ffmpegPath;
95
-
96
- $command = $ffmpegPath . ' -i "' . $video . '" -vstats 2>&1';
97
-
98
- exec ( $command, $output );
99
- $lastline = end($output);
100
- $lastline = prev($output)."<br />".$lastline;
101
- $output = implode("\n", $output);
102
-
103
- $result = ereg ( '[0-9]?[0-9][0-9][0-9]x[0-9][0-9][0-9][0-9]?', $output, $regs );
104
-
105
- if (isset ( $regs [0] )) {
106
- $vals = (explode ( 'x', $regs [0] ));
107
- $width = $vals [0] ? $vals [0] : null;
108
- $height = $vals [1] ? $vals [1] : null;
109
- preg_match('/Duration: (.*?),/', $output, $matches);
110
- $duration = $matches[1];
111
- preg_match('/configuration: (.*?)\n/', $output, $matches);
112
- $configuration = $matches[1];
113
- preg_match('/rotate : (.*?)\n/', $output, $matches);
114
- if ( array_key_exists(1, $matches) == true ) { $rotate = $matches[1]; }
115
- else $rotate = "0";
116
- return array ('width' => $width, 'height' => $height, 'duration' => $duration, 'configuration' => $configuration, 'rotate' => $rotate, 'worked'=>true );
117
- } else {
118
- return array ('output'=>$lastline, 'worked'=>false);
119
- }
120
-
121
- }
122
-
123
- if ($action == "generate" || $action == "encode" ) {
124
-
125
- //exec($ffmpegPath.' /dev/null 2>&1', $output, $returnvalue); //attempt to execute FFMPEG
126
- $ffmpeg_info = kg_check_ffmpeg_exists();
127
-
128
- if ( $ffmpeg_info['ffmpeg_exists'] == true ) { //if FFMPEG executed
129
-
130
- $movie_info = get_video_dimensions($moviefilepath);
131
-
132
- if ($movie_info['worked'] == true) { //if FFMPEG was able to open the file
133
-
134
- $movie_duration_hours = intval(substr($movie_info['duration'], -11, 2));
135
- $movie_duration_minutes = intval(substr($movie_info['duration'], -8, 2));
136
- $movie_duration_seconds = intval(substr($movie_info['duration'], -5, 2));
137
- $movie_duration_seconds = ($movie_duration_hours * 60 * 60) + ($movie_duration_minutes * 60) + $movie_duration_seconds;
138
- $movie_width = $movie_info['width'];
139
- $movie_height = $movie_info['height'];
140
-
141
- switch ($movie_info['rotate']) {
142
- case "90": $movie_rotate = '-vf "transpose=1"'; break;
143
- case "180": $movie_rotate = '-vf "hflip,vflip"'; break;
144
- case "270": $movie_rotate = '-vf "transpose=2"'; break;
145
- default: $movie_rotate = ""; break;
146
- }
147
-
148
- if ($action == "generate") {
149
-
150
- if (!file_exists($uploads['path'].'/thumb_tmp')) { mkdir($uploads['path'].'/thumb_tmp'); }
151
-
152
- $thumbnailheight = strval(round(floatval($movie_height) / floatval($movie_width) * 200));
153
-
154
- switch ($movie_info['rotate']) { //if it's a sideways iPhone video
155
- case "90";
156
- case "270": $thumbnailheight = strval(round(floatval($movie_width) / floatval($movie_height) * 200));
157
- }
158
-
159
- $jpgpath = $uploads['path']."/thumb_tmp/";
160
-
161
- $movieoffset = round(($movie_duration_seconds * $iincreaser) / ($numberofthumbs * 2));
162
-
163
- if ($generate_button == "random") { //adjust offset random amount
164
- $movieoffset = $movieoffset - rand(0, round($movie_duration_seconds / $numberofthumbs));
165
- if ($movieoffset < 0) { $movieoffset = "0"; }
166
- }
167
-
168
- if ($thumbtimecode) { //if a specific thumbnail timecode is set
169
- if ($thumbtimecode == "firstframe") { $thumbtimecode = "0"; }
170
- $timecode_array = explode(":", $thumbtimecode);
171
- $timecode_array = array_reverse($timecode_array);
172
- $thumbtimecode = $timecode_array[0] + ($timecode_array[1] * 60) + ($timecode_array[2] * 3600);
173
- $movieoffset = $thumbtimecode;
174
- $i = $numberofthumbs + 1;
175
- }
176
-
177
- if ($dofirstframe == "true" && $i == 1) {
178
- $movieoffset = "0";
179
- }
180
-
181
- $thumbnailfilename[$i] = $jpgpath.$moviefilebasename."_thumb".$i.".jpg";
182
- $thumbnailfilename[$i] = str_replace(" ", "_", $thumbnailfilename[$i]);
183
- $ffmpeg_options = '-y -ss '.$movieoffset.' -i "'.$moviefilepath.'" '.$movie_rotate.' -vframes 1 "'.$thumbnailfilename[$i].'"';
184
- $thumbnailurl = $thumbnailfilebase."_thumb".$i.'.jpg';
185
- $thumbnailurl = str_replace(" ", "_", $thumbnailurl);
186
-
187
- exec($ffmpegPath." ".$ffmpeg_options);
188
-
189
- if (floatval($movieoffset) > 60) {
190
- $movieoffset_minutes = sprintf("%02s", intval(intval($movieoffset) / 60) );
191
- $movieoffset_seconds = sprintf("%02s", round(fmod( floatval($movieoffset), 60), 2) );
192
- $movieoffset_display = $movieoffset_minutes.":".$movieoffset_seconds;
193
- }
194
- else { $movieoffset_display = "00:".sprintf("%02s", $movieoffset); }
195
-
196
- $thumbnaildisplaycode = '<div class="kg_thumbnail_select" name="attachments_'.$postID.'_thumb'.$i.'" id="attachments_'.$postID.'_thumb'.$i.'"><label for="kgflashmedia-thumb'.$i.'"><img src="'.$thumbnailurl.'?'.rand().'" width="200" height="'.$thumbnailheight.'" class="kg_thumbnail"></label><br /><input type="radio" name="kgflashmedia-thumb" id="kgflashmedia-thumb'.$i.'" value="'.str_replace('/thumb_tmp/', '/', $thumbnailurl).'" onchange="getElementById(\'attachments['. $postID .'][kgflashmediaplayer-poster]\').value = this.value; getElementById(\'attachments['. $postID .'][thumbtime]\').value = \''. $movieoffset_display .'\'; getElementById(\'attachments_'. $postID .'_numberofthumbs\').value =\'1\';"></div>';
197
-
198
- switch ($movie_info['rotate']) {
199
- case "90";
200
- case "270": $movie_width ^= $movie_height ^= $movie_width ^= $movie_height; break; //swap height & width
201
- }
202
-
203
- $i++;
204
-
205
- $arr = array ( "thumbnaildisplaycode"=>$thumbnaildisplaycode, "movie_width"=>$movie_width, "movie_height"=>$movie_height, "lastthumbnumber"=>$i, "movieoffset"=>$movieoffset );
206
-
207
- echo json_encode($arr);
208
- }//if generate
209
-
210
- if ($action == "encode") {
211
-
212
- //preferred encode path is the directory of the original file (likely in the wp_upload dir)
213
- $encodepath = "";
214
- $embed_display = "";
215
- $ffmpeg_ipod_options = "";
216
- $ffmpeg_ogv_options = "";
217
- $ffmpeg_webm_options = "";
218
- $logfile = "";
219
- $processPID = "";
220
- $serverOS = "";
221
-
222
- $encode_anything = "false";
223
-
224
- $encodevideo_info = kg_encodevideo_info($movieurl, $postID);
225
-
226
- if ($encodemobile == "true") {
227
- if ( ! $encodevideo_info['mobile_exists'] || ($encodevideo_info['sameserver'] && filesize($encodevideo_info['mobilefilepath']) < 24576) ) {
228
-
229
- switch($mobile_res) {
230
- case "480": $ipod_movie_max_width = 640; break;
231
- case "720": $ipod_movie_max_width = 1280; break;
232
- case "1080": $ipod_movie_max_width = 1920; break;
233
- default: $ipod_movie_max_width = 640;
234
- }
235
-
236
- if ( floatval($movie_width) > $ipod_movie_max_width ) { $ipod_movie_width = strval($ipod_movie_max_width); }
237
- else { $ipod_movie_width = $movie_width; }
238
- $ipod_movie_height = strval(round(floatval($movie_height) / floatval($movie_width) * $ipod_movie_width));
239
- if ($ipod_movie_height % 2 != 0) { $ipod_movie_height++; } //make sure it's an even number
240
-
241
- if ( strpos($movie_info['configuration'], 'enable-libfaac') || strpos($movie_info['configuration'], 'enable-libvo-aacenc') && strpos($movie_info['configuration'], 'enable-libx264') ) {
242
-
243
- if ( strpos($movie_info['configuration'], 'enable-libfaac') ) { $aaclib = "libfaac"; }
244
- else { $aaclib = "libvo_aacenc"; }
245
-
246
- $ipodbitrate = $movie_height * 3;
247
- $vpre_flags = "";
248
- if ( get_option('wp_FMP_vpre') == 'true' ) { $vpre_flags = '-vpre slow -vpre ipod640'; }
249
-
250
- $ffmpeg_ipod_options = ' -acodec '.$aaclib.' -ab 128k -s '.$ipod_movie_width.'x'.$ipod_movie_height.' -vcodec libx264 '.$vpre_flags.' -threads 1 '.$movie_rotate.' -b '.$ipodbitrate.'k -bt 800k -f ipod "'.$encodevideo_info['mobilefilepath'].'"';
251
- $encode_anything = "true";
252
- $embed_display .= "<strong> Encoding Mobile M4V. </strong>";
253
- }//if the proper FFMPEG libraries are enabled
254
- else { $embed_display .= "<strong>FFMPEG missing library 'libfaac' 'libvo-aacenc' or 'libx264' required for Mobile M4V encoding. </strong>"; }
255
- }//if mobile file doesn't already exist
256
- else { $embed_display .= "<strong>Mobile M4V Already Encoded! </strong>"; }
257
- }//if mobile is checked
258
-
259
- if ($encodewebm == "true") {
260
- if ( ! $encodevideo_info['webm_exists'] || ($encodevideo_info['sameserver'] && filesize($encodevideo_info['webmfilepath']) < 24576) ) {
261
- if ( strpos($movie_info['configuration'], 'enable-libvorbis') && strpos($movie_info['configuration'], 'enable-libvpx') ) {
262
- $webmbitrate = $movie_height * 3;
263
- $ffmpeg_webm_options = ' -ab 128k -b '.$webmbitrate.'k '.$movie_rotate.' -threads 1 "'.$encodevideo_info['webmfilepath'].'"';
264
- $encode_anything = "true";
265
- $embed_display .= "<strong> Encoding WEBM. </strong>";
266
- }//if the proper FFMPEG libraries are enabled
267
- else { $embed_display .= "<strong>FFMPEG missing library 'libvorbis' or 'libvpx' required for WEBM encoding. </strong>"; }
268
- }//if webm doesn't already exist
269
- else { $embed_display .= "<strong>WEBM Already Encoded! </strong>"; }
270
- }//if encodewebm is checked
271
-
272
- if ($encodeogg == "true") {
273
- if ( ! $encodevideo_info['ogg_exists'] || ($encodevideo_info['sameserver'] && filesize($encodevideo_info['oggfilepath']) < 24576) ) {
274
-
275
- if ( strpos($movie_info['configuration'], 'enable-libvorbis') && strpos($movie_info['configuration'], 'enable-libtheora') ) {
276
- $ogvbitrate = $movie_height * 3;
277
- $ffmpeg_ogv_options = ' -acodec libvorbis -ab 128k -vcodec libtheora -b '.$ogvbitrate.'k '.$movie_rotate.' -threads 1 "'.$encodevideo_info['oggfilepath'].'"';
278
- $encode_anything = "true";
279
- $embed_display .= "<strong> Encoding OGV. </strong>";
280
- }//if the proper FFMPEG libraries are enabled
281
- else { $embed_display .= "<strong>FFMPEG missing library 'libvorbis' or 'libtheora' required for OGV encoding. </strong>"; }
282
- }//if ogv doesn't already exist
283
- else { $embed_display .= "<strong>OGV Already Encoded! </strong>"; }
284
- }//if encodeogg is checked
285
-
286
-
287
- if ( $encode_anything == "true" ) {
288
-
289
- if ( ! file_exists($encodevideo_info['encodepath']) ) { mkdir($encodevideo_info['encodepath']); }
290
-
291
- $ffmpeg_options = '-y -i "'.$moviefilepath.'" '.$ffmpeg_ipod_options.$ffmpeg_ogv_options.$ffmpeg_webm_options;
292
- $logfile = $encodevideo_info['encodepath'].str_replace(" ", "_", $moviefilebasename)."_".sprintf("%04s",mt_rand(1, 1000))."_encode.txt";
293
- $cmd = escapeshellcmd($ffmpegPath." ".$ffmpeg_options);
294
- $cmd = $cmd." > ".$logfile." 2>&1 & echo $!";
295
-
296
- $process = new Process($cmd);
297
-
298
- sleep(1);
299
-
300
- $processPID = $process->getPid();
301
- $serverOS = $process->OS;
302
- $encodevideo_info = kg_encodevideo_info($movieurl, $postID); //update after encoding starts
303
-
304
- $embed_display .= " <em><small>(continues if window is closed)</small></em>";
305
-
306
- $output_map = array_map(create_function('$key, $value', 'return $key.":".$value." # ";'), array_keys($process->output), array_values($process->output));
307
- $output_implode = implode($output_map);
308
-
309
- //$embed_display .= "Command: ".$cmd." Output: ".$output_implode;
310
-
311
- }//if any HTML5 videos don't already exist
312
-
313
- $replaceoptions = "";
314
- $originalselect = "";
315
- $original_extension = pathinfo($movieurl, PATHINFO_EXTENSION);
316
- $embeddable = array("flv", "f4v", "mp4", "mov", "m4v", "ogv", "ogg", "webm");
317
- if ( in_array($original_extension, $embeddable) ) { $originalselect = '<option value="'.$movieurl.'">original</option>'; }
318
- if ( $encodevideo_info['mobile_exists'] ) { $replaceoptions .= '<option value="'.$encodevideo_info['mobileurl'].'">Mobile/H.264</option>'; }
319
- if ( $encodevideo_info['webm_exists'] ) { $replaceoptions .= '<option value="'.$encodevideo_info['webmurl'].'">WEBM</option>'; }
320
- if ( $encodevideo_info['ogg_exists'] ) { $replaceoptions .= '<option value="'.$encodevideo_info['oggurl'].'">OGV</option>'; }
321
-
322
- $altembedselect = '<span class="kg_embedselect">Embed <select name="attachments['.$postID.'][kgflashmediaplayer-altembed]" id="attachments['.$postID.'][kgflashmediaplayer-altembed]">'.$originalselect.$replaceoptions.'</select></span>';
323
-
324
- //$encodevideo_info_map = array_map(create_function('$key, $value', 'return $key.":".$value." # ";'), array_keys($encodevideo_info), array_values($encodevideo_info));
325
- //$encodevideo_info_implode = implode($encodevideo_info_map);
326
-
327
- $arr = array ( "embed_display"=>$embed_display, "pid"=>$processPID, "logfile"=>$logfile, "movie_duration"=>$movie_duration_seconds, "encode_anything"=>$encode_anything, "altembedselect"=>$altembedselect, "serverOS"=>$serverOS );
328
- echo json_encode($arr);
329
-
330
- }//if encode
331
-
332
- }//if ffmpeg can open movie
333
-
334
- else { $thumbnaildisplaycode = '<strong>Can\'t open movie file.</strong><br />'.$movie_info['output'];
335
- $arr = array ( "thumbnaildisplaycode"=>$thumbnaildisplaycode, "embed_display"=>$thumbnaildisplaycode, "lastthumbnumber"=>"break" );
336
- echo json_encode($arr);
337
- } //can't open movie
338
-
339
- }//if ffmpeg exists
340
-
341
- else { $thumbnaildisplaycode = '<strong>Error: FFMPEG not found. Verify that FFMPEG is installed and check the <a href="options-general.php?page=video-embed-thumbnail-generator.php">path to FFMPEG plugin setting</a>.</strong>' ;
342
- $arr = array ( "thumbnaildisplaycode"=>$thumbnaildisplaycode, "embed_display"=>$thumbnaildisplaycode, "lastthumbnumber"=>"break" );
343
- echo json_encode($arr);
344
- } //no ffmpeg
345
-
346
-
347
- }// if encoding or generating
348
-
349
- if ($action == "delete") {
350
-
351
- if ($poster) {
352
- $posterfile = pathinfo($poster, PATHINFO_BASENAME);
353
- $posterpath = $uploads['path'].'/'.$posterfile;
354
- if ( file_exists($posterpath) ) { unlink($posterpath); }
355
- }
356
- rrmdir($uploads['path'].'/thumb_tmp');
357
- $thumbnaildisplaycode = "<strong>Thumbnails Deleted</strong>";
358
- $arr = array ( "thumbnaildisplaycode"=>$thumbnaildisplaycode );
359
- echo json_encode($arr);
360
-
361
- }//if delete
362
-
363
-
364
- if ($action == "submit") {
365
-
366
- $posterfile = pathinfo($poster, PATHINFO_BASENAME);
367
- $tmp_posterpath = $uploads['path'].'/thumb_tmp/'.$posterfile;
368
- if ( !is_file($uploads['path'].'/'.$posterfile) ) {
369
- if ( is_file($tmp_posterpath) ) {
370
- copy($tmp_posterpath, $uploads['path'].'/'.$posterfile);
371
- $thumb_base = substr($tmp_posterpath, 0, -5);
372
- foreach (glob($thumb_base."?.jpg") as $thumbfilename) {
373
- unlink($thumbfilename);
374
- }
375
- }
376
-
377
- if ( is_empty_dir($uploads["path"].'/thumb_tmp') ) { rrmdir($uploads["path"].'/thumb_tmp'); }
378
- }
379
-
380
- //$arr = array ( "posterfile"=>$posterfile, "tmp_posterpath"=>$tmp_posterpath, "final_posterpath"=>$final_posterpath );
381
- //echo json_encode($arr);
382
-
383
- }//if submit
384
-
385
-
386
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
kg_video_plugin.js DELETED
@@ -1,277 +0,0 @@
1
- var kgthumbnailTimeout = new Array();
2
- var kgstopthumb;
3
-
4
- function kg_set_dimension(postID, valuetochange, currentvalue) {
5
- var kg_aspect = (document.getElementById('attachments['+postID+'][kgflashmediaplayer-aspect]').value);
6
- var changeaspect = kg_aspect;
7
- if (valuetochange == "width") { changeaspect = 1/kg_aspect; }
8
- var changedvalue = Math.round(currentvalue*changeaspect);
9
- if (document.getElementById('attachments_'+postID+'_kgflashmediaplayer-lockaspect').checked == true && changedvalue != 0) {
10
- document.getElementById('attachments_'+postID+'_kgflashmediaplayer-'+valuetochange).value = changedvalue;
11
- }
12
- if(postID != "singleurl") {
13
- document.getElementById('attachments['+postID+'][kgflashmediaplayer-widthsave]').value = document.getElementById('attachments_'+postID+'_kgflashmediaplayer-width').value;
14
- document.getElementById('attachments['+postID+'][kgflashmediaplayer-heightsave]').value = document.getElementById('attachments_'+postID+'_kgflashmediaplayer-height').value;
15
- }
16
- }
17
-
18
- function kg_set_aspect(postID, checked) {
19
- if (checked) { document.getElementById('attachments['+postID+'][kgflashmediaplayer-aspect]').value = document.getElementById('attachments_'+postID+'_kgflashmediaplayer-height').value / document.getElementById('attachments_'+postID+'_kgflashmediaplayer-width').value;
20
- }
21
- }
22
-
23
- function kg_generate_thumb(postID, buttonPushed) {
24
-
25
- var kgflashmediaplayersecurity = document.getElementById('attachments['+postID+'][kgflashmediaplayer-security]').value;
26
- var kg_encodemobile = document.getElementById('attachments['+postID+'][kgflashmediaplayer-encodemobile]').value;
27
- var kg_encodeogg = document.getElementById('attachments['+postID+'][kgflashmediaplayer-encodeogg]').value;
28
- var kg_encodewebm = document.getElementById('attachments['+postID+'][kgflashmediaplayer-encodewebm]').value;
29
- var attachmentURL = document.getElementById('attachments['+postID+'][kgflashmediaplayer-url]').value;
30
- var howmanythumbs = document.getElementById('attachments_'+postID+'_numberofthumbs').value;
31
- var firstframethumb = document.getElementById('attachments_'+postID+'_firstframe').checked;
32
- var posterurl = document.getElementById('attachments['+postID+'][kgflashmediaplayer-poster]').value;
33
- var specifictimecode = document.getElementById('attachments['+postID+'][thumbtime]').value;
34
- if (specifictimecode === "0") { specifictimecode = "firstframe"; }
35
- var thumbnailplaceholderid = "#attachments_"+postID+"_thumbnailplaceholder";
36
- var encodeplaceholderid = "#attachments_"+postID+"_encodeplaceholder";
37
- var encodeprogressplaceholderid = "#attachments_"+postID+"_encodeprogressplaceholder";
38
- var altembedselectid = "#attachments_"+postID+"_altembedselect";
39
- var thumbnailboxID = "#attachments_"+postID+"_kgflashmediaplayer-thumbnailbox";
40
- var thumbnailboxoverlayID = "#attachments_"+postID+"_kgflashmediaplayer-thumbnailboxoverlay";
41
- var cancelthumbdivID = '#attachments_'+postID+'_kgflashmediaplayer-cancelthumbsdiv';
42
- var widthID = 'attachments_'+postID+'_kgflashmediaplayer-width';
43
- var heightID = 'attachments_'+postID+'_kgflashmediaplayer-height';
44
- var widthsaveID = 'attachments['+postID+'][kgflashmediaplayer-widthsave]';
45
- var heightsaveID = 'attachments['+postID+'][kgflashmediaplayer-heightsave]';
46
- var maxwidthID = 'attachments['+postID+'][kgflashmediaplayer-maxwidth]';
47
- var maxheightID = 'attachments['+postID+'][kgflashmediaplayer-maxheight]';
48
- kgstopthumb = false;
49
- var i=1;
50
- var increaser = 0;
51
- var iincreaser = 0;
52
-
53
- if (buttonPushed == "generate" || buttonPushed == "random" ) {
54
- actionName = "generate";
55
- if (specifictimecode != 0 ) { howmanythumbs = 1; }
56
- }
57
- else {
58
- actionName = buttonPushed;
59
- howmanythumbs = 1;
60
- }
61
-
62
- if (buttonPushed != "encode") {
63
-
64
- jQuery(thumbnailplaceholderid).empty();
65
- jQuery(thumbnailplaceholderid).append('<strong>Choose Thumbnail: </strong><div style="display:inline-block;" id="attachments_'+postID+'_kgflashmediaplayer-cancelthumbsdiv" name="attachments_'+postID+'_kgflashmediaplayer-cancelthumbsdiv"> <input type="button" id="attachments_'+postID+'_kgflashmediaplayer-cancelencode" class="button-secondary" value="Cancel Generating" name="attachments_'+postID+'_cancelencode" onclick="kg_cancel_thumbs(\''+postID+'\');kgstopthumb=true;"></div><div id="attachments_'+postID+'_kgflashmediaplayer-thumbnailboxoverlay" name="attachments_'+postID+'_kgflashmediaplayer-thumbnailboxoverlay" class="kg_thumbnail_overlay"><div name="attachments_'+postID+'_kgflashmediaplayer-thumbnailbox" id="attachments_'+postID+'_kgflashmediaplayer-thumbnailbox" class="kg_thumbnail_box"></div></div>');
66
- }
67
-
68
- if (buttonPushed == "encode") {
69
- jQuery(encodeplaceholderid).empty();
70
- jQuery(encodeprogressplaceholderid).empty();
71
- jQuery(encodeplaceholderid).append('<strong>Encoding...</strong>');
72
- }
73
-
74
- function kg_do_post() {
75
-
76
- iincreaser = i + increaser;
77
-
78
- jQuery.post(ajaxurl, { action:"kg_callffmpeg", security: kgflashmediaplayersecurity, movieurl: attachmentURL, numberofthumbs: howmanythumbs, thumbnumber:i, thumbnumberplusincreaser:iincreaser, ffmpeg_action: actionName, encodemobile: kg_encodemobile, encodeogg: kg_encodeogg, encodewebm: kg_encodewebm, attachmentID: postID, generate_button: buttonPushed, thumbtimecode: specifictimecode, dofirstframe: firstframethumb, poster: posterurl }, function(data) {
79
-
80
- if (buttonPushed != "encode") {
81
- jQuery(thumbnailboxID).append(data.thumbnaildisplaycode);
82
- var thumbnailselectID = "#attachments_"+postID+"_thumb"+i;
83
- jQuery(thumbnailselectID).css({display:"none"});
84
- //jQuery(thumbnailselectID).fadeIn(1000);
85
- jQuery(thumbnailselectID).animate({opacity: 'toggle', height: 'toggle', width: 'toggle'}, 1000);
86
- //jQuery(thumbnailselectID).animate({display:"inline-block"}, 2000);
87
- if (data.lastthumbnumber != "break" && kgstopthumb == false) { i = parseInt(data.lastthumbnumber); }
88
- else { i = howmanythumbs + 1; }
89
- increaser++;
90
- if ( i <= howmanythumbs ) { kgthumbnailTimeout[i] = setTimeout(function(){kg_do_post()}, 750); }
91
- else {
92
- jQuery(thumbnailboxoverlayID).fadeTo(2000, 1);
93
- jQuery(cancelthumbdivID).animate({opacity: 0}, 500);
94
- }
95
-
96
- kg_aspect = data.movie_height/data.movie_width;
97
- document.getElementById('attachments['+postID+'][kgflashmediaplayer-aspect]').value = kg_aspect;
98
- if (parseInt(data.movie_width) < parseInt(document.getElementById(maxwidthID).value) ) { document.getElementById(widthID).value = data.movie_width; }
99
- else { document.getElementById(widthID).value = document.getElementById(maxwidthID).value; }
100
- if (parseInt(data.movie_width) > parseInt(document.getElementById(maxwidthID).value) ) { document.getElementById(heightID).value = Math.round(kg_aspect*parseInt(document.getElementById(maxwidthID).value)); }
101
- else { document.getElementById(heightID).value = data.movie_height; }
102
- if(postID != "singleurl") {
103
- document.getElementById(widthsaveID).value = document.getElementById(widthID).value;
104
- document.getElementById(heightsaveID).value = document.getElementById(heightID).value;
105
- }
106
- jQuery.post( ajaxurl , { action:"kg_schedule_cleanup_generated_files", security:kgflashmediaplayersecurity, thumbs:"true" } );
107
- }
108
-
109
- if (buttonPushed == "encode") {
110
- jQuery(encodeplaceholderid).empty();
111
- jQuery(encodeprogressplaceholderid).empty();
112
- jQuery(encodeplaceholderid).append(data.embed_display);
113
- jQuery(altembedselectid).empty();
114
- jQuery(altembedselectid).append(data.altembedselect);
115
- if ( data.encode_anything == "true" ) {
116
- var kg_start_time = new Date().getTime();
117
- jQuery.post( ajaxurl , { action:"kg_schedule_cleanup_generated_files", security:kgflashmediaplayersecurity, logfile:data.logfile } );
118
- if (data.serverOS != "windows" ) {
119
- jQuery(encodeprogressplaceholderid).append('<div class="meter"><span style="width:0%;"></span></div>');
120
- setTimeout(function(){kg_check_encode_progress(postID, data.pid, data.logfile, data.movie_duration, data.altembedselect, kg_start_time)}, 1000);
121
- }
122
- else { //if it's Windows skip the progress bar
123
- jQuery(encodeprogressplaceholderid).append('<div class="meter_finished"><span style="width:100%;">100%</span></div>');
124
- jQuery(encodeplaceholderid).empty();
125
- jQuery(encodeplaceholderid).append('<strong>Encoding Complete</strong>');
126
- }
127
- }
128
- }
129
- }, "json");
130
-
131
- }// end kg_do_post function
132
-
133
- kg_do_post(); //actually call the loop
134
- }
135
-
136
- function kg_insert_shortcode() {
137
-
138
- var kgflashmediaplayersecurity = document.getElementById('attachments[singleurl][kgflashmediaplayer-security]').value;
139
- var url = document.getElementById('attachments[singleurl][kgflashmediaplayer-url]').value;
140
- var alturl = "";
141
-
142
- if ( document.getElementById('attachments[singleurl][kgflashmediaplayer-altembed]') ) { alturl = document.getElementById('attachments[singleurl][kgflashmediaplayer-altembed]').value; }
143
- if ( alturl != "" ) { url = alturl; }
144
- var validExtensions = new Array(".flv", ".f4v", ".mp4", ".mov", ".m4v", ".webm", ".ogg", ".ogv");
145
- var extension;
146
- var extensionExists = false;
147
- for (extension in validExtensions) {
148
- if (url.indexOf(extension) != -1) { extensionExists = true; break; }
149
- }
150
- if (extensionExists == false) { alert("Please enter a URL that points to a valid video file. Video sharing sites are not supported by this plugin.\nTo embed from YouTube, Vimeo, etc, just paste the link directly into the post window and WordPress will handle the rest."); return; }
151
-
152
- jQuery.post(ajaxurl, { action:'kg_callffmpeg', security: kgflashmediaplayersecurity, attachmentID: 'singleurl', movieurl: url, ffmpeg_action:'submit', poster: document.getElementById('attachments[singleurl][kgflashmediaplayer-poster]').value }, function(data) {
153
- jQuery('attachments_singleurl_thumbnailplaceholder').empty();
154
- }, "json" );
155
-
156
- var shortcode = "";
157
- if (document.getElementById('videotitle').value != "") {
158
- var titlecode = unescape(document.getElementById('attachments[singleurl][kgflashmediaplayer-titlecode]').value);
159
- titlecode=titlecode.replace(/\\'/g,'\'');
160
- titlecode=titlecode.replace(/\\"/g,'"');
161
- titlecode=titlecode.replace(/\\0/g,'\0');
162
- titlecode=titlecode.replace(/\\\\/g,'\\');
163
- if ( titlecode.substr(0,1) != '<' ) { titlecode = '<'+titlecode; }
164
- if ( titlecode.substr(-1,1) != '>' ) { titlecode = titlecode+'>'; }
165
- var endtitlecode = titlecode.replace('<', '</');
166
- endtitlecode = endtitlecode.split(' ');
167
- endtitlecode = endtitlecode[0];
168
- if ( endtitlecode.substr(-1,1) != '>' ) { endtitlecode = endtitlecode+'>'; }
169
- shortcode += titlecode + document.getElementById('videotitle').value + endtitlecode + '<br />';
170
- }
171
- if (url !="") {
172
- shortcode += ' [FMP';
173
- if (document.getElementById('attachments[singleurl][kgflashmediaplayer-poster]').value !="") { shortcode += ' poster="' + document.getElementById("attachments[singleurl][kgflashmediaplayer-poster]").value + '"'; }
174
- if (document.getElementById('attachments_singleurl_kgflashmediaplayer-width').value !="") { shortcode += ' width="' + document.getElementById("attachments_singleurl_kgflashmediaplayer-width").value + '"'; }
175
- if (document.getElementById('attachments_singleurl_kgflashmediaplayer-height').value !="") { shortcode += ' height="' + document.getElementById("attachments_singleurl_kgflashmediaplayer-height").value + '"'; }
176
- shortcode += ']' + url + '[/FMP] '; }
177
- if (document.getElementById('downloadlink').checked) { shortcode += '<br /><a href="' + document.getElementById("attachments[singleurl][kgflashmediaplayer-url]").value + '">Right-click or ctrl-click this link to download</a>'; }
178
-
179
- parent.send_to_editor(shortcode);
180
- }
181
-
182
- function kg_check_encode_progress(postID, kg_pid, kg_logfile, kg_movie_duration, kg_altembedselect, kg_start_time) {
183
- var encodeprogressplaceholderid = "#attachments_"+postID+"_encodeprogressplaceholder";
184
- var encodeplaceholderid = "#attachments_"+postID+"_encodeplaceholder";
185
- var altembedselectid = "#attachments_"+postID+"_altembedselect";
186
- var kgflashmediaplayersecurity = document.getElementById('attachments['+postID+'][kgflashmediaplayer-security]').value;
187
- var stopChecking = false;
188
-
189
- jQuery.post(ajaxurl, { action:"kg_check_encode_progress", security: kgflashmediaplayersecurity, pid: kg_pid, logfile: kg_logfile, movie_duration: kg_movie_duration }, function(data) {
190
-
191
- var display_percent = "";
192
- if ( data.percent_done > 7 ) { display_percent = data.percent_done+"%"; }
193
-
194
- var kg_current_time = new Date().getTime();
195
- var kg_time_elapsed = Math.round( (kg_current_time - kg_start_time) / 1000 );
196
- if ( kg_time_elapsed >= 60 ) {
197
- kg_time_elapsed_minutes = Math.floor(kg_time_elapsed/60);
198
- kg_time_elapsed_seconds = kg_time_elapsed%60;
199
- kg_time_elapsed_seconds = (kg_time_elapsed_seconds < 10) ? ("0" + kg_time_elapsed_seconds) : kg_time_elapsed_seconds;
200
- kg_time_elapsed_display = kg_time_elapsed_minutes+':'+kg_time_elapsed_seconds;
201
- }
202
- else { kg_time_elapsed_display = kg_time_elapsed+' seconds'; }
203
-
204
- if ( data.percent_done != "" && data.percent_done != "100" ) {
205
- if ( parseInt(data.percent_done) < 100 ) {
206
- var kg_time_remaining = Math.floor( (kg_time_elapsed / (data.percent_done/100) ) - kg_time_elapsed);
207
- if ( kg_time_remaining >= 60 ) {
208
- kg_time_remaining_minutes = Math.round(kg_time_remaining/60);
209
- kg_time_remaining_seconds = kg_time_remaining%60;
210
- kg_time_remaining_seconds = (kg_time_remaining_seconds < 10) ? ("0" + kg_time_remaining_seconds) : kg_time_remaining_seconds;
211
- kg_time_remaining_display = kg_time_remaining_minutes+':'+kg_time_remaining_seconds;
212
- }
213
- else { kg_time_remaining_display = kg_time_remaining+' seconds'; }
214
- jQuery(encodeprogressplaceholderid).empty();
215
- jQuery(encodeprogressplaceholderid).append('<div class="meter"><span style="width:'+data.percent_done+'%;">'+display_percent+'</span></div><div class="kg_cancel_button"><input type="button" id="attachments_'+postID+'_kgflashmediaplayer-cancelencode" class="button-secondary" value="Cancel" name="attachments_'+postID+'_cancelencode" onclick="kg_cancel_encode('+kg_pid+', \''+postID+'\');"></div><div style="display:block;"><small>Elapsed: '+kg_time_elapsed_display+'. Estimated Remaining: '+kg_time_remaining_display+'. FPS:'+data.fps+'</small></div>');
216
- }
217
- else {
218
- jQuery(encodeprogressplaceholderid).empty();
219
- jQuery(encodeprogressplaceholderid).append('<div class="kg_cancel_button"><input type="button" id="attachments_'+postID+'_kgflashmediaplayer-cancelencode" class="button-secondary" value="Cancel" name="attachments_'+postID+'_cancelencode" onclick="kg_cancel_encode('+kg_pid+', \''+postID+'\');"></div><div style="display:block;"><small>Elapsed: '+kg_time_elapsed_display+'. FPS:'+data.fps+'</small></div>');
220
- }
221
- }
222
-
223
- if (data.other_message != "") {
224
- clearTimeout(percent_timeout);
225
- stopChecking = true;
226
- jQuery(encodeplaceholderid).empty();
227
- jQuery(encodeplaceholderid).append('<strong>Encoding Halted</strong>');
228
- jQuery(encodeprogressplaceholderid).empty();
229
- jQuery(encodeprogressplaceholderid).append('<strong><span style="color:red;">Message from FFMPEG: '+data.other_message+'</span></strong>');
230
- }
231
-
232
- if ( data.percent_done == "100" ) {
233
- clearTimeout(percent_timeout);
234
- stopChecking = true;
235
- //delete window.kg_start_time_over;
236
- jQuery(encodeprogressplaceholderid).empty();
237
- jQuery(encodeprogressplaceholderid).append('<div class="meter_finished"><span style="width:100%;">100%</span></div><div style="display:block;"><small>Elapsed: '+kg_time_elapsed_display+'. Estimated Remaining: 0 seconds.</small></div>');
238
- jQuery(encodeplaceholderid).empty();
239
- jQuery(encodeplaceholderid).append('<strong>Encoding Complete</strong>');
240
- }
241
- //jQuery(encodeplaceholderid).empty();
242
- //jQuery(encodeplaceholderid).append(data.embed_display);
243
-
244
- if ( data.fps !== "" ) {
245
- var kg_timetowait = Math.round(30000/parseInt(data.fps));
246
- if (kg_timetowait < 1000) { kg_timetowait = 1000; }
247
- }
248
- else { var kg_timetowait = 2000; }
249
-
250
- if ( stopChecking != true ) {
251
- percent_timeout = setTimeout(function(){kg_check_encode_progress(postID, kg_pid, kg_logfile, kg_movie_duration, kg_altembedselect, kg_start_time)}, kg_timetowait);
252
- }
253
-
254
- }, "json" );
255
- }
256
-
257
- function kg_cancel_encode(kg_pid, postID) {
258
-
259
- var kgflashmediaplayersecurity = document.getElementById('attachments['+postID+'][kgflashmediaplayer-security]').value;
260
- var cancelbuttonID = 'attachments_'+postID+'_kgflashmediaplayer-cancelencode';
261
-
262
- document.getElementById(cancelbuttonID).disabled = true;
263
- document.getElementById(cancelbuttonID).title = "Command sent. Be patient";
264
-
265
- jQuery.post(ajaxurl, { action:"kg_cancel_encode", security: kgflashmediaplayersecurity, kg_pid: kg_pid } );
266
-
267
- }
268
-
269
-
270
- function kg_cancel_thumbs(postID) {
271
- for( key in kgthumbnailTimeout ){ clearTimeout(kgthumbnailTimeout[key]); }
272
- var thumbnailboxoverlayID = "#attachments_"+postID+"_kgflashmediaplayer-thumbnailboxoverlay";
273
- jQuery(thumbnailboxoverlayID).fadeTo(2000, 1);
274
- var cancelthumbdivID = '#attachments_'+postID+'_kgflashmediaplayer-cancelthumbsdiv';
275
- jQuery(cancelthumbdivID).animate({opacity: 0}, 500);
276
- jQuery(cancelthumbdivID).remove;
277
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
mdetect.php DELETED
@@ -1,991 +0,0 @@
1
- <?php
2
-
3
- /* *******************************************
4
- // Copyright 2010-2011, Anthony Hand
5
- //
6
- // File version date: August 22, 2011
7
- // Update:
8
- // - Updated DetectAndroidTablet() to fix a bug introduced in the last fix! The true/false returns were mixed up.
9
- //
10
- // File version date: August 16, 2011
11
- // Update:
12
- // - Updated DetectAndroidTablet() to exclude Opera Mini, which was falsely reporting as running on a tablet device when on a phone.
13
- //
14
- // File version date: August 7, 2011
15
- // Update:
16
- // - The Opera for Android browser doesn't follow Google's recommended useragent string guidelines, so some fixes were needed.
17
- // - Updated DetectAndroidPhone() and DetectAndroidTablet() to properly detect devices running Opera Mobile.
18
- // - Created 2 new methods: DetectOperaAndroidPhone() and DetectOperaAndroidTablet().
19
- // - Updated DetectTierIphone(). Removed the call to DetectMaemoTablet(), an obsolete mobile OS.
20
- //
21
- // File version date: July 15, 2011
22
- // Update:
23
- // - Refactored the variable called maemoTablet. Its new name is the more generic deviceTablet.
24
- // - Created the variable deviceWebOShp for HP's line of WebOS devices starting with the TouchPad tablet.
25
- // - Created the DetectWebOSTablet() method for HP's line of WebOS tablets starting with the TouchPad tablet.
26
- // - Updated the DetectTierTablet() method to also search for WebOS tablets.
27
- // - Updated the DetectMaemoTablet() method to disambiguate against WebOS tablets which share some signature traits.
28
- //
29
- //
30
- // LICENSE INFORMATION
31
- // Licensed under the Apache License, Version 2.0 (the "License");
32
- // you may not use this file except in compliance with the License.
33
- // You may obtain a copy of the License at
34
- // http://www.apache.org/licenses/LICENSE-2.0
35
- // Unless required by applicable law or agreed to in writing,
36
- // software distributed under the License is distributed on an
37
- // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
38
- // either express or implied. See the License for the specific
39
- // language governing permissions and limitations under the License.
40
- //
41
- //
42
- // ABOUT THIS PROJECT
43
- // Project Owner: Anthony Hand
44
- // Email: anthony.hand@gmail.com
45
- // Web Site: http://www.mobileesp.com
46
- // Source Files: http://code.google.com/p/mobileesp/
47
- //
48
- // Versions of this code are available for:
49
- // PHP, JavaScript, Java, ASP.NET (C#), and Ruby
50
- //
51
- // *******************************************
52
- */
53
-
54
-
55
-
56
- //**************************
57
- // The uagent_info class encapsulates information about
58
- // a browser's connection to your web site.
59
- // You can use it to find out whether the browser asking for
60
- // your site's content is probably running on a mobile device.
61
- // The methods were written so you can be as granular as you want.
62
- // For example, enquiring whether it's as specific as an iPod Touch or
63
- // as general as a smartphone class device.
64
- // The object's methods return 1 for true, or 0 for false.
65
- class uagent_info
66
- {
67
- var $useragent = "";
68
- var $httpaccept = "";
69
-
70
- //standardized values for true and false.
71
- var $true = 1;
72
- var $false = 0;
73
-
74
- //Let's store values for quickly accessing the same info multiple times.
75
- var $isIphone = 0; //Stores whether the device is an iPhone or iPod Touch.
76
- var $isAndroidPhone = 0; //Stores whether the device is a (small-ish) Android phone or media player.
77
- var $isTierTablet = 0; //Stores whether is the Tablet (HTML5-capable, larger screen) tier of devices.
78
- var $isTierIphone = 0; //Stores whether is the iPhone tier of devices.
79
- var $isTierRichCss = 0; //Stores whether the device can probably support Rich CSS, but JavaScript support is not assumed. (e.g., newer BlackBerry, Windows Mobile)
80
- var $isTierGenericMobile = 0; //Stores whether it is another mobile device, which cannot be assumed to support CSS or JS (eg, older BlackBerry, RAZR)
81
-
82
- //Initialize some initial smartphone string variables.
83
- var $engineWebKit = 'webkit';
84
- var $deviceIphone = 'iphone';
85
- var $deviceIpod = 'ipod';
86
- var $deviceIpad = 'ipad';
87
- var $deviceMacPpc = 'macintosh'; //Used for disambiguation
88
-
89
- var $deviceAndroid = 'android';
90
- var $deviceGoogleTV = 'googletv';
91
- var $deviceXoom = 'xoom'; //Motorola Xoom
92
- var $deviceHtcFlyer = 'htc_flyer'; //HTC Flyer
93
-
94
- var $deviceNuvifone = 'nuvifone'; //Garmin Nuvifone
95
-
96
- var $deviceSymbian = 'symbian';
97
- var $deviceS60 = 'series60';
98
- var $deviceS70 = 'series70';
99
- var $deviceS80 = 'series80';
100
- var $deviceS90 = 'series90';
101
-
102
- var $deviceWinPhone7 = 'windows phone os 7';
103
- var $deviceWinMob = 'windows ce';
104
- var $deviceWindows = 'windows';
105
- var $deviceIeMob = 'iemobile';
106
- var $devicePpc = 'ppc'; //Stands for PocketPC
107
- var $enginePie = 'wm5 pie'; //An old Windows Mobile
108
-
109
- var $deviceBB = 'blackberry';
110
- var $vndRIM = 'vnd.rim'; //Detectable when BB devices emulate IE or Firefox
111
- var $deviceBBStorm = 'blackberry95'; //Storm 1 and 2
112
- var $deviceBBBold = 'blackberry97'; //Bold
113
- var $deviceBBTour = 'blackberry96'; //Tour
114
- var $deviceBBCurve = 'blackberry89'; //Curve2
115
- var $deviceBBTorch = 'blackberry 98'; //Torch
116
- var $deviceBBPlaybook = 'playbook'; //PlayBook tablet
117
-
118
- var $devicePalm = 'palm';
119
- var $deviceWebOS = 'webos'; //For Palm's line of WebOS devices
120
- var $deviceWebOShp = 'hpwos'; //For HP's line of WebOS devices
121
-
122
- var $engineBlazer = 'blazer'; //Old Palm browser
123
- var $engineXiino = 'xiino'; //Another old Palm
124
-
125
- var $deviceKindle = 'kindle'; //Amazon Kindle, eInk one.
126
-
127
- //Initialize variables for mobile-specific content.
128
- var $vndwap = 'vnd.wap';
129
- var $wml = 'wml';
130
-
131
- //Initialize variables for other random devices and mobile browsers.
132
- var $deviceTablet = 'tablet'; //Generic term for slate and tablet devices
133
- var $deviceBrew = 'brew';
134
- var $deviceDanger = 'danger';
135
- var $deviceHiptop = 'hiptop';
136
- var $devicePlaystation = 'playstation';
137
- var $deviceNintendoDs = 'nitro';
138
- var $deviceNintendo = 'nintendo';
139
- var $deviceWii = 'wii';
140
- var $deviceXbox = 'xbox';
141
- var $deviceArchos = 'archos';
142
-
143
- var $engineOpera = 'opera'; //Popular browser
144
- var $engineNetfront = 'netfront'; //Common embedded OS browser
145
- var $engineUpBrowser = 'up.browser'; //common on some phones
146
- var $engineOpenWeb = 'openweb'; //Transcoding by OpenWave server
147
- var $deviceMidp = 'midp'; //a mobile Java technology
148
- var $uplink = 'up.link';
149
- var $engineTelecaQ = 'teleca q'; //a modern feature phone browser
150
-
151
- var $devicePda = 'pda'; //some devices report themselves as PDAs
152
- var $mini = 'mini'; //Some mobile browsers put 'mini' in their names.
153
- var $mobile = 'mobile'; //Some mobile browsers put 'mobile' in their user agent strings.
154
- var $mobi = 'mobi'; //Some mobile browsers put 'mobi' in their user agent strings.
155
-
156
- //Use Maemo, Tablet, and Linux to test for Nokia's Internet Tablets.
157
- var $maemo = 'maemo';
158
- var $linux = 'linux';
159
- var $qtembedded = 'qt embedded'; //for Sony Mylo and others
160
- var $mylocom2 = 'com2'; //for Sony Mylo also
161
-
162
- //In some UserAgents, the only clue is the manufacturer.
163
- var $manuSonyEricsson = "sonyericsson";
164
- var $manuericsson = "ericsson";
165
- var $manuSamsung1 = "sec-sgh";
166
- var $manuSony = "sony";
167
- var $manuHtc = "htc"; //Popular Android and WinMo manufacturer
168
-
169
- //In some UserAgents, the only clue is the operator.
170
- var $svcDocomo = "docomo";
171
- var $svcKddi = "kddi";
172
- var $svcVodafone = "vodafone";
173
-
174
- //Disambiguation strings.
175
- var $disUpdate = "update"; //pda vs. update
176
-
177
-
178
- //**************************
179
- //The constructor. Initializes several default variables.
180
- function uagent_info()
181
- {
182
- $this->useragent = isset($_SERVER['HTTP_USER_AGENT'])?strtolower($_SERVER['HTTP_USER_AGENT']):'';
183
- $this->httpaccept = isset($_SERVER['HTTP_ACCEPT'])?strtolower($_SERVER['HTTP_ACCEPT']):'';
184
-
185
- //Let's initialize some values to save cycles later.
186
- $this->InitDeviceScan();
187
- }
188
-
189
- //**************************
190
- // Initialize Key Stored Values.
191
- function InitDeviceScan()
192
- {
193
- global $isIphone, $isAndroidPhone, $isTierTablet, $isTierIphone;
194
-
195
- //We'll use these 4 variables to speed other processing. They're super common.
196
- $this->isIphone = $this->DetectIphoneOrIpod();
197
- $this->isAndroidPhone = $this->DetectAndroidPhone();
198
- $this->isTierIphone = $this->DetectTierIphone();
199
- $this->isTierTablet = $this->DetectTierTablet();
200
-
201
- //Optional: Comment these out if you don't need them.
202
- global $isTierRichCss, $isTierGenericMobile;
203
- $this->isTierRichCss = $this->DetectTierRichCss();
204
- $this->isTierGenericMobile = $this->DetectTierOtherPhones();
205
- }
206
-
207
- //**************************
208
- //Returns the contents of the User Agent value, in lower case.
209
- function Get_Uagent()
210
- {
211
- return $this->useragent;
212
- }
213
-
214
- //**************************
215
- //Returns the contents of the HTTP Accept value, in lower case.
216
- function Get_HttpAccept()
217
- {
218
- return $this->httpaccept;
219
- }
220
-
221
-
222
- //**************************
223
- // Detects if the current device is an iPhone.
224
- function DetectIphone()
225
- {
226
- if (stripos($this->useragent, $this->deviceIphone) > -1)
227
- {
228
- //The iPad and iPod Touch say they're an iPhone. So let's disambiguate.
229
- if ($this->DetectIpad() == $this->true ||
230
- $this->DetectIpod() == $this->true)
231
- return $this->false;
232
- //Yay! It's an iPhone!
233
- else
234
- return $this->true;
235
- }
236
- else
237
- return $this->false;
238
- }
239
-
240
- //**************************
241
- // Detects if the current device is an iPod Touch.
242
- function DetectIpod()
243
- {
244
- if (stripos($this->useragent, $this->deviceIpod) > -1)
245
- return $this->true;
246
- else
247
- return $this->false;
248
- }
249
-
250
- //**************************
251
- // Detects if the current device is an iPad tablet.
252
- function DetectIpad()
253
- {
254
- if (stripos($this->useragent, $this->deviceIpad) > -1 &&
255
- $this->DetectWebkit() == $this->true)
256
- return $this->true;
257
- else
258
- return $this->false;
259
- }
260
-
261
- //**************************
262
- // Detects if the current device is an iPhone or iPod Touch.
263
- function DetectIphoneOrIpod()
264
- {
265
- //We repeat the searches here because some iPods may report themselves as an iPhone, which would be okay.
266
- if (stripos($this->useragent, $this->deviceIphone) > -1 ||
267
- stripos($this->useragent, $this->deviceIpod) > -1)
268
- return $this->true;
269
- else
270
- return $this->false;
271
- }
272
-
273
- //**************************
274
- // Detects *any* iOS device: iPhone, iPod Touch, iPad.
275
- function DetectIos()
276
- {
277
- if (($this->DetectIphoneOrIpod() == $this->true) ||
278
- ($this->DetectIpad() == $this->true))
279
- return $this->true;
280
- else
281
- return $this->false;
282
- }
283
-
284
-
285
- //**************************
286
- // Detects *any* Android OS-based device: phone, tablet, and multi-media player.
287
- // Also detects Google TV.
288
- function DetectAndroid()
289
- {
290
- if ((stripos($this->useragent, $this->deviceAndroid) > -1) ||
291
- ($this->DetectGoogleTV() == $this->true))
292
- return $this->true;
293
- //Special check for the HTC Flyer 7" tablet
294
- if ((stripos($this->useragent, $this->deviceHtcFlyer) > -1))
295
- return $this->true;
296
- else
297
- return $this->false;
298
- }
299
-
300
- //**************************
301
- // Detects if the current device is a (small-ish) Android OS-based device
302
- // used for calling and/or multi-media (like a Samsung Galaxy Player).
303
- // Google says these devices will have 'Android' AND 'mobile' in user agent.
304
- // Ignores tablets (Honeycomb and later).
305
- function DetectAndroidPhone()
306
- {
307
- if (($this->DetectAndroid() == $this->true) &&
308
- (stripos($this->useragent, $this->mobile) > -1))
309
- return $this->true;
310
- //Special check for Android phones with Opera Mobile. They should report here.
311
- if (($this->DetectOperaAndroidPhone() == $this->true))
312
- return $this->true;
313
- //Special check for the HTC Flyer 7" tablet. It should report here.
314
- if ((stripos($this->useragent, $this->deviceHtcFlyer) > -1))
315
- return $this->true;
316
- else
317
- return $this->false;
318
- }
319
-
320
- //**************************
321
- // Detects if the current device is a (self-reported) Android tablet.
322
- // Google says these devices will have 'Android' and NOT 'mobile' in their user agent.
323
- function DetectAndroidTablet()
324
- {
325
- //First, let's make sure we're on an Android device.
326
- if ($this->DetectAndroid() == $this->false)
327
- return $this->false;
328
-
329
- //Special check for Opera Android Phones. They should NOT report here.
330
- if ($this->DetectOperaMobile() == $this->true)
331
- return $this->false;
332
- //Special check for the HTC Flyer 7" tablet. It should NOT report here.
333
- if ((stripos($this->useragent, $this->deviceHtcFlyer) > -1))
334
- return $this->false;
335
-
336
- //Otherwise, if it's Android and does NOT have 'mobile' in it, Google says it's a tablet.
337
- if (stripos($this->useragent, $this->mobile) > -1)
338
- return $this->false;
339
- else
340
- return $this->true;
341
- }
342
-
343
- //**************************
344
- // Detects if the current device is an Android OS-based device and
345
- // the browser is based on WebKit.
346
- function DetectAndroidWebKit()
347
- {
348
- if (($this->DetectAndroid() == $this->true) &&
349
- ($this->DetectWebkit() == $this->true))
350
- return $this->true;
351
- else
352
- return $this->false;
353
- }
354
-
355
- //**************************
356
- // Detects if the current device is a GoogleTV.
357
- function DetectGoogleTV()
358
- {
359
- if (stripos($this->useragent, $this->deviceGoogleTV) > -1)
360
- return $this->true;
361
- else
362
- return $this->false;
363
- }
364
-
365
- //**************************
366
- // Detects if the current browser is based on WebKit.
367
- function DetectWebkit()
368
- {
369
- if (stripos($this->useragent, $this->engineWebKit) > -1)
370
- return $this->true;
371
- else
372
- return $this->false;
373
- }
374
-
375
-
376
- //**************************
377
- // Detects if the current browser is the Nokia S60 Open Source Browser.
378
- function DetectS60OssBrowser()
379
- {
380
- //First, test for WebKit, then make sure it's either Symbian or S60.
381
- if ($this->DetectWebkit() == $this->true)
382
- {
383
- if (stripos($this->useragent, $this->deviceSymbian) > -1 ||
384
- stripos($this->useragent, $this->deviceS60) > -1)
385
- {
386
- return $this->true;
387
- }
388
- else
389
- return $this->false;
390
- }
391
- else
392
- return $this->false;
393
- }
394
-
395
- //**************************
396
- // Detects if the current device is any Symbian OS-based device,
397
- // including older S60, Series 70, Series 80, Series 90, and UIQ,
398
- // or other browsers running on these devices.
399
- function DetectSymbianOS()
400
- {
401
- if (stripos($this->useragent, $this->deviceSymbian) > -1 ||
402
- stripos($this->useragent, $this->deviceS60) > -1 ||
403
- stripos($this->useragent, $this->deviceS70) > -1 ||
404
- stripos($this->useragent, $this->deviceS80) > -1 ||
405
- stripos($this->useragent, $this->deviceS90) > -1)
406
- return $this->true;
407
- else
408
- return $this->false;
409
- }
410
-
411
- //**************************
412
- // Detects if the current browser is a
413
- // Windows Phone 7 device.
414
- function DetectWindowsPhone7()
415
- {
416
- if (stripos($this->useragent, $this->deviceWinPhone7) > -1)
417
- return $this->true;
418
- else
419
- return $this->false;
420
- }
421
-
422
- //**************************
423
- // Detects if the current browser is a Windows Mobile device.
424
- // Excludes Windows Phone 7 devices.
425
- // Focuses on Windows Mobile 6.xx and earlier.
426
- function DetectWindowsMobile()
427
- {
428
- if ($this->DetectWindowsPhone7() == $this->true)
429
- return $this->false;
430
- //Most devices use 'Windows CE', but some report 'iemobile'
431
- // and some older ones report as 'PIE' for Pocket IE.
432
- if (stripos($this->useragent, $this->deviceWinMob) > -1 ||
433
- stripos($this->useragent, $this->deviceIeMob) > -1 ||
434
- stripos($this->useragent, $this->enginePie) > -1)
435
- return $this->true;
436
- //Test for Windows Mobile PPC but not old Macintosh PowerPC.
437
- if (stripos($this->useragent, $this->devicePpc) > -1
438
- && !(stripos($this->useragent, $this->deviceMacPpc) > 1))
439
- return $this->true;
440
- //Test for certain Windwos Mobile-based HTC devices.
441
- if (stripos($this->useragent, $this->manuHtc) > -1 &&
442
- stripos($this->useragent, $this->deviceWindows) > -1)
443
- return $this->true;
444
- if ($this->DetectWapWml() == $this->true &&
445
- stripos($this->useragent, $this->deviceWindows) > -1)
446
- return $this->true;
447
- else
448
- return $this->false;
449
- }
450
-
451
- //**************************
452
- // Detects if the current browser is any BlackBerry device.
453
- // Includes the PlayBook.
454
- function DetectBlackBerry()
455
- {
456
- if ((stripos($this->useragent, $this->deviceBB) > -1) ||
457
- (stripos($this->httpaccept, $this->vndRIM) > -1))
458
- return $this->true;
459
- else
460
- return $this->false;
461
- }
462
-
463
- //**************************
464
- // Detects if the current browser is on a BlackBerry tablet device.
465
- // Examples: PlayBook
466
- function DetectBlackBerryTablet()
467
- {
468
- if ((stripos($this->useragent, $this->deviceBBPlaybook) > -1))
469
- return $this->true;
470
- else
471
- return $this->false;
472
- }
473
-
474
- //**************************
475
- // Detects if the current browser is a BlackBerry phone device AND uses a
476
- // WebKit-based browser. These are signatures for the new BlackBerry OS 6.
477
- // Examples: Torch. Includes the Playbook.
478
- function DetectBlackBerryWebKit()
479
- {
480
- if (($this->DetectBlackBerry() == $this->true) &&
481
- ($this->DetectWebkit() == $this->true))
482
- return $this->true;
483
- else
484
- return $this->false;
485
- }
486
-
487
- //**************************
488
- // Detects if the current browser is a BlackBerry Touch phone
489
- // device, such as the Storm or Torch. Excludes the Playbook.
490
- function DetectBlackBerryTouch()
491
- {
492
- if ((stripos($this->useragent, $this->deviceBBStorm) > -1) ||
493
- (stripos($this->useragent, $this->deviceBBTorch) > -1))
494
- return $this->true;
495
- else
496
- return $this->false;
497
- }
498
-
499
- //**************************
500
- // Detects if the current browser is a BlackBerry OS 5 device AND
501
- // has a more capable recent browser. Excludes the Playbook.
502
- // Examples, Storm, Bold, Tour, Curve2
503
- // Excludes the new BlackBerry OS 6 browser!!
504
- function DetectBlackBerryHigh()
505
- {
506
- //Disambiguate for BlackBerry OS 6 (WebKit) browser
507
- if ($this->DetectBlackBerryWebKit() == $this->true)
508
- return $this->false;
509
- if ($this->DetectBlackBerry() == $this->true)
510
- {
511
- if (($this->DetectBlackBerryTouch() == $this->true) ||
512
- stripos($this->useragent, $this->deviceBBBold) > -1 ||
513
- stripos($this->useragent, $this->deviceBBTour) > -1 ||
514
- stripos($this->useragent, $this->deviceBBCurve) > -1)
515
- {
516
- return $this->true;
517
- }
518
- else
519
- return $this->false;
520
- }
521
- else
522
- return $this->false;
523
- }
524
-
525
- //**************************
526
- // Detects if the current browser is a BlackBerry device AND
527
- // has an older, less capable browser.
528
- // Examples: Pearl, 8800, Curve1.
529
- function DetectBlackBerryLow()
530
- {
531
- if ($this->DetectBlackBerry() == $this->true)
532
- {
533
- //Assume that if it's not in the High tier, then it's Low.
534
- if (($this->DetectBlackBerryHigh() == $this->true) ||
535
- ($this->DetectBlackBerryWebKit() == $this->true))
536
- return $this->false;
537
- else
538
- return $this->true;
539
- }
540
- else
541
- return $this->false;
542
- }
543
-
544
- //**************************
545
- // Detects if the current browser is on a PalmOS device.
546
- function DetectPalmOS()
547
- {
548
- //Most devices nowadays report as 'Palm', but some older ones reported as Blazer or Xiino.
549
- if (stripos($this->useragent, $this->devicePalm) > -1 ||
550
- stripos($this->useragent, $this->engineBlazer) > -1 ||
551
- stripos($this->useragent, $this->engineXiino) > -1)
552
- {
553
- //Make sure it's not WebOS first
554
- if ($this->DetectPalmWebOS() == $this->true)
555
- return $this->false;
556
- else
557
- return $this->true;
558
- }
559
- else
560
- return $this->false;
561
- }
562
-
563
-
564
- //**************************
565
- // Detects if the current browser is on a Palm device
566
- // running the new WebOS.
567
- function DetectPalmWebOS()
568
- {
569
- if (stripos($this->useragent, $this->deviceWebOS) > -1)
570
- return $this->true;
571
- else
572
- return $this->false;
573
- }
574
-
575
- //**************************
576
- // Detects if the current browser is on an HP tablet running WebOS.
577
- function DetectWebOSTablet()
578
- {
579
- if ((stripos($this->useragent, $this->deviceWebOShp) > -1)
580
- && (stripos($this->useragent, $this->deviceTablet) > -1))
581
- return $this->true;
582
- else
583
- return $this->false;
584
- }
585
-
586
- //**************************
587
- // Detects if the current browser is a
588
- // Garmin Nuvifone.
589
- function DetectGarminNuvifone()
590
- {
591
- if (stripos($this->useragent, $this->deviceNuvifone) > -1)
592
- return $this->true;
593
- else
594
- return $this->false;
595
- }
596
-
597
-
598
- //**************************
599
- // Check to see whether the device is any device
600
- // in the 'smartphone' category.
601
- function DetectSmartphone()
602
- {
603
- global $isIphone, $isAndroidPhone, $isTierIphone;
604
-
605
- if (($this->isIphone == $this->true)
606
- || ($this->isAndroidPhone == $this->true)
607
- || ($this->isTierIphone == $this->true)
608
- || ($this->DetectS60OssBrowser() == $this->true)
609
- || ($this->DetectSymbianOS() == $this->true)
610
- || ($this->DetectWindowsMobile() == $this->true)
611
- || ($this->DetectWindowsPhone7() == $this->true)
612
- || ($this->DetectBlackBerry() == $this->true)
613
- || ($this->DetectPalmWebOS() == $this->true)
614
- || ($this->DetectPalmOS() == $this->true)
615
- || ($this->DetectGarminNuvifone() == $this->true))
616
- return $this->true;
617
- else
618
- return $this->false;
619
- }
620
-
621
-
622
- //**************************
623
- // Detects whether the device is a Brew-powered device.
624
- function DetectBrewDevice()
625
- {
626
- if (stripos($this->useragent, $this->deviceBrew) > -1)
627
- return $this->true;
628
- else
629
- return $this->false;
630
- }
631
-
632
- //**************************
633
- // Detects the Danger Hiptop device.
634
- function DetectDangerHiptop()
635
- {
636
- if (stripos($this->useragent, $this->deviceDanger) > -1 ||
637
- stripos($this->useragent, $this->deviceHiptop) > -1)
638
- return $this->true;
639
- else
640
- return $this->false;
641
- }
642
-
643
- //**************************
644
- // Detects if the current browser is Opera Mobile or Mini.
645
- function DetectOperaMobile()
646
- {
647
- if (stripos($this->useragent, $this->engineOpera) > -1)
648
- {
649
- if ((stripos($this->useragent, $this->mini) > -1) ||
650
- (stripos($this->useragent, $this->mobi) > -1))
651
- return $this->true;
652
- else
653
- return $this->false;
654
- }
655
- else
656
- return $this->false;
657
- }
658
-
659
- //**************************
660
- // Detects if the current browser is Opera Mobile
661
- // running on an Android phone.
662
- function DetectOperaAndroidPhone()
663
- {
664
- if ((stripos($this->useragent, $this->engineOpera) > -1) &&
665
- (stripos($this->useragent, $this->deviceAndroid) > -1) &&
666
- (stripos($this->useragent, $this->mobi) > -1))
667
- return $this->true;
668
- else
669
- return $this->false;
670
- }
671
-
672
- //**************************
673
- // Detects if the current browser is Opera Mobile
674
- // running on an Android tablet.
675
- function DetectOperaAndroidTablet()
676
- {
677
- if ((stripos($this->useragent, $this->engineOpera) > -1) &&
678
- (stripos($this->useragent, $this->deviceAndroid) > -1) &&
679
- (stripos($this->useragent, $this->deviceTablet) > -1))
680
- return $this->true;
681
- else
682
- return $this->false;
683
- }
684
-
685
- //**************************
686
- // Detects whether the device supports WAP or WML.
687
- function DetectWapWml()
688
- {
689
- if (stripos($this->httpaccept, $this->vndwap) > -1 ||
690
- stripos($this->httpaccept, $this->wml) > -1)
691
- return $this->true;
692
- else
693
- return $this->false;
694
- }
695
-
696
- //**************************
697
- // Detects if the current device is an Amazon Kindle.
698
- function DetectKindle()
699
- {
700
- if (stripos($this->useragent, $this->deviceKindle) > -1)
701
- return $this->true;
702
- else
703
- return $this->false;
704
- }
705
-
706
-
707
- //**************************
708
- // The quick way to detect for a mobile device.
709
- // Will probably detect most recent/current mid-tier Feature Phones
710
- // as well as smartphone-class devices. Excludes Apple iPads and other modern tablets.
711
- function DetectMobileQuick()
712
- {
713
- //Let's exclude tablets
714
- if ($this->isTierTablet == $this->true)
715
- return $this->false;
716
-
717
- //Most mobile browsing is done on smartphones
718
- if ($this->DetectSmartphone() == $this->true)
719
- return $this->true;
720
-
721
- if (($this->DetectWapWml() == $this->true)
722
- || ($this->DetectBrewDevice() == $this->true)
723
- || ($this->DetectOperaMobile() == $this->true))
724
- return $this->true;
725
-
726
- if ((stripos($this->useragent, $this->engineNetfront) > -1)
727
- || (stripos($this->useragent, $this->engineUpBrowser) > -1)
728
- || (stripos($this->useragent, $this->engineOpenWeb) > -1))
729
- return $this->true;
730
-
731
- if (($this->DetectDangerHiptop() == $this->true)
732
- || ($this->DetectMidpCapable() == $this->true)
733
- || ($this->DetectMaemoTablet() == $this->true)
734
- || ($this->DetectArchos() == $this->true))
735
- return $this->true;
736
-
737
- if ((stripos($this->useragent, $this->devicePda) > -1) &&
738
- !(stripos($this->useragent, $this->disUpdate) > -1))
739
- return $this->true;
740
- if (stripos($this->useragent, $this->mobile) > -1)
741
- return $this->true;
742
-
743
- else
744
- return $this->false;
745
- }
746
-
747
- //**************************
748
- // Detects if the current device is a Sony Playstation.
749
- function DetectSonyPlaystation()
750
- {
751
- if (stripos($this->useragent, $this->devicePlaystation) > -1)
752
- return $this->true;
753
- else
754
- return $this->false;
755
- }
756
-
757
- //**************************
758
- // Detects if the current device is a Nintendo game device.
759
- function DetectNintendo()
760
- {
761
- if (stripos($this->useragent, $this->deviceNintendo) > -1 ||
762
- stripos($this->useragent, $this->deviceWii) > -1 ||
763
- stripos($this->useragent, $this->deviceNintendoDs) > -1)
764
- return $this->true;
765
- else
766
- return $this->false;
767
- }
768
-
769
- //**************************
770
- // Detects if the current device is a Microsoft Xbox.
771
- function DetectXbox()
772
- {
773
- if (stripos($this->useragent, $this->deviceXbox) > -1)
774
- return $this->true;
775
- else
776
- return $this->false;
777
- }
778
-
779
- //**************************
780
- // Detects if the current device is an Internet-capable game console.
781
- function DetectGameConsole()
782
- {
783
- if ($this->DetectSonyPlaystation() == $this->true)
784
- return $this->true;
785
- else if ($this->DetectNintendo() == $this->true)
786
- return $this->true;
787
- else if ($this->DetectXbox() == $this->true)
788
- return $this->true;
789
- else
790
- return $this->false;
791
- }
792
-
793
- //**************************
794
- // Detects if the current device supports MIDP, a mobile Java technology.
795
- function DetectMidpCapable()
796
- {
797
- if (stripos($this->useragent, $this->deviceMidp) > -1 ||
798
- stripos($this->httpaccept, $this->deviceMidp) > -1)
799
- return $this->true;
800
- else
801
- return $this->false;
802
- }
803
-
804
- //**************************
805
- // Detects if the current device is on one of the Maemo-based Nokia Internet Tablets.
806
- function DetectMaemoTablet()
807
- {
808
- if (stripos($this->useragent, $this->maemo) > -1)
809
- return $this->true;
810
- //For Nokia N810, must be Linux + Tablet, or else it could be something else.
811
- if ((stripos($this->useragent, $this->linux) > -1)
812
- && (stripos($this->useragent, $this->deviceTablet) > -1)
813
- && ($this->DetectWebOSTablet() == $this->false)
814
- && ($this->DetectAndroid() == $this->false))
815
- return $this->true;
816
- else
817
- return $this->false;
818
- }
819
-
820
- //**************************
821
- // Detects if the current device is an Archos media player/Internet tablet.
822
- function DetectArchos()
823
- {
824
- if (stripos($this->useragent, $this->deviceArchos) > -1)
825
- return $this->true;
826
- else
827
- return $this->false;
828
- }
829
-
830
- //**************************
831
- // Detects if the current browser is a Sony Mylo device.
832
- function DetectSonyMylo()
833
- {
834
- if (stripos($this->useragent, $this->manuSony) > -1)
835
- {
836
- if ((stripos($this->useragent, $this->qtembedded) > -1) ||
837
- (stripos($this->useragent, $this->mylocom2) > -1))
838
- {
839
- return $this->true;
840
- }
841
- else
842
- return $this->false;
843
- }
844
- else
845
- return $this->false;
846
- }
847
-
848
-
849
- //**************************
850
- // The longer and more thorough way to detect for a mobile device.
851
- // Will probably detect most feature phones,
852
- // smartphone-class devices, Internet Tablets,
853
- // Internet-enabled game consoles, etc.
854
- // This ought to catch a lot of the more obscure and older devices, also --
855
- // but no promises on thoroughness!
856
- function DetectMobileLong()
857
- {
858
- if ($this->DetectMobileQuick() == $this->true)
859
- return $this->true;
860
- if ($this->DetectGameConsole() == $this->true)
861
- return $this->true;
862
- if ($this->DetectSonyMylo() == $this->true)
863
- return $this->true;
864
-
865
- //Detect older phones from certain manufacturers and operators.
866
- if (stripos($this->useragent, $this->uplink) > -1)
867
- return $this->true;
868
- if (stripos($this->useragent, $this->manuSonyEricsson) > -1)
869
- return $this->true;
870
- if (stripos($this->useragent, $this->manuericsson) > -1)
871
- return $this->true;
872
-
873
- if (stripos($this->useragent, $this->manuSamsung1) > -1)
874
- return $this->true;
875
- if (stripos($this->useragent, $this->svcDocomo) > -1)
876
- return $this->true;
877
- if (stripos($this->useragent, $this->svcKddi) > -1)
878
- return $this->true;
879
- if (stripos($this->useragent, $this->svcVodafone) > -1)
880
- return $this->true;
881
-
882
- else
883
- return $this->false;
884
- }
885
-
886
-
887
-
888
- //*****************************
889
- // For Mobile Web Site Design
890
- //*****************************
891
-
892
- //**************************
893
- // The quick way to detect for a tier of devices.
894
- // This method detects for the new generation of
895
- // HTML 5 capable, larger screen tablets.
896
- // Includes iPad, Android (e.g., Xoom), BB Playbook, WebOS, etc.
897
- function DetectTierTablet()
898
- {
899
- if (($this->DetectIpad() == $this->true)
900
- || ($this->DetectAndroidTablet() == $this->true)
901
- || ($this->DetectBlackBerryTablet() == $this->true)
902
- || ($this->DetectWebOSTablet() == $this->true))
903
- return $this->true;
904
- else
905
- return $this->false;
906
- }
907
-
908
-
909
- //**************************
910
- // The quick way to detect for a tier of devices.
911
- // This method detects for devices which can
912
- // display iPhone-optimized web content.
913
- // Includes iPhone, iPod Touch, Android, WebOS, etc.
914
- function DetectTierIphone()
915
- {
916
- if (($this->isIphone == $this->true) ||
917
- ($this->isAndroidPhone == $this->true))
918
- return $this->true;
919
-
920
- if (($this->DetectBlackBerryWebKit() == $this->true) &&
921
- ($this->DetectBlackBerryTouch() == $this->true))
922
- return $this->true;
923
- if ($this->DetectPalmWebOS() == $this->true)
924
- return $this->true;
925
- if ($this->DetectGarminNuvifone() == $this->true)
926
- return $this->true;
927
- else
928
- return $this->false;
929
- }
930
-
931
- //**************************
932
- // The quick way to detect for a tier of devices.
933
- // This method detects for devices which are likely to be capable
934
- // of viewing CSS content optimized for the iPhone,
935
- // but may not necessarily support JavaScript.
936
- // Excludes all iPhone Tier devices.
937
- function DetectTierRichCss()
938
- {
939
- if ($this->DetectMobileQuick() == $this->true)
940
- {
941
- if (($this->DetectTierIphone() == $this->true))
942
- return $this->false;
943
-
944
- //The following devices are explicitly ok.
945
- if ($this->DetectWebkit() == $this->true) //Any WebKit
946
- return $this->true;
947
- if ($this->DetectS60OssBrowser() == $this->true)
948
- return $this->true;
949
-
950
- //Note: 'High' BlackBerry devices ONLY
951
- if ($this->DetectBlackBerryHigh() == $this->true)
952
- return $this->true;
953
-
954
- //WP7's IE-7-based browser isn't good enough for iPhone Tier.
955
- if ($this->DetectWindowsPhone7() == $this->true)
956
- return $this->true;
957
- if ($this->DetectWindowsMobile() == $this->true)
958
- return $this->true;
959
- if (stripos($this->useragent, $this->engineTelecaQ) > -1)
960
- return $this->true;
961
-
962
- //default
963
- else
964
- return $this->false;
965
- }
966
- else
967
- return $this->false;
968
- }
969
-
970
- //**************************
971
- // The quick way to detect for a tier of devices.
972
- // This method detects for all other types of phones,
973
- // but excludes the iPhone and RichCSS Tier devices.
974
- function DetectTierOtherPhones()
975
- {
976
- //Exclude devices in the other 2 categories
977
- if (($this->DetectMobileLong() == $this->true)
978
- && ($this->DetectTierIphone() == $this->false)
979
- && ($this->DetectTierRichCss() == $this->false))
980
- return $this->true;
981
- else
982
- return $this->false;
983
- }
984
-
985
-
986
- }
987
-
988
-
989
- //Was informed by a MobileESP user that it's a best practice
990
- // to omit the closing ?&gt; marks here. They can sometimes
991
- // cause errors with HTML headers.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -1,53 +1,55 @@
1
  === Video Embed & Thumbnail Generator ===
2
  Contributors: kylegilman
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=kylegilman@gmail.com&item_name=Video%20Embed%20And%20Thumbnail%20Generator%20Plugin%20Donation/
4
- Tags: video, html5, shortcode, thumbnail, ffmpeg, embed, mobile, webm, ogg, h.264
5
- Requires at least: 3.0
6
- Tested up to: 3.3.2
7
- Stable tag: 2.0.6
 
 
8
 
9
- Generates thumbnails, HTML5-compliant videos, and embed codes for locally hosted videos. Requires FFMPEG for thumbnails and encodes.
10
 
11
  == Description ==
12
 
13
  = A plugin to make embedding videos, generating thumbnails, and encoding HTML5-compliant files a little bit easier. =
14
 
15
- The plugin adds several fields to any video uploaded to the WordPress Media Library. Just choose a few options and click Insert into Post to and you'll get a shortcode in your post that will embed a flexible Flash & HTML5 video player with a preview image into your post.
16
 
17
- The embedded player will default to a Flash video player if you're using a Flash-compatible file (flv, f4v, mp4, mov, or m4v). Otherwise it will use an HTML5 video element. I highly recommend H.264 video and AAC audio in an MP4 container. If you're encoding with Apple's Compressor, the "Streaming" setting should be "Fast Start" (NOT Fast Start - Compressed Header). I've written up my recommended video encode settings in <a href="http://www.kylegilman.net/2011/02/25/making-mp4-h-264-videos-in-apple-compressor/">a post on my website</a>.
18
 
19
- The plugin uses FFMPEG to generate thumbnails and encode HTML5/mobile videos. By default the plugin looks for FFMPEG in `/usr/local/bin` but if FFMPEG is installed in a different place on your server, you can point it to the correct place in the plugin settings. Users running WordPress on Windows servers should try using Linux-style paths (with forward slashes instead of backslashes and a forward slash instead of C:\)
20
 
21
- If FFMPEG is installed on your server, you can generate thumbnails using either the "Generate" or "Randomize" buttons. The "Generate" button will always generate thumbnails from the same frames of your video, evenly spaced. If you don't like them you can randomize the results with the "Randomize" button. If you want to see the first frame of the video, check the "Force 1st Frame Thumbnail" button. If you want really fine control you can enter timecode in the "Thumbnail Timecode" field. Use mm:ss format. If you want even more control you can use decimals to approximate frames. For example, `23.5` will generate a thumbnail halfway between the 23rd and 24th seconds in the video. `02:23.25` would be one quarter of the way between the 143rd and 144th seconds. You can generate as many or as few as you need (up to 9 at a time). The unused thumbnails will be deleted once you click "Insert into Post" or "Save Changes."
22
 
23
- In the plugin settings you can set the default maximum width based on the width of your particular template and those values will be filled in when you open the window. If you generate thumbnails, the video display dimensions will be automatically adjusted to match the size and aspect ratio of the video file. You can make further adjustments if you want.
24
 
25
- The "Encode" button is still a bit experimental. If you have FFMPEG on your server, clicking the button will start encoding an iPod/iPad/Android compliant H.264 video (which will also work in Safari and IE 9), or a Firefox/Chrome-compatible WEBM or OGV video in the same directory as your original file. Anyone using a modern browser who doesn't have a Flash plugin will see these files instead of the original. The files will encode in the background and will take several minutes to complete, depending on your server setup and the length and size of your video. New in version 2.0, you will see the encoding progress, you will have the option to cancel an encoding job, and you should get an error message if something goes wrong. Closing the window will not cancel encoding, but once the window is closed the progress bar won't come back. Users on Windows servers will not get any feedback while the files are encoding.
26
 
27
- Also new in this version is the option to encode an HD Mobile/H.264 file. Since there are more devices that can handle HD H.264 videos available now, you can choose to increase the resolution to 720p or 1080p. Keep in mind, very few mobile devices can currently play 1080p video.
28
 
29
- The plugin is currently favoring Flash instead of HTML5 because Flash is a better user experience in most cases. I'm particularly not a fan of some browsers' tendencies to auto-download HTML5 video elements. I may eventually include the option to favor HTML5. However, if you embed a non-Flash compatible file (like an ogv or webm file) then you will only get the HTML5 video element. If you want to make ogv, webm, or H.264 files available and can't use the FFMPEG encode button, you can upload your own files to the same directory as the original and the plugin will automatically find them. For example, if your main file is awesomevid.mp4, the plugin will look for awesomevid.webm and awesomevid.ogv as well. If you want to embed a high-res H.264 video but also make a mobile-compatible version available, add -ipod.m4v to the end of the filename (awesomevid-ipod.m4v) and it will be served up to most smartphones and tablets instead of the original.
30
 
31
- Android viewers who don't use Flash will see a play button superimposed on the thumbnail to make it a little clearer that it's an embedded video.
32
 
33
- If you have Mobile, WEBM, or OGV files encoded, you will have the option to embed one of those files instead of the original. This is for a small group of users who need to upload a file format that can't be embedded and want to replace that file with a newly encoded file. No matter which option you choose, any other encoded files will still be automatically swapped in on the appropriate devices and browsers.
 
 
34
 
35
  If you want to make it easier for people to save the video to their computers, you can choose to include a link by checking the "Generate Download Link Below Video" button.
36
 
37
- Sometimes for various reasons you might need to embed video files that are not saved in the Wordpress Media Library. Maybe your file is too large to upload through the media upload form, or maybe it's hosted on another server. Either way, you can use the tab "Embed from URL" in the Add Media window. Just enter the Video URL manually, and all other steps are the same as the Media Library options. If the video is in a directory that isn't writable, any encodes you make will go to an "html5encodes" subdirectory in the Wordpress uploads directory.
38
 
39
  = Once you've filled in all your options, click "Insert into Post" and you'll get a shortcode in the visual editor like this =
40
 
41
- `[FMP poster="http://www.kylegilman.net/wp-content/uploads/2011/10/Reel-11-10-10-web_thumb2.jpg"
42
- width="720" height="404"]http://www.kylegilman.net/wp-content/uploads/2011/10/Reel-11-10-10-web.mp4[/FMP]`
43
-
44
- After you save the post, the thumbnail file will be registered in the Wordpress Media Library and added to the post's attachments. Thumbnails are saved in the current Wordpress uploads directory. Encoded videos are not yet registered with the media library.
45
 
46
  = To embed videos on other sites = turn on the Attachment Template Override in the plugin settings. This will replace your video attachment template with a page that only has enough code to display the video. You can then embed the video using code like this
47
 
48
  `<iframe width="960" height="540" frameborder="0" scrolling="no" src="http://www.kylegilman.net/?attachment_id=1906"></iframe>`
49
 
50
- = If you want to further modify the way the video player works, you can add the following options inside the [FMP] tag. These will override anything you’ve set in the plugin settings. =
51
 
52
  * `poster="http://www.example.com/image.jpg"` sets the thumbnail.
53
  * `width="xxx"`
@@ -56,7 +58,12 @@ After you save the post, the thumbnail file will be registered in the Wordpress
56
  * `loop="true/false"`
57
  * `autoplay="true/false"`
58
 
59
- = These options will only affect Flash video elements. They will have no effect on HTML5 videos. =
 
 
 
 
 
60
 
61
  * `endofvideooverlay="http://www.example.com/end_image.jpg` sets the image shown when the video ends.
62
  * `autohide="true/false"` specify whether to autohide the control bar after a few seconds.
@@ -67,6 +74,15 @@ After you save the post, the thumbnail file will be registered in the Wordpress
67
  * `configuration="http://www.example.com/config.xml"` Lets you specify all these flashvars in an XML file.
68
  * `skin="http://www.example.com/skin.xml"` Completely change the look of the video player. <a href="http://www.longtailvideo.com/support/jw-player/jw-player-for-flash-v5/14/building-skins">Instructions here.</a>
69
 
 
 
 
 
 
 
 
 
 
70
  I'm not really a software developer. I'm just a film editor with some time on his hands who wanted to post video for clients and wasn't happy with the current state of any available software. But I want to really make this thing work, so please help me out by posting your feedback in the comments.
71
 
72
  == Installation ==
@@ -87,7 +103,7 @@ Most of the time your video doesn't play because it's not encoded in the right f
87
 
88
  If you recorded the video using a Samsung Galaxy S II phone, even though most programs will tell you it's H.264 video with AAC audio, there's a good chance that it's actually recorded in 3gp4 format, which won't work with the Flash player. Use MediaInfo Library to get really detailed information about your media files.
89
 
90
- The Flash player will not play mp4/m4v/mov files that don't have the MooV atom at the head of the file. FFMPEG puts the moov atom at the end of the file, so this can be a problem. I'm working on a solution for an upcoming version of the plugin.
91
 
92
  = Why doesn't this work with YouTube? =
93
 
@@ -101,19 +117,35 @@ Some of it will work without FFMPEG. You can generate embed codes for your video
101
 
102
  Use the "Embed from URL" tab. Use the format http://username:password@yourdomain.com/uploads/2012/01/awesomevid.mp4 in the Video URL field.
103
 
104
- = Why doesn't the encoding progress bar work on Windows servers? =
105
-
106
- Because I can't figure out how to do it. Windows works a little differently from Linux, and I don't understand it enough to get it to work.
107
-
108
  == Screenshots ==
109
 
110
- 1. Thumbnail & Embed Options in the Media Library/Insert Video page.
111
- 2. Encoding in progress.
112
- 3. "Embed from Url" tab.
113
  4. Shortcode inserted into the post content by the plugin.
114
 
115
  == Changelog ==
116
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
  = 2.0.6 - April 27, 2012 =
118
  * Removed swfobject.js from the plugin package. Now using the one included with WordPress. WordPress 3.3.2 contains a security fix for swfobject.js and the plugin will use the fixed version if you have upgraded WordPress (which is highly recommended).
119
  * Added setting to customize the formatting of titles inserted by the plugin.
@@ -196,4 +228,8 @@ Because I can't figure out how to do it. Windows works a little differently from
196
 
197
  == Upgrade Notice ==
198
 
199
- = 2.0 = Fixes several security issues.
 
 
 
 
1
  === Video Embed & Thumbnail Generator ===
2
  Contributors: kylegilman
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=kylegilman@gmail.com&item_name=Video%20Embed%20And%20Thumbnail%20Generator%20Plugin%20Donation/
4
+ Tags: video, video gallery, html5, shortcode, thumbnail, ffmpeg, libav, embed, mobile, webm, ogg, h.264
5
+ Requires at least: 3.5
6
+ Tested up to: 3.5
7
+ Stable tag: 3.0
8
+ License: GPLv2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
+ Generates thumbnails, HTML5-compliant videos, and embed codes for locally hosted videos. Requires FFMPEG or LIBAV for thumbnails and encodes.
12
 
13
  == Description ==
14
 
15
  = A plugin to make embedding videos, generating thumbnails, and encoding HTML5-compliant files a little bit easier. =
16
 
17
+ The plugin adds several fields to any video uploaded to the WordPress Media Library. Just choose a few options and click Insert into Post and you'll get a shortcode in the post editor that will embed a flexible HTML5/Flash video player with a preview image.
18
 
19
+ Version 3.0 of the plugin adds the option to use Video.js instead of Adobe's Strobe Media Playback. Video.js is a lightweight, flexible HTML5 player that uses Flash only if the browser can't find any compatible video formats. The HTML5 player is styled the same in all browsers and is easily customizable. The Strobe Media Playback option will default to a Flash video player if you're using a Flash-compatible file (flv, f4v, mp4, mov, or m4v). Otherwise it will use an unstyled HTML5 video element.
20
 
21
+ New in version 3.0 is the ability to create a popup video gallery. The short code uses similar options to the WordPress image gallery shortcode. In its simplest form use the code `[KGVID gallery="true"][/KGVID]` to create a gallery of all videos attached to the post. Thumbnail size and video popup size can be set on the plugin settings page.
22
 
23
+ The plugin uses FFMPEG or LIBAV to generate thumbnails and encode HTML5/mobile videos. By default the plugin looks for FFMPEG in `/usr/local/bin` but if the application is installed in a different place on your server, you can point it to the correct place in the plugin settings. Users running WordPress on Windows servers should try using Linux-style paths (with forward slashes instead of backslashes and a forward slash instead of C:\)
24
 
25
+ If FFMPEG is installed on your server, you can generate thumbnails using either the "Generate" or "Randomize" buttons. The "Generate" button will always generate thumbnails from the same frames of your video, evenly spaced. If you don't like them you can randomize the results with the "Randomize" button. If you want to see the first frame of the video, check the "Force 1st Frame Thumbnail" button. If you want really fine control you can enter timecode in the "Thumbnail Timecode" field. Use mm:ss format. If you want even more control you can use decimals to approximate frames. For example, `23.5` will generate a thumbnail halfway between the 23rd and 24th seconds in the video. `02:23.25` would be one quarter of the way between the 143rd and 144th seconds. You can generate as many or as few as you need (up to 99 at a time). The unused thumbnails will be deleted after you click "Insert into Post" or "Save Changes."
26
 
27
+ In the plugin settings you can set the default maximum width and height based on the dimensions of your particular template and those values will be filled in when you open the window. If you generate thumbnails, the video display dimensions will be adjusted automatically to match the size and aspect ratio of the video file. You can make further adjustments if you want. After you choose a thumbnail it will be registered in the Wordpress Media Library and added to the post's attachments.
28
 
29
+ I highly recommend starting with H.264 video and AAC audio in an MP4 container. If you're encoding with Apple's Compressor, the "Streaming" setting should be "Fast Start" (NOT Fast Start - Compressed Header). I've written up my recommended video encode settings in <a href="http://www.kylegilman.net/2011/02/25/making-mp4-h-264-videos-in-apple-compressor/">a post on my website</a>.
30
 
31
+ If you have FFMPEG or LIBAV and the proper libraries installed, you can choose to encode your uploaded video into as many as five additional formats depending on your original source. 1080p, 720p, or up to 480p H.264, WEBM, and OGV. Different browsers have different playback capabilities. Most desktop browsers can play H.264, and all modern mobile devices can play at least 480p H.264. If you create multiple H.264 resolutions, the highest resolution supported by the device will be served up automatically. The plugin will not upconvert your video, so if you upload a 720p video, it will not waste your time creating a 1080p version. There was a time when it seemed like a good idea to provide OGV or WEBM for some desktop browsers, but even Firefox is planning to allow H.264 playback in the future and I no longer recommend encoding OGV or WEBM unless you expect a large number of no-Flash sticklers visiting your site.
32
 
33
+ The files will encode in the background and will take several minutes to complete, depending on your server setup and the length and size of your video. New in version 3.0 is a basic encoding queue available from the Tools menu. You will see encoding progress, the option to cancel an encoding job, and you should get an error message if something goes wrong. Users on Windows servers may get inconsistent results with the encoding queue.
34
 
35
+ New in version 3.0, encoded H.264 files will be fixed for streaming using qt-faststart or MP4Box if you have one of them installed in the same directory as your encoder and select it in the plugin settings. Without one of these applications, FFMPEG & LIBAV will place moov atoms at the end of H.264 encoded files, which forces the entire file to download before playback can start and prevents the Flash player from playing them at all.
36
+
37
+ If you want to make ogv, webm, or H.264 files available and can't use the FFMPEG encode button, you can upload your own files to the same directory as the original and the plugin will automatically find them. For example, if your main file is awesomevid.mp4, the plugin will look for awesomevid-1080.m4v, awesomevid-720.m4v, awesomevid-ipod.m4v (up to 480p H.264), awesomevid.webm and awesomevid.ogv as well.
38
 
39
  If you want to make it easier for people to save the video to their computers, you can choose to include a link by checking the "Generate Download Link Below Video" button.
40
 
41
+ Sometimes for various reasons you might need to embed video files that are not saved in the Wordpress Media Library. Maybe your file is too large to upload through the media upload form (if it is, I suggest the excellent "Add From Server" plugin), or maybe it's hosted on another server. Either way, you can use the tab "Embed Video From URL" in the Add Media window. Just enter the Video URL manually, and all other steps are the same as the Media Library options. If the video is in a directory that isn't writable, any encodes you make will go to an "html5encodes" subdirectory in the Wordpress uploads directory.
42
 
43
  = Once you've filled in all your options, click "Insert into Post" and you'll get a shortcode in the visual editor like this =
44
 
45
+ `[KGVID poster="http://www.kylegilman.net/wp-content/uploads/2011/10/Reel-11-10-10-web_thumb2.jpg"
46
+ width="720" height="404"]http://www.kylegilman.net/wp-content/uploads/2011/10/Reel-11-10-10-web.mp4[/KGVID]`
 
 
47
 
48
  = To embed videos on other sites = turn on the Attachment Template Override in the plugin settings. This will replace your video attachment template with a page that only has enough code to display the video. You can then embed the video using code like this
49
 
50
  `<iframe width="960" height="540" frameborder="0" scrolling="no" src="http://www.kylegilman.net/?attachment_id=1906"></iframe>`
51
 
52
+ = If you want to further modify the way the video player works, you can add the following options inside the [FMP] tag. These will override anything you�'ve set in the plugin settings. =
53
 
54
  * `poster="http://www.example.com/image.jpg"` sets the thumbnail.
55
  * `width="xxx"`
58
  * `loop="true/false"`
59
  * `autoplay="true/false"`
60
 
61
+ = These options will only affect Video.js playback =
62
+
63
+ * `skin="example-css-class"` Completely change the look of the video player. <a href="https://github.com/zencoder/video-js/blob/master/docs/skins.md">Instructions here.</a>
64
+ * `volume="0.5"` Pre-set the volume for unusually loud videos. Value between 0 and 1.
65
+
66
+ = These options will only affect Flash playback in Strobe Media Playback video elements. They will have no effect on HTML5 or Video.js playback. =
67
 
68
  * `endofvideooverlay="http://www.example.com/end_image.jpg` sets the image shown when the video ends.
69
  * `autohide="true/false"` specify whether to autohide the control bar after a few seconds.
74
  * `configuration="http://www.example.com/config.xml"` Lets you specify all these flashvars in an XML file.
75
  * `skin="http://www.example.com/skin.xml"` Completely change the look of the video player. <a href="http://www.longtailvideo.com/support/jw-player/jw-player-for-flash-v5/14/building-skins">Instructions here.</a>
76
 
77
+ = These options are available for video galleries =
78
+
79
+ * `gallery_thumb="xxx"` width in pixels to display gallery thumbnails
80
+ * `gallery_exclude="15"` comma separated video attachment IDs. Excludes the videos from the gallery.
81
+ * `gallery_include="65"` comma separated video attachment IDs. Includes only these videos in the gallery. Please note that include and exclude cannot be used together.
82
+ * `gallery_orderby="menu_order/title/post_date/rand/ID"` criteria for sorting the gallery
83
+ * `gallery_order="ASC/DESC"` sort order
84
+ * `gallery_id="241"` post ID to display a gallery made up of videos associated with a different post
85
+
86
  I'm not really a software developer. I'm just a film editor with some time on his hands who wanted to post video for clients and wasn't happy with the current state of any available software. But I want to really make this thing work, so please help me out by posting your feedback in the comments.
87
 
88
  == Installation ==
103
 
104
  If you recorded the video using a Samsung Galaxy S II phone, even though most programs will tell you it's H.264 video with AAC audio, there's a good chance that it's actually recorded in 3gp4 format, which won't work with the Flash player. Use MediaInfo Library to get really detailed information about your media files.
105
 
106
+ The Strobe Media Playback Flash player will not play mp4/m4v/mov files that don't have the MooV atom at the head of the file. FFMPEG puts the moov atom at the end of the file, so this can be a problem. Version 3.0 of the plugin will fix this problem if you have qt-faststart or MP4Box installed on your server.
107
 
108
  = Why doesn't this work with YouTube? =
109
 
117
 
118
  Use the "Embed from URL" tab. Use the format http://username:password@yourdomain.com/uploads/2012/01/awesomevid.mp4 in the Video URL field.
119
 
 
 
 
 
120
  == Screenshots ==
121
 
122
+ 1. Thumbnails in the Add Media modal.
123
+ 2. Video Options in the Add Media modal.
124
+ 3. Encoding Queue.
125
  4. Shortcode inserted into the post content by the plugin.
126
 
127
  == Changelog ==
128
 
129
+ = 3.0 - January 23, 2012 =
130
+ * Updated to provide compatibility with several media changes in WordPress 3.5. With this version, thumbnail generating & video encoding will only work in WordPress 3.5 and above.
131
+ * Added popup video gallery.
132
+ * Changed shortcode tag to [KGVID]. Retained [FMP] for backwards compatibility.
133
+ * Added Video.js player option. Older Strobe Media Playback Flash player is still included for backwards compatibility, but Video.js is highly recommended.
134
+ * Added video play counting which is recorded to the WordPress database (Video.js only).
135
+ * Added Google Analytics event tracking for video plays (Video.js only)
136
+ * Added ability to encode multiple H.264 video resolutions.
137
+ * Added video encoding queue.
138
+ * Added qt-faststart and MP4Box processing to MP4/M4V H.264 videos encoded by the plugin to allow playback of videos as they download.
139
+ * Added option to change default number of thumbnails generated by the plugin.
140
+ * Changed any https FFMPEG input to http.
141
+ * Thumbnail images are now added to the WordPress database as soon as they are selected.
142
+ * Added option to use LIBAV instead of FFMPEG for thumbnail generating and video encoding.
143
+ * Added wmode parameter to fix Chrome z-index issue. (Strobe Media Playback only)
144
+ * Improved swfobject.js script enqueuing method to prevent conflicts (Strobe Media Playback only)
145
+ * Rewrote plugin settings to work with the WordPress plugin settings API.
146
+ * Removed dropdown list for embedding alternate encoded formats of video. All formats are made available to the player and the browser chooses best compatible format.
147
+ * Removed mdetect.php and removed forced downgrading of quality when on mobile devices. Mobile browsers now automatically choose best compatible format.
148
+
149
  = 2.0.6 - April 27, 2012 =
150
  * Removed swfobject.js from the plugin package. Now using the one included with WordPress. WordPress 3.3.2 contains a security fix for swfobject.js and the plugin will use the fixed version if you have upgraded WordPress (which is highly recommended).
151
  * Added setting to customize the formatting of titles inserted by the plugin.
228
 
229
  == Upgrade Notice ==
230
 
231
+ = 3.0 =
232
+ Fixes thumbnails & encodes in WP 3.5. Not compatible with earlier WP versions.
233
+
234
+ = 2.0 =
235
+ Fixes several security issues.
screenshot-1.jpg CHANGED
Binary file
screenshot-2.jpg CHANGED
Binary file
screenshot-3.jpg CHANGED
Binary file
screenshot-4.jpg CHANGED
Binary file
video-embed-thumbnail-generator.css DELETED
@@ -1,171 +0,0 @@
1
- .meter, .meter_finished {
2
- margin-top: 5px;
3
- height: 18px;
4
- width: 280px;
5
- display: inline-block;
6
- position: relative;
7
- background: #e4e4e4;
8
- -moz-border-radius: 12px;
9
- -webkit-border-radius: 12px;
10
- border-radius: 12px;
11
- padding: 5px;
12
- -webkit-box-shadow: inset 0 -1px 1px rgba(255,255,255,0.3);
13
- -moz-box-shadow : inset 0 -1px 1px rgba(255,255,255,0.3);
14
- box-shadow : inset 0 -1px 1px rgba(255,255,255,0.3);
15
- }
16
-
17
- .meter > span {
18
- text-align: right;
19
- padding-right: 5px;
20
- font-weight: bold;
21
- color: white;
22
- font-size: 80%;
23
- display: inline-block;
24
- height: 100%;
25
- -webkit-border-top-right-radius: 4px;
26
- -webkit-border-bottom-right-radius: 4px;
27
- -moz-border-radius-topright: 4px;
28
- -moz-border-radius-bottomright: 4px;
29
- border-top-right-radius: 4px;
30
- border-bottom-right-radius: 4px;
31
- -webkit-border-top-left-radius: 10px;
32
- -webkit-border-bottom-left-radius: 10px;
33
- -moz-border-radius-topleft: 10px;
34
- -moz-border-radius-bottomleft: 10px;
35
- border-top-left-radius: 10px;
36
- border-bottom-left-radius: 10px;
37
- background-color: rgb(41,140,186);
38
- background-image: -webkit-gradient(
39
- linear,
40
- left bottom,
41
- left top,
42
- color-stop(0, rgb(41,140,186)),
43
- color-stop(1, rgb(64,176,228))
44
- );
45
- background-image: -webkit-linear-gradient(
46
- center bottom,
47
- rgb(41,140,186) 37%,
48
- rgb(64,176,228) 69%
49
- );
50
- background-image: -moz-linear-gradient(
51
- center bottom,
52
- rgb(41,140,186) 37%,
53
- rgb(64,176,228) 69%
54
- );
55
- background-image: -ms-linear-gradient(
56
- center bottom,
57
- rgb(41,140,186) 37%,
58
- rgb(64,176,228) 69%
59
- );
60
- background-image: -o-linear-gradient(
61
- center bottom,
62
- rgb(41,140,186) 37%,
63
- rgb(64,176,228) 69%
64
- );
65
- -webkit-box-shadow:
66
- inset 0 2px 9px rgba(255,255,255,0.3),
67
- inset 0 -2px 6px rgba(0,0,0,0.4);
68
- -moz-box-shadow:
69
- inset 0 2px 9px rgba(255,255,255,0.3),
70
- inset 0 -2px 6px rgba(0,0,0,0.4);
71
- position: relative;
72
- overflow: hidden;
73
- }
74
-
75
-
76
- .meter_finished > span {
77
- text-align: center;
78
- font-weight: bold;
79
- color: white;
80
- font-size: 80%;
81
- display: inline-block;
82
- height: 100%;
83
- -webkit-border-top-right-radius: 10px;
84
- -webkit-border-bottom-right-radius: 10px;
85
- -moz-border-radius-topright: 10px;
86
- -moz-border-radius-bottomright: 10px;
87
- border-top-right-radius: 10px;
88
- border-bottom-right-radius: 10px;
89
- -webkit-border-top-left-radius: 10px;
90
- -webkit-border-bottom-left-radius: 10px;
91
- -moz-border-radius-topleft: 10px;
92
- -moz-border-radius-bottomleft: 10px;
93
- border-top-left-radius: 10px;
94
- border-bottom-left-radius: 10px;
95
- background-color: rgb(41,140,186);
96
- background-image: -webkit-gradient(
97
- linear,
98
- left bottom,
99
- left top,
100
- color-stop(0, rgb(41,140,186)),
101
- color-stop(1, rgb(41,140,186))
102
- );
103
- background-image: -webkit-linear-gradient(
104
- center bottom,
105
- rgb(41,140,186) 37%,
106
- rgb(41,140,186) 69%
107
- );
108
- background-image: -moz-linear-gradient(
109
- center bottom,
110
- rgb(41,140,186) 37%,
111
- rgb(41,140,186) 69%
112
- );
113
- background-image: -ms-linear-gradient(
114
- center bottom,
115
- rgb(41,140,186) 37%,
116
- rgb(41,140,186) 69%
117
- );
118
- background-image: -o-linear-gradient(
119
- center bottom,
120
- rgb(41,140,186) 37%,
121
- rgb(41,140,186) 69%
122
- );
123
- -webkit-box-shadow:
124
- inset 0 2px 9px rgba(255,255,255,0.3),
125
- inset 0 -2px 6px rgba(0,0,0,0.4);
126
- -moz-box-shadow:
127
- inset 0 2px 9px rgba(255,255,255,0.3),
128
- inset 0 -2px 6px rgba(0,0,0,0.4);
129
- position: relative;
130
- overflow: hidden;
131
- }
132
-
133
- div.kg_thumbnail_box {
134
- border-style:solid;
135
- border-color:#ccc;
136
- border-width:1px;
137
- width:425px;
138
- text-align:center;
139
- margin-bottom:10px;
140
- padding:5px;
141
- }
142
-
143
- div.kg_thumbnail_overlay {
144
- width: 100%;
145
- height:100%;
146
- background: #fff;
147
- opacity: 0.5;
148
- filter: alpha(opacity = 50); /* required for opacity to work in IE */
149
- }
150
-
151
- div.kg_thumbnail_select {
152
- text-align:center;
153
- display:inline-block;
154
- }
155
-
156
- img.kg_thumbnail {
157
- margin:2px;
158
- }
159
-
160
- .kg_embedselect {
161
- border-left:2px solid #ccc;
162
- display:inline;
163
- padding-left:8px;
164
- }
165
-
166
- div.kg_cancel_button {
167
- display:inline-block;
168
- vertical-align:top;
169
- margin-top:7px;
170
- padding-left:5px;
171
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
video-embed-thumbnail-generator.php CHANGED
@@ -2,8 +2,8 @@
2
  /*
3
  Plugin Name: Video Embed & Thumbnail Generator
4
  Plugin URI: http://www.kylegilman.net/2011/01/18/video-embed-thumbnail-generator-wordpress-plugin/
5
- Description: Generates thumbnails, HTML5-compliant videos, and embed codes for locally hosted videos. Requires FFMPEG for thumbnails and encodes. <a href="options-general.php?page=video-embed-thumbnail-generator.php">Settings</a> | <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=kylegilman@gmail.com&item_name=Video%20Embed%20And%20Thumbnail%20Generator%20Plugin%20Donation/">Donate</a>
6
- Version: 2.0.6
7
  Author: Kyle Gilman
8
  Author URI: http://www.kylegilman.net/
9
 
@@ -24,38 +24,98 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24
  1) Includes Strobe Media Playback Flash Player
25
  Website: http://osmf.org/strobe_mediaplayback.html
26
  License: http://creativecommons.org/licenses/by-nc/3.0/
27
- 2) Includes Geoff Stearns' SWFObject Javascript Library (MIT License) v2.1
28
- Website: http://code.google.com/p/swfobject/
29
- License: http://www.opensource.org/licenses/mit-license.php
30
- 3) Includes code adapted from Joshua Eldridge's Flash Media Player Plugin
31
  Website: http://wordpress.org/extend/plugins/flash-video-player/
32
- 4) Includes code adapted from Gary Cao's Make Shortcodes User-Friendly tutorial
33
  Website: http://www.wphardcore.com/2010/how-to-make-shortcodes-user-friendly/
34
- 5) Includes code adapted from Justin Gable's "Modifying Wordpress' Default Method for Inserting Media"
35
  Website: http://justingable.com/2008/10/03/modifying-wordpress-default-method-for-inserting-media/
36
- 6) Includes MobileESP class, Apache License 2.0
37
- Website: http://blog.mobileesp.com/
38
-
 
 
39
  */
40
 
41
  if ( ! defined( 'ABSPATH' ) )
42
  die( "Can't load this file directly" );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
 
44
- function kg_add_upload_mimes ( $existing_mimes=array() ) {
45
 
46
  // allows uploading .webm videos
47
  $existing_mimes['webm'] = 'video/webm';
48
  return $existing_mimes;
49
 
50
  }
51
- add_filter('upload_mimes', 'kg_add_upload_mimes');
52
 
53
- function url_exists($url) {
54
  $hdrs = @get_headers($url);
55
  return is_array($hdrs) ? preg_match('/^HTTP\\/\\d+\\.\\d+\\s+2\\d\\d\\s+.*$/',$hdrs[0]) : false;
56
  }
57
 
58
- function is_empty_dir($dir)
59
  {
60
  if ($dh = @opendir($dir))
61
  {
@@ -72,7 +132,7 @@ function is_empty_dir($dir)
72
  else return false; // whatever the reason is : no such dir, not a dir, not readable
73
  }
74
 
75
- function kg_explodeX($delimiters,$string)
76
  {
77
  $return_array = Array($string); // The array to return
78
  $d_count = 0;
@@ -93,12 +153,12 @@ function kg_explodeX($delimiters,$string)
93
  return $return_array; // Return the exploded elements
94
  }
95
 
96
- function rrmdir($dir) {
97
  if (is_dir($dir)) {
98
  $objects = scandir($dir);
99
  foreach ($objects as $object) {
100
  if ($object != "." && $object != "..") {
101
- if (filetype($dir."/".$object) == "dir") rrmdir($dir."/".$object); else unlink($dir."/".$object);
102
  }
103
  }
104
  reset($objects);
@@ -106,41 +166,47 @@ function rrmdir($dir) {
106
  }
107
  }
108
 
109
- function kg_check_ffmpeg_exists() {
110
-
111
  $exec_enabled = false;
112
  $ffmpeg_exists = false;
113
  $output = array();
114
- $ffmpeg_path = get_option('wp_FMP_ffmpeg');
115
  $uploads = wp_upload_dir();
116
 
117
  if(function_exists('exec')) {
118
- $exec_enabled = true;
119
- exec ( get_option('wp_FMP_ffmpeg').'/ffmpeg -i '.plugins_url("", __FILE__).'/flash/skin/images/PlayNormal.png '.$uploads['path'].'/ffmpeg_exists_test.jpg', $output, $returnvalue );
 
 
120
  }
121
 
122
  if ( $exec_enabled == true && file_exists($uploads['path'].'/ffmpeg_exists_test.jpg') ) { //if FFMPEG has executed successfully
123
- update_option('wp_FMP_ffmpeg_exists', "true");
124
  $ffmpeg_exists = true;
125
  unlink($uploads['path'].'/ffmpeg_exists_test.jpg');
126
  }
127
- else { update_option('wp_FMP_ffmpeg_exists', "notinstalled"); }
128
 
129
- $output_output = implode("/n", $output);
 
 
 
 
130
 
 
131
  $arr = array ("exec_enabled"=>$exec_enabled, "ffmpeg_exists"=>$ffmpeg_exists, "return_value"=>$returnvalue, "output"=>$output_output);
132
-
133
  return $arr;
134
  }
135
 
136
- function kg_encodevideo_info($movieurl, $postID) {
 
 
137
 
138
  $uploads = wp_upload_dir();
139
  $movie_extension = pathinfo(parse_url($movieurl, PHP_URL_PATH), PATHINFO_EXTENSION);
 
140
  $encodevideo_info['moviefilebasename'] = basename($movieurl,'.'.$movie_extension);
141
  $moviefilepath = str_replace(" ", "%20", $movieurl);
 
142
 
143
- if ($postID != "singleurl") { //if it's an attachment, not from URL
144
  $moviefile = get_attached_file($postID);
145
  $path_parts = pathinfo($moviefile);
146
  $encodevideo_info['encodepath'] = $path_parts['dirname']."/";
@@ -167,71 +233,35 @@ function kg_encodevideo_info($movieurl, $postID) {
167
  }
168
  }
169
 
170
- $movieurl_noextension = preg_replace("/\\.[^.\\s]{3,4}$/", "", $movieurl);
171
- $encodevideo_info['mobileurl'] = $movieurl_noextension."-ipod.m4v";
172
- $encodevideo_info['oggurl'] = $movieurl_noextension.".ogv";
173
- $encodevideo_info['webmurl'] = $movieurl_noextension.".webm";
174
-
175
  if ( !is_writable($encodevideo_info['encodepath']) ) { //if the original directory is not writable use a directory in base wp_upload
176
  $encodevideo_info['encodepath'] = $uploads['basedir']."/html5encodes/";
177
  $encodevideo_info['html5encodes'] = true;
178
- $encodevideo_info['mobileurl'] = $uploads['baseurl']."/html5encodes/".$encodevideo_info['moviefilebasename']."-ipod.m4v";
179
- $encodevideo_info['oggurl'] = $uploads['baseurl']."/html5encodes/".$encodevideo_info['moviefilebasename'].".ogv";
180
- $encodevideo_info['webmurl'] = $uploads['baseurl']."/html5encodes/".$encodevideo_info['moviefilebasename'].".webm";
181
- }
182
-
183
- $encodevideo_info['mobilefilepath'] = $encodevideo_info['encodepath'].$encodevideo_info['moviefilebasename']."-ipod.m4v";
184
- $encodevideo_info['oggfilepath'] = $encodevideo_info['encodepath'].$encodevideo_info['moviefilebasename'].".ogv";
185
- $encodevideo_info['webmfilepath'] = $encodevideo_info['encodepath'].$encodevideo_info['moviefilebasename'].".webm";
186
-
187
- $encodevideo_info['mobilefilepath_html5encodes'] = $uploads['basedir']."/html5encodes/".$encodevideo_info['moviefilebasename']."-ipod.m4v";
188
- $encodevideo_info['oggfilepath_html5encodes'] = $uploads['basedir']."/html5encodes/".$encodevideo_info['moviefilebasename'].".ogv";
189
- $encodevideo_info['webmfilepath_html5encodes'] = $uploads['basedir']."/html5encodes/".$encodevideo_info['moviefilebasename'].".webm";
190
-
191
- if ( file_exists($encodevideo_info['mobilefilepath']) ) { $encodevideo_info['mobile_exists'] = true; }
192
- else {
193
- if ( file_exists($encodevideo_info['mobilefilepath_html5encodes']) ) {
194
- $encodevideo_info['mobilefilepath'] = $encodevideo_info['mobilefilepath_html5encodes'];
195
- $encodevideo_info['mobile_exists'] = true;
196
- }
197
- else { $encodevideo_info['mobile_exists'] = false; }
198
- }
199
- if ( file_exists($encodevideo_info['oggfilepath']) ) { $encodevideo_info['ogg_exists'] = true; }
200
- else {
201
- if ( file_exists($encodevideo_info['oggfilepath_html5encodes']) ) {
202
- $encodevideo_info['oggfilepath'] = $encodevideo_info['oggfilepath_html5encodes'];
203
- $encodevideo_info['ogg_exists'] = true;
204
- }
205
- else { $encodevideo_info['ogg_exists'] = false; }
206
- }
207
- if ( file_exists($encodevideo_info['webmfilepath']) ) { $encodevideo_info['webm_exists'] = true; }
208
- else {
209
- if ( file_exists($encodevideo_info['webmfilepath_html5encodes']) ) {
210
- $encodevideo_info['webmfilepath'] = $encodevideo_info['webmfilepath_html5encodes'];
211
- $encodevideo_info['webm_exists'] = true;
212
  }
213
- else { $encodevideo_info['webm_exists'] = false; }
214
  }
215
 
216
- if ( !$encodevideo_info['sameserver'] ) { //last resort if it's not on the same server, check url_exists
217
- if ( !file_exists($encodevideo_info['mobilefilepath']) ) {
218
- if ( url_exists($movieurl_noextension."-ipod.m4v") ) {
219
- $encodevideo_info['mobile_exists'] = true;
220
- $encodevideo_info['mobileurl'] = $movieurl_noextension."-ipod.m4v"; ;
221
- }
222
- else { $encodevideo_info['mobile_exists'] = false; }
223
- }
224
- if ( !file_exists($encodevideo_info['oggfilepath']) ) {
225
- if ( url_exists($movieurl_noextension.".ogv") ) {
226
- $encodevideo_info['ogg_exists'] = true;
227
- $encodevideo_info['oggurl'] = $movieurl_noextension.".ogv"; ;
228
  }
229
- else { $encodevideo_info['ogg_exists'] = false; }
230
  }
231
- if ( !file_exists($encodevideo_info['webmfilepath']) ) {
232
- if ( url_exists($movieurl_noextension.".webm") ) {
233
- $encodevideo_info['webm_exists'] = true;
234
- $encodevideo_info['webmurl'] = $movieurl_noextension.".webm"; ;
 
 
 
 
235
  }
236
  }
237
  }
@@ -239,196 +269,297 @@ function kg_encodevideo_info($movieurl, $postID) {
239
  return $encodevideo_info;
240
  }
241
 
242
- function video_embed_thumbnail_generator_activate() {
243
-
244
- define("wp_FMP_swfobject_default", "true", true);
245
- define("wp_FMP_flashplayer_default", "<strong>Please upgrade Flash Player</strong> This content is shown when the user does not have a correct Flash Player version installed.", true);
246
- define("wp_FMP_default_width", "640", true);
247
- define("wp_FMP_default_height", "360", true);
248
- define("wp_FMP_default_HTML5", "true", true);
249
- define("wp_FMP_default_controlbar_style", "docked", true);
250
- define("wp_FMP_default_poster", "", true);
251
- define("wp_FMP_default_endOfVideoOverlay", "", true);
252
- define("wp_FMP_default_autohide", "true", true);
253
- define("wp_FMP_default_autoplay", "false", true);
254
- define("wp_FMP_default_loop", "false", true);
255
- define("wp_FMP_default_playbutton", "true", true);
256
- define("wp_FMP_default_stream_type", "liveOrRecorded", true);
257
- define("wp_FMP_default_scale_mode", "letterbox", true);
258
- define("wp_FMP_default_bgcolor", "", true);
259
- define("wp_FMP_default_configuration", "", true);
260
- define("wp_FMP_default_skin", plugins_url("", __FILE__)."/flash/skin/kg_skin.xml", true);
261
- define("wp_FMP_default_ffmpeg", "/usr/local/bin", true);
262
- define("wp_FMP_default_ffmpeg_exists", "notchecked", true);
263
- define("wp_FMP_default_encodemobile", "true", true);
264
- define("wp_FMP_default_mobile_res", "480", true);
265
- define("wp_FMP_default_encodeogg", "false", true);
266
- define("wp_FMP_default_encodewebm", "true", true);
267
- define("wp_FMP_default_vpre", "false", true);
268
- define("wp_FMP_default_template", "false", true);
269
- define("wp_FMP_default_titlecode", "<strong>", true);
270
-
271
- add_option('wp_FMP_swfobject', wp_FMP_swfobject_default);
272
- add_option('wp_FMP_flashplayer', wp_FMP_flashplayer_default);
273
- add_option('wp_FMP_width', wp_FMP_default_width);
274
- add_option('wp_FMP_height', wp_FMP_default_height);
275
- add_option('wp_FMP_HTML5', wp_FMP_default_HTML5);
276
- add_option('wp_FMP_controlbar_style', wp_FMP_default_controlbar_style);
277
- add_option('wp_FMP_poster', wp_FMP_default_poster);
278
- add_option('wp_FMP_endOfVideoOverlay', wp_FMP_default_endOfVideoOverlay);
279
- add_option('wp_FMP_autohide', wp_FMP_default_autohide);
280
- add_option('wp_FMP_autoplay', wp_FMP_default_autoplay);
281
- add_option('wp_FMP_loop', wp_FMP_default_loop);
282
- add_option('wp_FMP_playbutton', wp_FMP_default_playbutton);
283
- add_option('wp_FMP_stream_type', wp_FMP_default_stream_type);
284
- add_option('wp_FMP_scale_mode', wp_FMP_default_scale_mode);
285
- add_option('wp_FMP_bgcolor', wp_FMP_default_bgcolor);
286
- add_option('wp_FMP_configuration', wp_FMP_default_configuration);
287
- add_option('wp_FMP_skin', wp_FMP_default_skin);
288
- add_option('wp_FMP_ffmpeg', wp_FMP_default_ffmpeg);
289
- add_option('wp_FMP_ffmpeg_exists', wp_FMP_default_ffmpeg_exists);
290
- add_option('wp_FMP_mobile_res', wp_FMP_default_mobile_res);
291
- add_option('wp_FMP_encodemobile', wp_FMP_default_encodemobile);
292
- add_option('wp_FMP_encodeogg', wp_FMP_default_encodeogg);
293
- add_option('wp_FMP_encodewebm', wp_FMP_default_encodewebm);
294
- add_option('wp_FMP_vpre', wp_FMP_default_vpre);
295
- add_option('wp_FMP_template', wp_FMP_default_template);
296
- add_option('wp_FMP_titlecode', wp_FMP_default_titlecode);
297
-
298
- kg_check_ffmpeg_exists();
299
 
300
  }
301
- register_activation_hook( __FILE__, 'video_embed_thumbnail_generator_activate' );
302
 
303
- function addSWFObject() {
304
- if(get_option('wp_FMP_swfobject') == "true") {
305
- echo "\n<script src=\"".get_bloginfo('wpurl')."/wp-includes/js/swfobject.js\" type=\"text/javascript\"></script>\n";
306
- //wp_enqueue_script( 'swfobject', , , false );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
307
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
308
  }
309
- add_action('wp_head', 'addSWFObject');
 
310
 
311
- function FMP_shortcode($atts, $content = ''){
 
 
 
312
 
313
  // workaround for relative video URL (contributed by Lee Fernandes)
314
  if(substr($content, 0, 1) == '/') $content = get_bloginfo('url').$content;
315
 
316
  $query_atts = shortcode_atts(
317
- array('width' => get_option('wp_FMP_width'),
318
- 'height' => get_option('wp_FMP_height'),
319
- 'controlbar' => get_option('wp_FMP_controlbar_style'),
320
- 'autohide' => get_option('wp_FMP_autohide'),
321
- 'poster' => get_option('wp_FMP_poster'),
322
- 'endOfVideoOverlay' => get_option('wp_FMP_endOfVideoOverlay'),
323
- 'endOfVideoOverlaySame' => get_option('wp_FMP_endOfVideoOverlaySame'),
324
- 'playbutton' => get_option('wp_FMP_playbutton'),
325
- 'loop' => get_option('wp_FMP_loop'),
326
- 'autoplay' => get_option('wp_FMP_autoplay'),
327
- 'streamtype' => get_option('wp_FMP_stream_type'),
328
- 'scalemode' => get_option('wp_FMP_scale_mode'),
329
- 'backgroundcolor' => get_option('wp_FMP_bgcolor'),
330
- 'configuration' => get_option('wp_FMP_configuration'),
331
- 'skin' => get_option('wp_FMP_skin')), $atts);
332
-
333
- $div_suffix = substr(uniqid(rand(), true),0,4);
334
-
335
- global $wpdb;
336
- $query = "SELECT ID FROM {$wpdb->posts} WHERE guid='$content'";
337
- $id = $wpdb->get_var($query);
338
- $moviefiletype = pathinfo(trim($content), PATHINFO_EXTENSION);
339
- $flashcompatible = array("flv", "f4v", "mp4", "mov", "m4v");
340
-
341
- if ($id != "") { $encodevideo_info = kg_encodevideo_info(trim($content), $id); }
342
- else { $encodevideo_info = kg_encodevideo_info(trim($content), 'singleurl'); }
343
-
344
- $video_swf = plugins_url('', __FILE__)."/flash/StrobeMediaPlayback.swf";
345
- $minimum_flash = "10.1.0";
346
 
347
- if ( in_array($moviefiletype, $flashcompatible) ) { $flashvars = "{src:'".urlencode(trim($content))."'"; }
348
- else { $flashvars = "{src:'".urlencode(trim($encodevideo_info['mobileurl']))."'"; }
349
 
350
- if($query_atts["poster"] != '') {
351
- $flashvars .= ", poster:'".urlencode(trim($query_atts["poster"]))."'";
352
- }
353
- if($query_atts["endOfVideoOverlaySame"] == "true") { $query_atts["endOfVideoOverlay"] = $query_atts["poster"]; }
354
- if($query_atts["endOfVideoOverlay"] != '') {
355
- $flashvars .= ", endOfVideoOverlay:'".urlencode(trim($query_atts["endOfVideoOverlay"]))."'";
356
- }
357
- if($query_atts["controlbar"] != '') {
358
- $flashvars .= ", controlBarMode:'".$query_atts["controlbar"]."'";
359
- }
360
- if($query_atts["autohide"] != '') {
361
- $flashvars .= ", controlBarAutoHide:'".$query_atts["autohide"]."'";
362
- }
363
- if($query_atts["playbutton"] != '') {
364
- $flashvars .= ", playButtonOverlay:'".$query_atts["playbutton"]."'";
365
- }
366
- if($query_atts["loop"] != '') {
367
- $flashvars .= ", loop:'".$query_atts["loop"]."'";
368
- }
369
- if($query_atts["autoplay"] != '') {
370
- $flashvars .= ", autoPlay:'".$query_atts["autoplay"]."'";
371
- }
372
- if($query_atts["streamtype"] != '') {
373
- $flashvars .= ", streamType:'".$query_atts["streamtype"]."'";
374
- }
375
- if($query_atts["scalemode"] != '') {
376
- $flashvars .= ", scaleMode:'".$query_atts["scalemode"]."'";
377
- }
378
- if($query_atts["backgroundcolor"] != '') {
379
- $flashvars .= ", backgroundColor:'".$query_atts["backgroundcolor"]."'";
380
- }
381
- if($query_atts["configuration"] != '') {
382
- $flashvars .= ", configuration:'".urlencode($query_atts["configuration"])."'";
383
- }
384
- if($query_atts["skin"] != '') {
385
- $flashvars .= ", skin:'".urlencode($query_atts["skin"])."'";
386
- }
387
- $flashvars .= ", verbose:'true'";
388
- $flashvars .= "}";
389
-
390
- $params = "{allowfullscreen:'true', allowscriptaccess:'always', base:'".plugins_url("", __FILE__)."/flash/'}";
391
-
392
- if(get_option('wp_FMP_HTML5') == "true") {
393
- include_once dirname( __FILE__ ) .'/mdetect.php';
394
- $uagent_obj = new uagent_info();
395
- $isAndroid = $uagent_obj->DetectAndroid(); //determine if we're running on an Android device
396
- $isTierIphone = $uagent_obj->DetectTierIphone(); //determine if we're running on a mobile device that plays iPhone-optimized video
397
- $moviefilebasename = pathinfo(trim($content), PATHINFO_FILENAME);
398
  $h264compatible = array("mp4", "mov", "m4v");
 
 
 
 
 
 
 
 
399
 
400
- $code = "<div id=\"flashcontent".$div_suffix."\">";
401
- $code .= "<video ";
402
- if ($query_atts["loop"] == 'true') { $code .= "loop='loop' " ;}
403
- if ($query_atts["autoplay"] == 'true') { $code .= "autoplay='autoplay' " ;}
404
- if ($query_atts["controlbar"] != 'none') { $code .= "controls='controls' " ;}
405
- if ($isAndroid) { $code .= "onclick='this.play();' "; }
406
- $code .= "preload='metadata' ";
407
- if($query_atts["poster"] != '' && !$isAndroid) {
408
- $code .= "poster='".$query_atts["poster"]."' ";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
409
  }
410
- if($query_atts["poster"] != '' && $isAndroid) {
411
- $code .= "poster='".plugins_url('', __FILE__)."/images/androidthumb.php?src=".$query_atts["poster"]."' ";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
412
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
413
  $code .= "width='".$query_atts["width"]."' height='".$query_atts["height"]."'";
 
 
 
 
 
 
414
  $code .= ">\n";
 
 
415
 
416
- if ( in_array($moviefiletype, $h264compatible) ) {
417
- if ( $encodevideo_info["mobile_exists"] && $isTierIphone ) {
418
- $code .= "<source src='".$encodevideo_info["mobileurl"]."'";
419
- }
420
- else { $code .= "<source src='".trim($content)."'"; }
421
- if (!$isAndroid) { $code.= " type='video/mp4'"; }
422
- $code .=">\n";
423
- }
424
- else { if ( $encodevideo_info["mobile_exists"] ) {
425
- $code .= "<source src='".$encodevideo_info["mobileurl"]."'";
426
- if (!$isAndroid) { $code.= " type='video/mp4'"; }
427
- $code .=">\n";
428
- } }
429
- if ( $encodevideo_info["webm_exists"] ) { $code .= "<source src='".$encodevideo_info["webmurl"]."' type='video/webm'>\n"; }
430
- if ( $encodevideo_info["ogg_exists"] ) { $code .= "<source src='".$encodevideo_info["oggurl"]."' type='video/ogg'>\n"; }
431
- if ( !in_array($moviefiletype, $flashcompatible) && $encodevideo_info["mobile_exists"] ) { // Flash fallback if WEBM/OGV embed
432
  $flashvars_remove = array("{", "}", "'");
433
  $flashvars_reformat = str_replace($flashvars_remove, "", $flashvars);
434
  $flashvars_reformat = str_replace(":", "=", $flashvars_reformat);
@@ -443,761 +574,783 @@ function FMP_shortcode($atts, $content = ''){
443
  }
444
  $code .= "</video>\n";
445
  $code .= "</div>\n\n";
446
-
447
- /* if ($id !="") {
448
- $iframeurl = site_url('/')."?attachment_id=".$id;
449
- $iframecode = '<iframe src="'.$iframeurl.'" frameborder="0" scrolling="no" width="'.$query_atts['width'].'" height="'.$query_atts["height"].'"></iframe>';
450
- $code .= "<div style='background-color:#e8e8e8; width:".$query_atts['width']."px; height:25px; margin-top:-25px; padding:5px; font-size:8pt;'>Embed code: <input style='height:10px; background-color:#f4f4f4;' type='text' value='".$iframecode."' width='10' onClick='this.select();'></div>\n";
451
- } */
452
- } else {
453
- if ( in_array($moviefiletype, $flashcompatible) ) { $code = "<div id=\"flashcontent".$div_suffix."\">".get_option('wp_FMP_flashplayer')."</div>\n\n"; }
454
- }
455
-
456
- if ( in_array($moviefiletype, $flashcompatible) ) {
457
- $code .= "<script type=\"text/javascript\">\n\t";
458
- $code .= "swfobject.embedSWF('".$video_swf."', 'flashcontent".$div_suffix."', '".trim($query_atts['width'])."', '".trim($query_atts['height'])."', '".$minimum_flash."', '".plugins_url("", __FILE__)."/flash/expressInstall.swf', $flashvars, $params)\n";
459
- $code .= "</script>\n";
460
- }
461
-
462
- return $code;
463
- }
464
- add_shortcode('FMP', 'FMP_shortcode');
465
-
466
- function addFMPOptionsPage() {
467
- add_options_page('Video Embed & Thumbnail Generator', 'Video Embed & Thumbnail Generator', 'administrator', basename(__FILE__), 'FMPOptionsPage');
468
- }
469
-
470
- function FMPOptionsPage() {
471
-
472
- define("wp_FMP_swfobject_default", "true", true);
473
- define("wp_FMP_flashplayer_default", "<strong>Please upgrade Flash Player</strong> This content is shown when the user does not have a correct Flash Player version installed.", true);
474
- define("wp_FMP_default_width", "640", true);
475
- define("wp_FMP_default_height", "360", true);
476
- define("wp_FMP_default_HTML5", "true", true);
477
- define("wp_FMP_default_controlbar_style", "docked", true);
478
- define("wp_FMP_default_poster", "", true);
479
- define("wp_FMP_default_endOfVideoOverlay", "", true);
480
- define("wp_FMP_default_autohide", "true", true);
481
- define("wp_FMP_default_autoplay", "false", true);
482
- define("wp_FMP_default_loop", "false", true);
483
- define("wp_FMP_default_playbutton", "true", true);
484
- define("wp_FMP_default_stream_type", "liveOrRecorded", true);
485
- define("wp_FMP_default_scale_mode", "letterbox", true);
486
- define("wp_FMP_default_bgcolor", "", true);
487
- define("wp_FMP_default_configuration", "", true);
488
- define("wp_FMP_default_skin", plugins_url("", __FILE__)."/flash/skin/kg_skin.xml", true);
489
- define("wp_FMP_default_ffmpeg", "/usr/local/bin", true);
490
- define("wp_FMP_default_mobile_res", "480", true);
491
- define("wp_FMP_default_encodemobile", "true", true);
492
- define("wp_FMP_default_encodeogg", "false", true);
493
- define("wp_FMP_default_encodewebm", "true", true);
494
- define("wp_FMP_default_vpre", "false", true);
495
- define("wp_FMP_default_template", "false", true);
496
- define("wp_FMP_default_titlecode", "<strong>", true);
497
-
498
- if (isset($_POST['wp_FMP_reset'])) {
499
- update_option('wp_FMP_swfobject', wp_FMP_swfobject_default);
500
- update_option('wp_FMP_HTML5', wp_FMP_default_HTML5);
501
- update_option('wp_FMP_width', wp_FMP_default_width);
502
- update_option('wp_FMP_height', wp_FMP_default_height);
503
- update_option('wp_FMP_flashplayer', wp_FMP_flashplayer_default);
504
- update_option('wp_FMP_controlbar_style', wp_FMP_default_controlbar_style);
505
- update_option('wp_FMP_poster', wp_FMP_default_poster);
506
- update_option('wp_FMP_endOfVideoOverlay', wp_FMP_default_endOfVideoOverlay);
507
- update_option('wp_FMP_autohide', wp_FMP_default_autohide);
508
- update_option('wp_FMP_autoplay', wp_FMP_default_autoplay);
509
- update_option('wp_FMP_loop', wp_FMP_default_loop);
510
- update_option('wp_FMP_playbutton', wp_FMP_default_playbutton);
511
- update_option('wp_FMP_stream_type', wp_FMP_default_stream_type);
512
- update_option('wp_FMP_scale_mode', wp_FMP_default_scale_mode);
513
- update_option('wp_FMP_bgcolor', wp_FMP_default_bgcolor);
514
- update_option('wp_FMP_configuration', wp_FMP_default_configuration);
515
- update_option('wp_FMP_skin', wp_FMP_default_skin);
516
- update_option('wp_FMP_ffmpeg', wp_FMP_default_ffmpeg);
517
- update_option('wp_FMP_mobile_res', wp_FMP_default_mobile_res);
518
- update_option('wp_FMP_encodemobile', wp_FMP_default_encodemobile);
519
- update_option('wp_FMP_encodeogg', wp_FMP_default_encodeogg);
520
- update_option('wp_FMP_encodewebm', wp_FMP_default_encodewebm);
521
- update_option('wp_FMP_vpre', wp_FMP_default_vpre);
522
- update_option('wp_FMP_template', wp_FMP_default_template);
523
- update_option('wp_FMP_titlecode', wp_FMP_default_titlecode);
524
-
525
- echo "<div class='updated'><p><strong>Video Embed & Thumbnail Generator plugin reset to default settings</strong></p></div>";
526
-
527
- $ffmpeg_info = kg_check_ffmpeg_exists();
528
-
529
- if ( $ffmpeg_info['exec_enabled'] == false ) {
530
- echo "<div class='error'><p><strong>EXEC function is disabled in PHP settings. Embed codes will work, but video thumbnail generation and Mobile/HTML5 encoding will not. Contact your System Administrator to find out if you can enable EXEC</strong></p></div>";
531
- }
532
- elseif ( $ffmpeg_info['ffmpeg_exists'] == false ) {
533
- echo "<div class='error'><p><strong>FFMPEG not found at ".get_option('wp_FMP_ffmpeg').". Embed codes will work, but video thumbnail generation and Mobile/HTML5 encoding will not.</strong></p></div>";
534
  }
535
-
536
- }
537
 
538
- if (isset($_POST['wp_FMP_update'])) {
539
- check_admin_referer();
540
- $use_swfobject = $_POST[wp_FMP_swfobject];
541
- $use_html5fallback = $_POST[wp_FMP_HTML5];
542
- $use_autohide = $_POST[wp_FMP_autohide];
543
- $use_autoplay = $_POST[wp_FMP_autoplay];
544
- $use_loop = $_POST[wp_FMP_loop];
545
- $use_playbutton = $_POST[wp_FMP_playbutton];
546
- $use_encodemobile = $_POST[wp_FMP_encodemobile];
547
- $use_encodeogg = $_POST[wp_FMP_encodeogg];
548
- $use_encodewebm = $_POST[wp_FMP_encodewebm];
549
- $use_vpre = $_POST[wp_FMP_vpre];
550
- $use_template = $_POST[wp_FMP_template];
551
- $use_endOfVideoOverlaySame = $_POST[wp_FMP_endOfVideoOverlaySame];
552
-
553
- if ($use_swfobject == 'use') {
554
- update_option(wp_FMP_swfobject, "true");
555
- } else {
556
- update_option(wp_FMP_swfobject, "false");
557
- }
558
-
559
- if ($use_html5fallback == 'use') {
560
- update_option(wp_FMP_HTML5, "true");
561
- } else {
562
- update_option(wp_FMP_HTML5, "false");
563
  }
564
-
565
- if ($use_autohide == 'use') {
566
- update_option(wp_FMP_autohide, "true");
567
- } else {
568
- update_option(wp_FMP_autohide, "false");
569
- }
570
-
571
- if ($use_autoplay == 'use') {
572
- update_option(wp_FMP_autoplay, "true");
573
- } else {
574
- update_option(wp_FMP_autoplay, "false");
575
  }
576
 
577
- if ($use_loop == 'use') {
578
- update_option(wp_FMP_loop, "true");
579
- } else {
580
- update_option(wp_FMP_loop, "false");
581
- }
582
-
583
- if ($use_playbutton == 'use') {
584
- update_option(wp_FMP_playbutton, "true");
585
- } else {
586
- update_option(wp_FMP_playbutton, "false");
587
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
588
 
589
- if ($use_encodemobile == 'use') {
590
- update_option(wp_FMP_encodemobile, "true");
591
- } else {
592
- update_option(wp_FMP_encodemobile, "false");
593
- }
594
 
595
- if ($use_encodeogg == 'use') {
596
- update_option(wp_FMP_encodeogg, "true");
597
- } else {
598
- update_option(wp_FMP_encodeogg, "false");
599
- }
600
 
601
- if ($use_encodewebm == 'use') {
602
- update_option(wp_FMP_encodewebm, "true");
603
- } else {
604
- update_option(wp_FMP_encodewebm, "false");
 
 
 
 
 
 
605
  }
 
606
 
607
- if ($use_vpre == 'use') {
608
- update_option(wp_FMP_vpre, "true");
609
- } else {
610
- update_option(wp_FMP_vpre, "false");
611
- }
 
 
612
 
613
- if ($use_template == 'use') {
614
- update_option(wp_FMP_template, "true");
615
- } else {
616
- update_option(wp_FMP_template, "false");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
617
  }
618
-
619
- if ($use_endOfVideoOverlaySame == 'use') {
620
- update_option(wp_FMP_endOfVideoOverlaySame, "true");
621
- } else {
622
- update_option(wp_FMP_endOfVideoOverlaySame, "false");
623
- }
624
-
625
- update_option('wp_FMP_mobile_res', $_POST[wp_FMP_mobile_res]);
626
- update_option('wp_FMP_width', $_POST[wp_FMP_width]);
627
- update_option('wp_FMP_height', $_POST[wp_FMP_height]);
628
- update_option('wp_FMP_bgcolor', $_POST[wp_FMP_bgcolor]);
629
- update_option('wp_FMP_configuration', $_POST[wp_FMP_configuration]);
630
- update_option('wp_FMP_skin', $_POST[wp_FMP_skin]);
631
- update_option('wp_FMP_flashplayer', $_POST[wp_FMP_flashplayer]);
632
- update_option('wp_FMP_controlbar_style', $_POST[wp_FMP_controlbar_style]);
633
- update_option('wp_FMP_stream_type', $_POST[wp_FMP_stream_type]);
634
- update_option('wp_FMP_scale_mode', $_POST[wp_FMP_scale_mode]);
635
- update_option('wp_FMP_poster', $_POST[wp_FMP_poster]);
636
- update_option('wp_FMP_endOfVideoOverlay', $_POST[wp_FMP_endOfVideoOverlay]);
637
- update_option('wp_FMP_ffmpeg', $_POST[wp_FMP_ffmpeg]);
638
- update_option('wp_FMP_titlecode', $_POST[wp_FMP_titlecode]);
639
-
640
- echo "<div class='updated'><p><strong>Video Embed & Thumbnail Generator plugin settings updated</strong></p></div>";
641
-
642
- $ffmpeg_info = kg_check_ffmpeg_exists();
643
-
644
- if ( $ffmpeg_info['exec_enabled'] == false ) {
645
- echo "<div class='error'><p><strong>EXEC function is disabled in PHP settings. Embed codes will work, but video thumbnail generation and Mobile/HTML5 encoding will not. Contact your System Administrator to find out if you can enable EXEC</strong></p></div>";
646
  }
647
- elseif ( $ffmpeg_info['ffmpeg_exists'] == false ) {
648
- echo "<div class='error'><p><strong>FFMPEG not found at ".get_option('wp_FMP_ffmpeg').". Embed codes will work, but video thumbnail generation and Mobile/HTML5 encoding will not.</strong></p></div>";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
649
  }
650
  }
 
 
 
 
 
 
651
 
652
- ?>
653
 
654
- <form method="post" action="options-general.php?page=video-embed-thumbnail-generator.php">
655
- <div class="wrap">
656
- <h2>Video Embed & Thumbnail Generator</h2>
657
-
658
- <table class="form-table">
659
- <tr>
660
- <th colspan="2"><h3>Plugin settings</h3></th><td>
661
- </td>
662
- </tr>
663
- <tr>
664
- <th scope="row" valign="top" align="left">
665
- <label>Embed SWFObject:</label>
666
- </th>
667
- <td width="10"></td>
668
- <td>
669
- <?php
670
- echo "<input type='checkbox' name='wp_FMP_swfobject' id='wp_FMP_swfobject' value='use' ";
671
- if(get_option('wp_FMP_swfobject') == "true") {
672
- echo "checked";
673
- }
674
- echo " />\n";
675
- ?>
676
- Uncheck if you already have SWFObject embedded
677
- </td>
678
- </tr>
679
- <tr>
680
- <th scope="row" valign="top" align="left">
681
- <label>Enable HTML5 video fallback:</label>
682
- </th>
683
- <td width="10"></td>
684
- <td>
685
- <?php
686
- echo "<input type='checkbox' name='wp_FMP_HTML5' id='wp_FMP_HTML5' value='use' ";
687
- if(get_option('wp_FMP_HTML5') == "true") {
688
- echo "checked";
689
- }
690
- echo " />\n";
691
- ?>
692
- Uncheck if you don't want HTML5 video fallback when Flash isn't installed.
693
- </td>
694
- </tr>
695
- <tr>
696
- <th scope="row" valign="top" align="left">
697
- <label>Attachment Template Override:</label>
698
- </th>
699
- <td width="10"></td>
700
- <td>
701
- <?php
702
- echo "<input type='checkbox' name='wp_FMP_template' id='wp_FMP_template' value='use' ";
703
- if(get_option('wp_FMP_template') == "true") {
704
- echo "checked";
705
- }
706
- echo " />\n";
707
- ?>
708
- Check to enable experimental minimalist video attachment template.<br />
709
- <em><small>Allows easy iframe embedding on other sites. Will override any existing video attachment template page.</small></em>
710
- </td>
711
- </tr>
712
- <tr>
713
- <th scope="row" valign="top" align="left">
714
- <label>Default Mobile/HTML5 Video Encode Formats:</label>
715
- </th>
716
- <td width="10"></td>
717
- <td>
718
- <?php
719
- echo "<input type='checkbox' name='wp_FMP_encodemobile' id='wp_FMP_encodemobile' value='use' ";
720
- if(get_option('wp_FMP_encodemobile') == "true") {
721
- echo "checked";
722
- }
723
- echo " />\n";
724
- ?>
725
- H264/Mobile <small><em>(iOS, Android, Safari, IE 9)</em></small><br />
726
- <?php
727
- echo "<input type='checkbox' name='wp_FMP_encodewebm' id='wp_FMP_encodewebm' value='use' ";
728
- if(get_option('wp_FMP_encodewebm') == "true") {
729
- echo "checked";
730
- }
731
- echo " />\n";
732
- ?>
733
- WEBM <small><em>(Firefox, Chrome, Android 2.3+, Opera)</em></small><br />
734
- <?php
735
- echo "<input type='checkbox' name='wp_FMP_encodeogg' id='wp_FMP_encodeogg' value='use' ";
736
- if(get_option('wp_FMP_encodeogg') == "true") {
737
- echo "checked";
738
- }
739
- echo " />\n";
740
- ?>
741
- OGV <small><em>(Firefox, Chrome, Android 2.3+, Opera)</em></small><br />
742
- <em>Requires FFMPEG.</em>
743
- </td>
744
- </tr>
745
- <tr>
746
- <th scope="row" valign="top" align="left">
747
- <label>Maximum H.264/Mobile Encode Resolution:</label>
748
- </th>
749
- <td width="10"></td>
750
- <td>
751
- <select name="wp_FMP_mobile_res" id="wp_FMP_mobile_res">
752
- <?php
753
- $res_480 = "";
754
- $res_720 = "";
755
- $res_1080 = "";
756
- if(get_option('wp_FMP_mobile_res') == "480") {
757
- $res_480 = " selected=\"selected\"";
758
- }
759
- if(get_option('wp_FMP_mobile_res') == "720") {
760
- $res_720 = " selected=\"selected\"";
761
- }
762
- if(get_option('wp_FMP_mobile_res') == "1080") {
763
- $res_1080 = " selected=\"selected\"";
764
- }
765
- ?>
766
- <option value="480"<?php echo $res_480 ?>>480p</option>
767
- <option value="720"<?php echo $res_720 ?>>720p</option>
768
- <option value="1080"<?php echo $res_1080 ?>>1080p</option>
769
- </select>
770
- <em>Newer mobile devices can display HD video (iPhone 4/iPad 1/some Android play 720p, iPhone 4s/iPad 2+ play 1080p) but many older devices (iPhone 3Gs/older Android) can't play higher than 480p. Increase at your own risk.</em>
771
- </td>
772
- </tr>
773
- <tr>
774
- <th scope="row" valign="top" align="left">
775
- <label>Path to FFMPEG:</label>
776
- </th>
777
- <td width="10"></td>
778
- <td>
779
- <input name="wp_FMP_ffmpeg" id="wp_FMP_ffmpeg" type="text" value="<?php echo stripslashes(get_option('wp_FMP_ffmpeg')); ?>" /><br />
780
- <em>Don't include trailing slash. Example: /usr/local/bin</em>
781
- </td>
782
- </tr>
783
- <tr>
784
- <th scope="row" valign="top" align="left">
785
- <label>FFMPEG Options:</label>
786
- </th>
787
- <td width="10"></td>
788
- <td>
789
- <?php
790
- echo "<input type='checkbox' name='wp_FMP_vpre' id='wp_FMP_vpre' value='use' ";
791
- if(get_option('wp_FMP_vpre') == "true") {
792
- echo "checked";
793
- }
794
- echo " />\n";
795
- ?>
796
- Enable FFMPEG 'vpre' flags.<br />
797
- <em><small>Check this if your installed version of FFMPEG is old enough that libx264 requires vpre flags to operate (Dreamhost users must turn this on).<br />This should help if you can encode WEBM or OGV files but H264/Mobile files fail. It will cause newer versions of FFMPEG to fail and probably won't work on Windows servers.</em></small>
798
- </td>
799
- </tr>
800
- <tr>
801
- <th scope="row" valign="top" align="left">
802
- <label>Video Title Text HTML Formatting:</label>
803
- </th>
804
- <td width="10"></td>
805
- <td>
806
- <input name="wp_FMP_titlecode" id="wp_FMP_titlecode" type="text" value="<?php echo htmlentities(stripslashes(get_option('wp_FMP_titlecode'))); ?>" /><br />
807
- <em><small>HTML tag applied to video titles inserted by the plugin. Ex: &lt;strong&gt;, &lt;em&gt;, &lt;H2&gt;, &lt;span class="videotitle"&gt;.<br /> Corresponding closing tags will be applied to the end of the title automatically.</em></small>
808
- </td>
809
- </tr>
810
- <tr>
811
- <th scope="row" valign="top" align="left">
812
- <label>Flash Player not installed message:</label>
813
- </th>
814
- <td width="10"></td>
815
- <td>
816
- <textarea name="wp_FMP_flashplayer" id="wp_FMP_flashplayer" rows="5" cols="50"><?php echo get_option('wp_FMP_flashplayer'); ?></textarea><br />
817
- <em>This message will only be shown if HTML5 video fallback is disabled</em>
818
- </td>
819
- </tr>
820
- <tr align="left">
821
- <th></th>
822
- <td></td>
823
- <td align="left"><br />
824
- <div style="align:left"><input name="wp_FMP_update" value="Save Changes" type="submit" />&nbsp;&nbsp;&nbsp;<input name="wp_FMP_reset" value="Reset to defaults" type="submit" /></div>
825
- </td>
826
- </tr>
827
- <tr>
828
- <th colspan="2"><h3>Default video playback settings</h3></th><td>
829
- </td>
830
- </tr>
831
- <tr>
832
- <th scope="row" valign="top" align="left">
833
- <label>Default poster image:</label>
834
- </th>
835
- <td width="10"></td>
836
- <td>
837
- <input type='text' name='wp_FMP_poster' id='wp_FMP_poster' size='50' value='<?php echo get_option('wp_FMP_poster') ?>' />
838
- </td>
839
- </tr>
840
- <tr>
841
- <th scope="row" valign="top" align="left">
842
- <label>Default max video width:</label>
843
- </th>
844
- <td width="10"></td>
845
- <td>
846
- <input name="wp_FMP_width" id="wp_FMP_width" type="text" value="<?php echo get_option('wp_FMP_width') ?>" />
847
- </td>
848
- </tr>
849
- <tr>
850
- <th scope="row" valign="top" align="left">
851
- <label>Default max video height:</label>
852
- </th>
853
- <td width="10"></td>
854
- <td>
855
- <input name="wp_FMP_height" id="wp_FMP_height" type="text" value="<?php echo get_option('wp_FMP_height') ?>" />
856
- </td>
857
- </tr>
858
- <tr>
859
- <th scope="row" valign="top" align="left">
860
- <label>Default controlbar style:</label>
861
- </th>
862
- <td width="10"></td>
863
- <td>
864
- <select name="wp_FMP_controlbar_style" id="wp_FMP_controlbar_style">
865
- <?php
866
- $docked = "";
867
- $floating = "";
868
- $none = "";
869
- if(get_option('wp_FMP_controlbar_style') == "docked") {
870
- $docked = " selected=\"selected\"";
871
- }
872
- if(get_option('wp_FMP_controlbar_style') == "floating") {
873
- $floating = " selected=\"selected\"";
874
- }
875
- if(get_option('wp_FMP_controlbar_style') == "none") {
876
- $none = " selected=\"selected\"";
877
- }
878
- ?>
879
- <option value="docked"<?php echo $docked ?>>docked</option>
880
- <option value="floating"<?php echo $floating ?>>floating</option>
881
- <option value="none"<?php echo $none ?>>none</option>
882
- </select> HTML5 videos only respond to the "none" option.
883
- </td>
884
- </tr>
885
- <tr>
886
- <th scope="row" valign="top" align="left">
887
- <label>Default autoplay behavior:</label>
888
- </th>
889
- <td width="10"></td>
890
- <td>
891
- <?php
892
- echo "<input type='checkbox' name='wp_FMP_autoplay' id='wp_FMP_autoplay' value='use' ";
893
- if(get_option('wp_FMP_autoplay') == "true") {
894
- echo "checked";
895
- }
896
- echo " />\n";
897
- ?>
898
- Check if you want video to automatically play when loaded
899
- </td>
900
- </tr>
901
- <tr>
902
- <th scope="row" valign="top" align="left">
903
- <label>Default loop behavior:</label>
904
- </th>
905
- <td width="10"></td>
906
- <td>
907
- <?php
908
- echo "<input type='checkbox' name='wp_FMP_loop' id='wp_FMP_loop' value='use' ";
909
- if(get_option('wp_FMP_loop') == "true") {
910
- echo "checked";
911
- }
912
- echo " />\n";
913
- ?>
914
- Check if you want video to loop
915
- </td>
916
- </tr>
917
- <tr>
918
- <th colspan="3"><h4>The following options will only affect Flash playback</h4></th><td>
919
- </td>
920
- </tr>
921
- <tr>
922
- <th scope="row" valign="top" align="left">
923
- <label>End of video image:</label>
924
- </th>
925
- <td width="10"></td>
926
- <td>
927
- <input type='checkbox' name='wp_FMP_endOfVideoOverlaySame' id='wp_FMP_endOfVideoOverlaySame' value='use' onclick='if (this.checked == true) { document.getElementById("wp_FMP_endOfVideoOverlay").disabled=true; } else { document.getElementById("wp_FMP_endOfVideoOverlay").disabled=false; }' <?php if(get_option('wp_FMP_endOfVideoOverlaySame') == "true") { echo "checked"; } echo " /> Display poster image again when video ends.<br />"; ?>
928
- <input type='text' name='wp_FMP_endOfVideoOverlay' id='wp_FMP_endOfVideoOverlay' size='50' value='<?php echo get_option('wp_FMP_endOfVideoOverlay'); ?>' <?php if(get_option('wp_FMP_endOfVideoOverlaySame') == "true") { echo "disabled"; } ?> /> Display alternate image when video ends.<br />
929
- <small><em>Leave blank to display the first frame of the video when video ends.</em></small>
930
- </td>
931
- </tr>
932
- <tr>
933
- <th scope="row" valign="top" align="left">
934
- <label>Default background color:</label>
935
- </th>
936
- <td width="10"></td>
937
- <td>
938
- <input name="wp_FMP_bgcolor" id="wp_FMP_bgcolor" type="text" value="<?php echo get_option('wp_FMP_bgcolor') ?>" /> #rrggbb
939
- </td>
940
- </tr>
941
- <tr>
942
- <th scope="row" valign="top" align="left">
943
- <label>Default XML configuration file:</label>
944
- </th>
945
- <td width="10"></td>
946
- <td>
947
- <input name="wp_FMP_configuration" id="wp_FMP_configuration" type="text" size="50" value="<?php echo get_option('wp_FMP_configuration') ?>" />
948
- </td>
949
- </tr>
950
- <tr>
951
- <th scope="row" valign="top" align="left">
952
- <label>Default video skin file:</label>
953
- </th>
954
- <td width="10"></td>
955
- <td>
956
- <input name="wp_FMP_skin" id="wp_FMP_skin" type="text" size="50" value="<?php echo get_option('wp_FMP_skin') ?>" /><br />
957
- <em><small>Use <?php echo plugins_url("", __FILE__)."/flash/skin/kg_skin.xml" ?> for a modern, circular play button.<br />
958
- Leave blank for the older, square play button.</small></em>
959
- </td>
960
- </tr>
961
- <tr>
962
- <th scope="row" valign="top" align="left">
963
- <label>Default video stream type:</label>
964
- </th>
965
- <td width="10"></td>
966
- <td>
967
- <select name="wp_FMP_stream_type" id="wp_FMP_stream_type">
968
- <?php
969
- $liveOrRecorded = "";
970
- $live = "";
971
- $recorded = "";
972
- $dvr = "";
973
-
974
- if(get_option('wp_FMP_stream_type') == "liveOrRecorded") {
975
- $liveOrRecorded = " selected=\"selected\"";
976
- }
977
- if(get_option('wp_FMP_stream_type') == "live") {
978
- $live = " selected=\"selected\"";
979
- }
980
- if(get_option('wp_FMP_stream_type') == "recorded") {
981
- $recorded = " selected=\"selected\"";
982
- }
983
- if(get_option('wp_FMP_stream_type') == "dvr") {
984
- $dvr = " selected=\"selected\"";
985
- }
986
-
987
- ?>
988
- <option value="liveOrRecorded"<?php echo $liveOrRecorded ?>>live or recorded</option>
989
- <option value="live"<?php echo $live ?>>live</option>
990
- <option value="recorded"<?php echo $recorded ?>>recorded</option>
991
- <option value="dvr"<?php echo $dvr ?>>DVR</option>
992
- </select>
993
- </td>
994
- </tr>
995
- <tr>
996
- <th scope="row" valign="top" align="left">
997
- <label>Default video scale mode:</label>
998
- </th>
999
- <td width="10"></td>
1000
- <td>
1001
- <select name="wp_FMP_scale_mode" id="wp_FMP_scale_mode">
1002
- <?php
1003
- $letterbox = "";
1004
- $none = "";
1005
- $stretch = "";
1006
- $zoom = "";
1007
-
1008
- if(get_option('wp_FMP_scale_mode') == "letterbox") {
1009
- $letterbox = " selected=\"selected\"";
1010
- }
1011
- if(get_option('wp_FMP_scale_mode') == "none") {
1012
- $none = " selected=\"selected\"";
1013
- }
1014
- if(get_option('wp_FMP_scale_mode') == "stretch") {
1015
- $stretch = " selected=\"selected\"";
1016
- }
1017
- if(get_option('wp_FMP_scale_mode') == "zoom") {
1018
- $zoom = " selected=\"selected\"";
1019
- }
1020
-
1021
- ?>
1022
- <option value="letterbox"<?php echo $letterbox ?>>letterbox</option>
1023
- <option value="none"<?php echo $none ?>>none</option>
1024
- <option value="stretch"<?php echo $stretch ?>>stretch</option>
1025
- <option value="zoom"<?php echo $zoom ?>>zoom</option>
1026
- </select>
1027
- </td>
1028
- </tr>
1029
- <tr>
1030
- <th scope="row" valign="top" align="left">
1031
- <label>Default autohide behavior:</label>
1032
- </th>
1033
- <td width="10"></td>
1034
- <td>
1035
- <?php
1036
- echo "<input type='checkbox' name='wp_FMP_autohide' id='wp_FMP_autohide' value='use' ";
1037
- if(get_option('wp_FMP_autohide') == "true") {
1038
- echo "checked";
1039
- }
1040
- echo " />\n";
1041
- ?>
1042
- Uncheck if you do not want controlbar to hide when video is playing
1043
- </td>
1044
- </tr>
1045
- <tr>
1046
- <th scope="row" valign="top" align="left">
1047
- <label>Default play button overlay:</label>
1048
- </th>
1049
- <td width="10"></td>
1050
- <td>
1051
- <?php
1052
- echo "<input type='checkbox' name='wp_FMP_playbutton' id='wp_FMP_playbutton' value='use' ";
1053
- if(get_option('wp_FMP_playbutton') == "true") {
1054
- echo "checked";
1055
- }
1056
- echo " />\n";
1057
- ?>
1058
- Uncheck if you do not want a play button overlay
1059
- </td>
1060
- </tr>
1061
- <tr align="left">
1062
- <th></th>
1063
- <td></td>
1064
- <td align="left"><br />
1065
- <div style="align:left"><input name="wp_FMP_update" value="Save Changes" type="submit" />&nbsp;&nbsp;&nbsp;<input name="wp_FMP_reset" value="Reset to defaults" type="submit" /></div><br />&nbsp;<br />
1066
- </td>
1067
- </tr>
1068
- </table>
1069
-
1070
- </div>
1071
- </form>
1072
 
1073
- <?php
1074
 
1075
- }
1076
 
1077
- function kg_addPostSave($post_id) { //saves the poster image as an attachment
1078
- global $flag;
1079
- if ($flag == 1) { //if draft already saved. Helps prevent duplicates.
1080
- $current_post = get_post($post_id);
1081
- $uploads = wp_upload_dir();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1082
 
1083
- preg_match_all('/poster="([^"\r\n]*)"/', $current_post->post_content, $matches);
1084
-
1085
- if (!empty($matches[1])) {
1086
- $args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => null, 'post_mime_type' => 'image' );
1087
- $post_children = get_posts( $args );
1088
- $existing_attachment = array();
1089
- $i=0;
1090
- foreach ($post_children as $child) {
1091
- $existing_attachment[$i] = $child->guid;
1092
- $i++;
1093
- $kg_image_sizes = get_intermediate_image_sizes();
1094
- foreach ($kg_image_sizes as $size_name) {
1095
- $current_image_size_src = wp_get_attachment_image_src($child->ID, $size_name);
1096
- $existing_attachment[$i] = $current_image_size_src[0];
1097
- $i++;
1098
- }//each image size URL
1099
- }//each attachment
1100
- }//if there are any poster urls set in the post
1101
-
1102
- foreach ($matches[1] as $url) {
1103
- if(!in_array($url, $existing_attachment) && !is_local_attachment($url) ) {
1104
- $filename_baseurl = substr($url, 0, strlen($uploads['baseurl']));
1105
- if ( $filename_baseurl == $uploads['baseurl'] ) {
1106
- $filename = str_replace($filename_baseurl, $uploads['basedir'], $url);
1107
- if (file_exists($filename)) {
1108
- $wp_filetype = wp_check_filetype(basename($filename), null );
1109
- $attachment = array(
1110
- 'post_mime_type' => $wp_filetype['type'],
1111
- 'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)),
1112
- 'post_content' => '',
1113
- 'post_status' => 'inherit',
1114
- 'guid' => $url
1115
- );
1116
- $attach_id = wp_insert_attachment( $attachment, $filename, $post_id );
1117
- // you must first include the image.php file
1118
- // for the function wp_generate_attachment_metadata() to work
1119
- require_once(ABSPATH . "wp-admin" . '/includes/image.php');
1120
- $attach_data = wp_generate_attachment_metadata( $attach_id, $filename );
1121
- wp_update_attachment_metadata( $attach_id, $attach_data );
1122
- }//if file exists
1123
- }//if url is in the uploads directory
1124
- }//if url is not already an attachment
1125
- }//foreach
1126
- }//if post not already saved
1127
- $flag = 1;
1128
  }
1129
- add_action('save_post', 'kg_addPostSave');
1130
 
 
1131
 
1132
- /**
1133
- * Adding our custom fields to the $form_fields array
1134
- *
1135
- * @param array $form_fields
1136
- * @param object $post
1137
- * @return array
1138
- */
1139
- function kg_image_attachment_fields_to_edit($form_fields, $post) {
1140
- if( substr($post->post_mime_type, 0, 5) == 'video' ){
1141
-
1142
- $form_fields["kgflashmediaplayer-security"]["input"] = "hidden";
1143
- $form_fields["kgflashmediaplayer-security"]["value"] = wp_create_nonce('video-embed-thumbnail-generator-nonce');
1144
 
1145
- $movieurl = wp_get_attachment_url($post->ID);
1146
- $form_fields["kgflashmediaplayer-url"]["input"] = "hidden";
1147
- $form_fields["kgflashmediaplayer-url"]["value"] = $movieurl;
1148
 
1149
- $encodemobileset = get_post_meta($post->ID, "_kgflashmediaplayer-encodemobile", true);
1150
- if ($encodemobileset == "") { $encodemobileset = get_option('wp_FMP_encodemobile'); }
1151
- $form_fields["kgflashmediaplayer-encodemobile"]["input"] = "hidden";
1152
- $form_fields["kgflashmediaplayer-encodemobile"]["value"] = $encodemobileset;
1153
-
1154
- $encodeoggset = get_post_meta($post->ID, "_kgflashmediaplayer-encodeogg", true);
1155
- if ($encodeoggset == "") { $encodeoggset = get_option('wp_FMP_encodeogg'); }
1156
- $form_fields["kgflashmediaplayer-encodeogg"]["input"] = "hidden";
1157
- $form_fields["kgflashmediaplayer-encodeogg"]["value"] = $encodeoggset;
1158
-
1159
- $encodewebmset = get_post_meta($post->ID, "_kgflashmediaplayer-encodewebm", true);
1160
- if ($encodewebmset == "") { $encodewebmset = get_option('wp_FMP_encodewebm'); }
1161
- $form_fields["kgflashmediaplayer-encodewebm"]["input"] = "hidden";
1162
- $form_fields["kgflashmediaplayer-encodewebm"]["value"] = $encodewebmset;
1163
-
1164
- $encoded = get_post_meta($post->ID, "_kgflashmediaplayer-encoded", true);
1165
- $form_fields["kgflashmediaplayer-encoded"]["input"] = "hidden";
1166
- $form_fields["kgflashmediaplayer-encoded"]["value"] = $encoded;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1167
 
1168
- $maxwidth = get_option('wp_FMP_width');
1169
- $widthset = get_post_meta($post->ID, "_kgflashmediaplayer-width", true);
1170
- if ($widthset == "") { $widthset = $maxwidth; }
1171
- $form_fields["kgflashmediaplayer-widthsave"]["input"] = "hidden";
1172
- $form_fields["kgflashmediaplayer-widthsave"]["value"] = $widthset;
1173
 
1174
- $form_fields["kgflashmediaplayer-maxwidth"]["input"] = "hidden";
1175
- $form_fields["kgflashmediaplayer-maxwidth"]["value"] = $maxwidth;
1176
 
1177
- $maxheight = get_option('wp_FMP_height');
1178
- $heightset = get_post_meta($post->ID, "_kgflashmediaplayer-height", true);
1179
- if ($heightset == "") { $heightset = $maxheight; }
1180
- $form_fields["kgflashmediaplayer-heightsave"]["input"] = "hidden";
1181
- $form_fields["kgflashmediaplayer-heightsave"]["value"] = $heightset;
 
 
1182
 
1183
- $form_fields["kgflashmediaplayer-maxheight"]["input"] = "hidden";
1184
- $form_fields["kgflashmediaplayer-maxheight"]["value"] = $maxheight;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1185
 
1186
- $form_fields["kgflashmediaplayer-aspect"]["input"] = "hidden";
1187
- $form_fields["kgflashmediaplayer-aspect"]["value"] = $heightset/$widthset;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1188
 
1189
- $form_fields["kgflashmediaplayer-downloadsave"]["input"] = "hidden";
1190
- $form_fields["kgflashmediaplayer-downloadsave"]["value"] = get_post_meta($post->ID, "_kgflashmediaplayer-download", true);
1191
 
1192
- $form_fields["kgflashmediaplayer-showtitlesave"]["input"] = "hidden";
1193
- $form_fields["kgflashmediaplayer-showtitlesave"]["value"] = get_post_meta($post->ID, "_kgflashmediaplayer-showtitle", true);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1194
 
1195
- $embedset = get_post_meta($post->ID, "_kgflashmediaplayer-embed", true);
1196
- if ($embedset == "") { $embedset = "checked"; }
1197
- $form_fields["kgflashmediaplayer-embedsave"]["input"] = "hidden";
1198
- $form_fields["kgflashmediaplayer-embedsave"]["value"] = $embedset;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1199
 
1200
- $thumbnail_url = get_post_meta($post->ID, "_kgflashmediaplayer-poster", true);
 
 
 
 
 
 
 
 
 
1201
 
1202
  $uploads = wp_upload_dir();
1203
  $url_parts = parse_url($uploads['baseurl']);
@@ -1208,134 +1361,153 @@ add_action('save_post', 'kg_addPostSave');
1208
  $originalpath = $home_path."public_html".$moviefiledirectory."/".$moviefilebasename;
1209
  if ( !file_exists($originalpath) ) { $thumbnail_url = ""; }
1210
  }
1211
- else { if ( !url_exists($thumbnail_url) ) { $thumbnail_url = ""; } }
1212
 
1213
  $thumbnail_html = "";
1214
- if ($thumbnail_url != "" ) {
1215
- $thumbnail_html = '<div style="border-style:solid; border-color:#ccc; border-width:3px; width:200px; text-align:center; margin:10px;"><img width="200" src="'.$thumbnail_url.'"></div>';
1216
  }
1217
-
 
1218
  if (get_post_meta($post->ID, "_kgflashmediaplayer-thumbtime", true) != "") { $numberofthumbs_value = "1"; }
1219
- else { $numberofthumbs_value = "4"; }
1220
-
1221
- if ( get_option('wp_FMP_titlecode') === false ) { update_option('wp_FMP_titlecode', '<strong>'); }
1222
 
1223
- if ( get_option('wp_FMP_ffmpeg_exists') == false ) { kg_check_ffmpeg_exists(); } //make sure the new ffmpeg_exists option exists
 
 
 
 
1224
 
1225
- if ( get_option('wp_FMP_ffmpeg_exists') == "notinstalled" ) { $ffmpeg_disabled_text = 'disabled="disabled" title="FFMPEG not found at '.get_option('wp_FMP_ffmpeg').'"'; }
1226
  else { $ffmpeg_disabled_text = ""; }
 
 
 
 
 
 
 
 
 
 
 
 
 
1227
 
1228
  $form_fields["generator"]["label"] = __("Thumbnails");
1229
- $form_fields["generator"]["input"] = "html";
1230
- $form_fields["generator"]["html"] = '<div id="attachments_'. $post->ID .'_thumbnailplaceholder">'. $thumbnail_html .'</div>
1231
- <input id="attachments_'. $post->ID .'_numberofthumbs" type="text" value="'.$numberofthumbs_value.'" maxlength="2" size="4" style="width:25px;" onchange="document.getElementById(\'attachments['.$post->ID.'][thumbtime]\').value =\'\';" '.$ffmpeg_disabled_text.'/>
1232
- <input type="button" id="attachments['. $post->ID .'][thumbgenerate]" class="button-secondary" value="Generate" name="thumbgenerate" onclick="kg_generate_thumb('. $post->ID .', \'generate\');" '.$ffmpeg_disabled_text.'/>
1233
- <input type="button" id="thumbrandomize" class="button-secondary" value="Randomize" name="thumbrandomize" onclick="kg_generate_thumb('. $post->ID .', \'random\');" '.$ffmpeg_disabled_text.'/>
1234
- <input type="checkbox" id="attachments_'. $post->ID .'_firstframe" onchange="document.getElementById(\'attachments['.$post->ID.'][thumbtime]\').value =\'\';" '.$ffmpeg_disabled_text.'/>
1235
- <label for="attachments_'. $post->ID .'_firstframe">Force 1st Frame Thumbnail</label>';
1236
-
1237
- $form_fields["thumbtime"]["label"] = __("Thumbnail Timecode");
1238
- $form_fields["thumbtime"]["value"] = get_post_meta($post->ID, "_kgflashmediaplayer-thumbtime", true);
1239
- $form_fields["thumbtime"]["helps"] = "<small>Optional: generates a single thumbnail at the specified time (hh:mm:ss, mm:ss, or s).</small>";
1240
-
1241
- $form_fields["kgflashmediaplayer-poster"]["label"] = __("Thumbnail URL");
1242
- $form_fields["kgflashmediaplayer-poster"]["value"] = get_post_meta($post->ID, "_kgflashmediaplayer-poster", true);
1243
- $form_fields["kgflashmediaplayer-poster"]["helps"] = "<small>Leave blank to use <a href='options-general.php?page=video-embed-thumbnail-generator.php' target='_blank'>default thumbnail</a>.</small>";
1244
-
1245
- $form_fields["kgflashmediaplayer-dimensions"]["label"] = __("Video Embed Dimensions");
1246
- $form_fields["kgflashmediaplayer-dimensions"]["input"] = "html";
1247
- $form_fields["kgflashmediaplayer-dimensions"]["html"] = 'Width: <input name="attachments_'. $post->ID .'_kgflashmediaplayer-width" type="text" value="'.$widthset.'" id="attachments_'. $post->ID .'_kgflashmediaplayer-width" type="text" style="width:50px;" onchange="kg_set_dimension('.$post->ID.', \'height\', this.value);" onkeyup="kg_set_dimension('.$post->ID.', \'height\', this.value);"> Height:
1248
- <input id="attachments_'. $post->ID .'_kgflashmediaplayer-height" type="text" value="'.$heightset.'" style="width:50px;" onchange="kg_set_dimension('.$post->ID.', \'width\', this.value);" onkeyup="kg_set_dimension('.$post->ID.', \'width\', this.value);">
1249
- <input type="checkbox" id="attachments_'. $post->ID .'_kgflashmediaplayer-lockaspect" onclick="kg_set_aspect('.$post->ID.', this.checked);" checked>
1250
- <label for="attachments_'. $post->ID .'_kgflashmediaplayer-lockaspect"><small>Lock to Aspect Ratio</small></label>';
1251
- $form_fields["kgflashmediaplayer-dimensions"]["helps"] = "<small>Leave blank to use <a href='options-general.php?page=video-embed-thumbnail-generator.php' target='_blank'>default dimensions</a>.</small>";
1252
-
1253
- if ($encodemobileset == "false") { $mobilechecked = ""; }
1254
- else { $mobilechecked = "checked"; }
1255
- if ($encodeoggset == "false") { $oggchecked = ""; }
1256
- else { $oggchecked = "checked"; }
1257
- if ($encodewebmset == "false") { $webmchecked = ""; }
1258
- else { $webmchecked = "checked"; }
1259
-
1260
- $replaceoptions = "";
1261
-
1262
- $altembedset = get_post_meta($post->ID, "_kgflashmediaplayer-altembed", true);
1263
- $encodevideo_info = kg_encodevideo_info($movieurl, $post->ID);
1264
-
1265
- $altembedselect = "";
1266
- $originalselect = "";
1267
- $selected = ' selected="selected" ';
1268
- $mobileselected = "";
1269
- $oggselected = "";
1270
- $webmselected = "";
1271
- $original_extension = pathinfo($movieurl, PATHINFO_EXTENSION);
1272
- $embeddable = array("flv", "f4v", "mp4", "mov", "m4v", "ogv", "ogg", "webm");
1273
- if ( in_array($original_extension, $embeddable) ) { $originalselect = '<option value="'.$movieurl.'">original</option>'; }
1274
- if ($altembedset == $encodevideo_info['mobileurl']) { $mobileselected = $selected; }
1275
- if ($altembedset == $encodevideo_info['oggurl']) { $oggselected = $selected; }
1276
- if ($altembedset == $encodevideo_info['webmurl']) { $webmselected = $selected; }
1277
-
1278
- if ( $encodevideo_info['mobile_exists'] ) { $replaceoptions .= '<option '.$mobileselected.' value="'.$encodevideo_info['mobileurl'].'">Mobile/H.264</option>'; }
1279
- if ( $encodevideo_info['webm_exists'] ) { $replaceoptions .= '<option '.$webmselected.' value="'.$encodevideo_info['webmurl'].'">WEBM</option>'; }
1280
- if ( $encodevideo_info['ogg_exists'] ) { $replaceoptions .= '<option '.$oggselected.' value="'.$encodevideo_info['oggurl'].'">OGV</option>'; }
1281
- if ( $encodevideo_info['mobile_exists'] || $encodevideo_info['webm_exists'] || $encodevideo_info['ogg_exists'] ) { $altembedselect ='<span class="kg_embedselect">Embed <select name="attachments['.$post->ID.'][kgflashmediaplayer-altembed]" id="attachments['.$post->ID.'][kgflashmediaplayer-altembed]">'.$originalselect.$replaceoptions.'</select></span>'; }
1282
-
1283
- $form_fields["kgflashmediaplayer-encode"]["label"] = __("HTML5 & Mobile");
1284
- $form_fields["kgflashmediaplayer-encode"]["input"] = "html";
1285
- $form_fields["kgflashmediaplayer-encode"]["html"] = '<input type="button" id="attachments['. $post->ID .'][kgflashmediaplayer-encode]" name="attachments['. $post->ID .'][kgflashmediaplayer-encode]" class="button-secondary" value="Encode" name="thumbgenerate" onclick="kg_generate_thumb('. $post->ID .', \'encode\');" '.$ffmpeg_disabled_text.'/>
1286
-
1287
- <input type="checkbox" id="attachments['. $post->ID .'][kgflashmediaplayer-encodemobilecheck]" name="attachments['. $post->ID .'][kgflashmediaplayer-encodemobilecheck]" value="checked" onclick="if(this.checked) { document.getElementById(\'attachments['.$post->ID.'][kgflashmediaplayer-encodemobile]\').value = \'true\'; } else { document.getElementById(\'attachments['.$post->ID.'][kgflashmediaplayer-encodemobile]\').value = \'false\'; }" '.$mobilechecked.' '.$ffmpeg_disabled_text.'>
1288
- <label for="attachments['. $post->ID .'][kgflashmediaplayer-encodemobilecheck]">Mobile/H.264</label>
1289
-
1290
- <input type="checkbox" id="attachments['. $post->ID .'][kgflashmediaplayer-encodewebmcheck]" name="attachments['. $post->ID .'][kgflashmediaplayer-encodewebmcheck]" value="checked" onclick="if(this.checked) { document.getElementById(\'attachments['.$post->ID.'][kgflashmediaplayer-encodewebm]\').value = \'true\'; } else { document.getElementById(\'attachments['.$post->ID.'][kgflashmediaplayer-encodewebm]\').value = \'false\'; }" '.$webmchecked.' '.$ffmpeg_disabled_text.'>
1291
- <label for="attachments['. $post->ID .'][kgflashmediaplayer-encodewebmcheck]">WEBM</label>
1292
-
1293
- <input type="checkbox" id="attachments['. $post->ID .'][kgflashmediaplayer-encodeoggcheck]" name="attachments['. $post->ID .'][kgflashmediaplayer-encodeoggcheck]" value="checked" onclick="if(this.checked) { document.getElementById(\'attachments['.$post->ID.'][kgflashmediaplayer-encodeogg]\').value = \'true\'; } else { document.getElementById(\'attachments['.$post->ID.'][kgflashmediaplayer-encodeogg]\').value = \'false\'; }" '.$oggchecked.' '.$ffmpeg_disabled_text.'>
1294
- <label for="attachments['. $post->ID .'][kgflashmediaplayer-encodeoggcheck]">OGV</label>
1295
-
1296
- <div style="display:inline;" id="attachments_'. $post->ID .'_altembedselect">'.$altembedselect.'</div>
1297
- <div style="display:block;" id="attachments_'. $post->ID .'_encodeplaceholder"></div>
1298
- <div style="display:block;" id="attachments_'. $post->ID .'_encodeprogressplaceholder"></div>
1299
-
1300
- <small><em>(Experimental) Generates video files compatible with most mobile & HTML5-compatible browsers.</em></small>';
1301
-
1302
- $showtitlechecked = get_post_meta($post->ID, "_kgflashmediaplayer-showtitle", true);
1303
- $downloadlinkchecked = get_post_meta($post->ID, "_kgflashmediaplayer-download", true);
1304
- $embedchecked = get_post_meta($post->ID, "_kgflashmediaplayer-embed", true);
1305
- if ($embedchecked == "unchecked") { $embedchecked = ""; }
1306
- else { $embedchecked = "checked"; }
1307
- $form_fields["kgflashmediaplayer-options"]["label"] = __("Video Embed Options");
1308
- $form_fields["kgflashmediaplayer-options"]["input"] = "html";
1309
- $form_fields["kgflashmediaplayer-options"]["html"] = '<input type="checkbox" name="attachments['.$post->ID.'][kgflashmediaplayer-showtitle]" id="attachments['.$post->ID.'][kgflashmediaplayer-showtitle]" value="checked" onclick="if(this.checked) { document.getElementById(\'attachments['.$post->ID.'][kgflashmediaplayer-showtitlesave]\').value = \'checked\'; } else { document.getElementById(\'attachments['.$post->ID.'][kgflashmediaplayer-showtitlesave]\').value = \'unchecked\'; }"" '.$showtitlechecked.'>
1310
- <label for="attachments['.$post->ID.'][kgflashmediaplayer-showtitle]">Include Title Above Video</label><br />
1311
-
1312
- <input type="checkbox" name="attachments['.$post->ID.'][kgflashmediaplayer-downloadlink]" id="attachments['.$post->ID.'][kgflashmediaplayer-downloadlink]" value="checked" onclick="if(this.checked) { document.getElementById(\'attachments['.$post->ID.'][kgflashmediaplayer-downloadsave]\').value = \'checked\'; } else { document.getElementById(\'attachments['.$post->ID.'][kgflashmediaplayer-downloadsave]\').value = \'unchecked\'; }" '.$downloadlinkchecked.'>
1313
- <label for="attachments['.$post->ID.'][kgflashmediaplayer-downloadlink]">Generate Download Link Below Video<em><small>(Makes it easier for users to download video file)</em></small></label><br />
1314
-
1315
- <input type="checkbox" name="attachments['.$post->ID.'][kgflashmediaplayer-embed]" id="attachments['.$post->ID.'][kgflashmediaplayer-embed]" value="checked" onclick="if(this.checked) { document.getElementById(\'attachments['.$post->ID.'][kgflashmediaplayer-embedsave]\').value = \'checked\'; } else { document.getElementById(\'attachments['.$post->ID.'][kgflashmediaplayer-embedsave]\').value = \'unchecked\'; }" '.$embedchecked.'>
1316
- <label for="attachments['.$post->ID.'][kgflashmediaplayer-embed]">Generate Embed Shortcode <em><small>(Turn off checkbox to use default WordPress video embedding)</small></em></label>';
1317
-
1318
- //$form_fields["kgflashmediaplayer-attachment"]["label"] = __("All Meta");
1319
- //$form_fields["kgflashmediaplayer-attachment"]["value"] = get_post_meta($post->ID, "_kgflashmediaplayer-attachment", true);
1320
-
1321
- } //only add fields if attachment is video
1322
- return $form_fields;
1323
- }
1324
- // attach our function to the correct hook
1325
- add_filter("attachment_fields_to_edit", "kg_image_attachment_fields_to_edit", null, 2);
1326
 
1327
- /**
1328
- * @param array $post
1329
- * @param array $attachment
1330
- * @return array
1331
- */
1332
- function kg_video_attachment_fields_to_save($post, $attachment) {
1333
- // $attachment part of the form $_POST ($_POST[attachments][postID])
1334
- // $post attachments wp post array - will be saved after returned
1335
- // $post['post_type'] == 'attachment'
1336
- if( isset($attachment['kgflashmediaplayer-poster']) ) {
1337
- $uploads = wp_upload_dir();
1338
- $posterfile = pathinfo($attachment['kgflashmediaplayer-poster'], PATHINFO_BASENAME);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1339
  $tmp_posterpath = $uploads['path'].'/thumb_tmp/'.$posterfile;
1340
  if ( !is_file($uploads['path'].'/'.$posterfile) ) {
1341
  if ( is_file($tmp_posterpath) ) {
@@ -1345,21 +1517,128 @@ function kg_video_attachment_fields_to_save($post, $attachment) {
1345
  unlink($thumbfilename);
1346
  }
1347
  }
1348
- if ( is_empty_dir($uploads["path"].'/thumb_tmp') ) { rrmdir($uploads["path"].'/thumb_tmp'); }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1349
  }
1350
- update_post_meta($post['ID'], '_kgflashmediaplayer-poster', $attachment['kgflashmediaplayer-poster']);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1351
  }
 
 
 
1352
  if( isset($attachment['thumbtime']) ) {update_post_meta($post['ID'], '_kgflashmediaplayer-thumbtime', $attachment['thumbtime']); }
1353
- if( isset($attachment['kgflashmediaplayer-widthsave']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-width', $attachment['kgflashmediaplayer-widthsave']); }
1354
- if( isset($attachment['kgflashmediaplayer-heightsave']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-height', $attachment['kgflashmediaplayer-heightsave']); }
 
 
1355
  if( isset($attachment['kgflashmediaplayer-aspect']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-aspect', $attachment['kgflashmediaplayer-aspect']); }
1356
- if( isset($attachment['kgflashmediaplayer-encodemobile']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-encodemobile', $attachment['kgflashmediaplayer-encodemobile']); }
1357
- if( isset($attachment['kgflashmediaplayer-encodeogg']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-encodeogg', $attachment['kgflashmediaplayer-encodeogg']); }
1358
- if( isset($attachment['kgflashmediaplayer-encodewebm']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-encodewebm', $attachment['kgflashmediaplayer-encodewebm']); }
1359
- if( isset($attachment['kgflashmediaplayer-embedsave']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-embed', $attachment['kgflashmediaplayer-embedsave']); }
1360
- if( isset($attachment['kgflashmediaplayer-downloadsave']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-download', $attachment['kgflashmediaplayer-downloadsave']); }
1361
- if( isset($attachment['kgflashmediaplayer-showtitlesave']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-showtitle', $attachment['kgflashmediaplayer-showtitlesave']); }
1362
- if( isset($attachment['kgflashmediaplayer-altembed']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-altembed', $attachment['kgflashmediaplayer-altembed']); }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1363
  /* if( isset($attachment['kgflashmediaplayer-encoded']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-encoded', $attachment['kgflashmediaplayer-encoded']); } */
1364
 
1365
  //$attachment_printr = print_r($attachment, true);
@@ -1367,7 +1646,7 @@ function kg_video_attachment_fields_to_save($post, $attachment) {
1367
 
1368
  return $post;
1369
  }
1370
- add_filter("attachment_fields_to_save", "kg_video_attachment_fields_to_save", null, 2);
1371
 
1372
  class kgInsertMedia {
1373
  //class constructor
@@ -1377,15 +1656,14 @@ class kgInsertMedia {
1377
  //function that does the modifying
1378
  function kgmodifyMediaInsert($html, $attachment_id, $attachment) {
1379
 
 
1380
  $output = $html;
1381
 
1382
  $attachment['embed'] = get_post_meta($attachment_id, "_kgflashmediaplayer-embed", true);
1383
 
1384
- if ($attachment['embed'] == "checked" || $attachment_id == "singleurl" ) {
1385
  $output = "";
1386
- $attachment['altembed'] = get_post_meta($attachment_id, "_kgflashmediaplayer-altembed", true);
1387
- if ( $attachment['altembed'] != "" ) { $attachment['url'] = $attachment['altembed']; }
1388
- else { $attachment['url'] = wp_get_attachment_url($attachment_id); }
1389
  $attachment['title'] = get_the_title($attachment_id);
1390
  $attachment['poster'] = get_post_meta($attachment_id, "_kgflashmediaplayer-poster", true);
1391
  $attachment['width'] = get_post_meta($attachment_id, "_kgflashmediaplayer-width", true);
@@ -1393,7 +1671,7 @@ class kgInsertMedia {
1393
  $attachment['downloadlink'] = get_post_meta($attachment_id, "_kgflashmediaplayer-download", true);
1394
  $attachment['showtitle'] = get_post_meta($attachment_id, "_kgflashmediaplayer-showtitle", true);
1395
  if ($attachment['showtitle'] =="checked") {
1396
- $titlecode = html_entity_decode(stripslashes(get_option('wp_FMP_titlecode')));
1397
  if ( substr($titlecode, 0, 1) != '<' ) { $titlecode = '<'.$titlecode; }
1398
  if ( substr($titlecode, -1, 1) != '>' ) { $titlecode .= '>'; }
1399
  $endtitlecode = str_replace("<", "</", $titlecode);
@@ -1401,52 +1679,68 @@ class kgInsertMedia {
1401
  if ( substr($endtitlecode_array[0], -1) != ">" ) { $endtitlecode = $endtitlecode_array[0].">"; }
1402
  $output .= $titlecode.$attachment["title"].$endtitlecode.'<br />';
1403
  }
1404
- $output .= '[FMP';
1405
  if ($attachment['poster'] !="") { $output .= ' poster="'.$attachment["poster"].'"'; }
1406
  if ($attachment['width'] !="") { $output .= ' width="'.$attachment["width"].'"'; }
1407
  if ($attachment['height'] !="") { $output .= ' height="'.$attachment["height"].'"'; }
1408
- $output .= ']'.$attachment["url"].'[/FMP]<br />';
1409
  if ($attachment['downloadlink'] == "checked") { $output .= '<a href="'.$attachment["url"].'">Right-click or ctrl-click this link to download.</a><br />'; }
1410
- } //if embed code is enabled
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1411
  return $output;
1412
  }
1413
  }
1414
  //instantiate the class
1415
  $kgIM = new kgInsertMedia();
1416
 
1417
-
1418
- //add_filter('video_send_to_editor_url', 'kg_filter_video_url', 20, 3);
1419
-
1420
- //function kg_filter_video_url($html, $href, $title) { //when inserting via URL only
1421
- // $html = '[FMP]'.$href.'"[/FMP]';
1422
- // return $html;
1423
- //}
1424
-
1425
- function kg_embedurl_menu($tabs) {
1426
- $newtab = array('embedurl' => __('Embed from URL', 'kgoutsidevideo'));
1427
- return array_merge($tabs, $newtab);
1428
  }
1429
- add_filter('media_upload_tabs', 'kg_embedurl_menu');
1430
 
1431
  function media_embedurl_process() {
1432
 
1433
- if ( get_option('wp_FMP_titlecode') === false ) { update_option('wp_FMP_titlecode', '<strong>'); }
1434
-
1435
- if ( get_option('wp_FMP_ffmpeg_exists') == false ) { kg_check_ffmpeg_exists(); } //make sure the new ffmpeg_exists option exists
1436
 
1437
- if ( get_option('wp_FMP_ffmpeg_exists') == "notinstalled" ) { $ffmpeg_disabled_text = 'disabled="disabled" title="FFMPEG not found at '.get_option('wp_FMP_ffmpeg').'"'; }
1438
- else { $ffmpeg_disabled_text = ""; }
 
 
 
 
 
 
 
1439
 
1440
- if ( get_option('wp_FMP_encodemobile') == "true" ) { $mobilechecked = "checked"; }
1441
- else { $mobilechecked = ""; }
1442
- if ( get_option('wp_FMP_encodeogg') == "true" ) { $oggchecked = "checked"; }
1443
- else { $oggchecked = ""; }
1444
- if ( get_option('wp_FMP_encodewebm') == "true" ) { $webmchecked = "checked"; }
1445
- else { $webmchecked = ""; }
1446
 
1447
  media_upload_header();
1448
  ?>
1449
- <form class="media-upload-form type-form validate" id="video-form" enctype="multipart/form-data" method="post" action="">
1450
 
1451
  <div id="media-items">
1452
  <div class="media-item media-blank">
@@ -1458,51 +1752,36 @@ function media_embedurl_process() {
1458
  <p class="help"><small>Add an optional header above the video.</small></p></td>
1459
  </tr>
1460
  <tr>
1461
- <th valign="top" scope="row" class="label"><label for="attachments[singleurl][kgflashmediaplayer-url]">Video URL</label></th>
1462
- <td class="field"><input type="text" id="attachments[singleurl][kgflashmediaplayer-url]" name="attachments[singleurl][kgflashmediaplayer-url]" value="" size="50" onchange="document.getElementById('attachments_singleurl_encodeplaceholder').innerHTML = '';"/>
1463
  <p class="help"><small>Specify the URL of the video file.</small></p></td>
1464
  </tr>
1465
  <tr>
1466
  <th valign="top" scope="row" class="label"><span class="alignleft"><label for="numberofthumbs">Thumbnails</label></span></th>
1467
- <td class="field"><div id="attachments_singleurl_thumbnailplaceholder"></div>
1468
- <input id="attachments_singleurl_numberofthumbs" type="text" value="4" maxlength="2" size="4" style="width:25px;" title="Number of Thumbnails" onchange="document.getElementById('attachments[singleurl][thumbtime]').value='';" <?php echo $ffmpeg_disabled_text; ?> />
1469
- <input type="button" id="attachments[singleurl][thumbgenerate]" class="button-secondary" value="Generate" name="thumbgenerate" onclick="kg_generate_thumb('singleurl', 'generate');" <?php echo $ffmpeg_disabled_text; ?> />
1470
- <input type="button" id="thumbrandomize" class="button-secondary" value="Randomize" name="thumbrandomize" onclick="kg_generate_thumb('singleurl', 'random');" <?php echo $ffmpeg_disabled_text; ?> />
1471
- <input type="checkbox" id="attachments_singleurl_firstframe" onchange="document.getElementById('attachments[singleurl][thumbtime]').value ='';" <?php echo $ffmpeg_disabled_text; ?> /><label for="attachments_singleurl_firstframe">Force 1st Frame Thumbnail</label></td>
1472
  </tr>
1473
  <tr>
1474
- <th valign="top" scope="row" class="label"><span class="alignleft"><label for="attachments[singleurl][thumbtime]">Thumbnail Timecode</span></label><br class="clear" /></th>
1475
- <td class="field"><input type="text" name="attachments[singleurl][thumbtime]" id="attachments[singleurl][thumbtime]" value="" size="50" />
1476
  <p class="help"><small>Optional: generates a single thumbnail at the specified time (hh:mm:ss, mm:ss, or s).</small></p></td>
1477
  </tr>
1478
  <tr>
1479
- <th valign="top" scope="row" class="label"><span class="alignleft"><label for="attachments[singleurl][kgflashmediaplayer-poster]">Thumbnail URL</label></span></th>
1480
- <td class="field"><input type="text" name="attachments[singleurl][kgflashmediaplayer-poster]" id="attachments[singleurl][kgflashmediaplayer-poster]" value="" size="50" />
1481
- <p class="help"><small>Leave blank to use <a href="options-general.php?page=video-embed-thumbnail-generator.php" target="_blank">default thumbnail</a>.</small></p></td>
1482
  </tr>
1483
  <tr>
1484
- <th valign="top" scope="row" class="label"><span class="alignleft"><label for="attachments[singleurl][kgflashmediaplayer-width]">Dimensions</label></span></th>
1485
- <td class="field">Width: <input name="attachments_singleurl_kgflashmediaplayer-width" type="text" value="" id="attachments_singleurl_kgflashmediaplayer-width" type="text" style="width:50px;" onchange="kg_set_dimension('singleurl', 'height', this.value);" onkeyup="kg_set_dimension('singleurl', 'height', this.value);"> Height: <input id="attachments_singleurl_kgflashmediaplayer-height" type="text" value="" style="width:50px;" onchange="kg_set_dimension('singleurl', 'width', this.value);" onkeyup="kg_set_dimension('singleurl', 'width', this.value);"> <input type="checkbox" id="attachments_singleurl_kgflashmediaplayer-lockaspect" onclick="kg_set_aspect('singleurl', this.checked);" checked> <label for="attachments_singleurl_kgflashmediaplayer-lockaspect"><small>Lock to Aspect Ratio</small></label>
1486
- <p class="help"><small>Leave blank to use <a href="options-general.php?page=video-embed-thumbnail-generator.php" target="_blank">default dimensions</a>.</small></p></td>
1487
  </tr>
1488
  <tr>
1489
  <th valign="top" scope="row" class="label"><span class="alignleft"><label for="html5">HTML5 & Mobile</span></label></th>
1490
- <td><input type="button" id="html5" class="button-secondary" value="Encode" name="html5" onclick="kg_generate_thumb('singleurl', 'encode');" <?php echo $ffmpeg_disabled_text; ?> />
1491
-
1492
- <input type="checkbox" id="attachments[singleurl][kgflashmediaplayer-encodemobilecheck]" name="attachments[singleurl][kgflashmediaplayer-encodemobilecheck]" value="checked" onclick="if(this.checked) { document.getElementById('attachments[singleurl][kgflashmediaplayer-encodemobile]').value = 'true'; } else { document.getElementById('attachments[singleurl][kgflashmediaplayer-encodemobile]').value = 'false'; }" <?php echo ($mobilechecked." ".$ffmpeg_disabled_text); ?> />
1493
- <label for="attachments[singleurl][kgflashmediaplayer-encodemobilecheck]">Mobile/H.264</label>
1494
-
1495
- <input type="checkbox" id="attachments[singleurl][kgflashmediaplayer-encodewebmcheck]" name="attachments[singleurl][kgflashmediaplayer-encodewebmcheck]" value="checked" onclick="if(this.checked) { document.getElementById('attachments[singleurl][kgflashmediaplayer-encodewebm]').value = 'true'; } else { document.getElementById('attachments[singleurl][kgflashmediaplayer-encodewebm]').value = 'false'; }" <?php echo ($webmchecked." ".$ffmpeg_disabled_text); ?> />
1496
- <label for="attachments[singleurl][kgflashmediaplayer-encodewebmcheck]">WEBM</label>
1497
-
1498
- <input type="checkbox" id="attachments[singleurl][kgflashmediaplayer-encodeoggcheck]" name="attachments[singleurl][kgflashmediaplayer-encodeoggcheck]" value="checked" onclick="if(this.checked) { document.getElementById('attachments[singleurl][kgflashmediaplayer-encodeogg]').value = 'true'; } else { document.getElementById('attachments[singleurl][kgflashmediaplayer-encodeogg]').value = 'false'; }" <?php echo ($oggchecked." ".$ffmpeg_disabled_text); ?> />
1499
- <label for="attachments[singleurl][kgflashmediaplayer-encodeoggcheck]">OGV</label>
1500
-
1501
- <div style="display:inline;" id="attachments_singleurl_altembedselect"></div>
1502
- <div style="display:block;" id="attachments_singleurl_encodeplaceholder"></div>
1503
- <div style="display:block;" id="attachments_singleurl_encodeprogressplaceholder"></div>
1504
-
1505
- <small><em>(Experimental) Generates video files compatible with most mobile & HTML5-compatible browsers.</em></small></td>
1506
  </tr>
1507
  <tr>
1508
  <th valign="top" scope="row" class="label"><span class="alignleft"><label>Options</span></label></th>
@@ -1511,229 +1790,912 @@ function media_embedurl_process() {
1511
  <tr class="submit">
1512
  <td></td>
1513
  <td>
1514
- <input type="button" onclick="kg_insert_shortcode();" name="insertonlybutton" id="insertonlybutton" class="button" value="Insert into Post" />
1515
  </td>
1516
  </tr>
1517
  </tbody></table>
1518
  </div>
1519
  </div>
1520
 
1521
- <?php
1522
- $uploads = wp_upload_dir();
1523
- $maxheight = get_option('wp_FMP_height');
1524
- $maxwidth = get_option('wp_FMP_width');
1525
- ?>
1526
-
1527
- <input type='hidden' name='attachments[singleurl][kgflashmediaplayer-security]' id='attachments[singleurl][kgflashmediaplayer-security]' value='<?php echo wp_create_nonce('video-embed-thumbnail-generator-nonce'); ?>' />
1528
- <input type='hidden' name='attachments[singleurl][kgflashmediaplayer-encodemobile]' id='attachments[singleurl][kgflashmediaplayer-encodemobile]' value='<?php echo get_option('wp_FMP_encodemobile'); ?>' />
1529
- <input type='hidden' name='attachments[singleurl][kgflashmediaplayer-encodeogg]' id='attachments[singleurl][kgflashmediaplayer-encodeogg]' value='<?php echo get_option('wp_FMP_encodeogg'); ?>' />
1530
- <input type='hidden' name='attachments[singleurl][kgflashmediaplayer-encodewebm]' id='attachments[singleurl][kgflashmediaplayer-encodewebm]' value='<?php echo get_option('wp_FMP_encodewebm'); ?>' />
1531
- <input type='hidden' name='attachments[singleurl][kgflashmediaplayer-maxheight]' id='attachments[singleurl][kgflashmediaplayer-maxheight]' value='<?php echo($maxheight); ?>' />
1532
- <input type='hidden' name='attachments[singleurl][kgflashmediaplayer-maxwidth]' id='attachments[singleurl][kgflashmediaplayer-maxwidth]' value='<?php echo($maxwidth); ?>' />
1533
- <input type='hidden' name='attachments[singleurl][kgflashmediaplayer-aspect]' id='attachments[singleurl][kgflashmediaplayer-aspect]' value='<?php echo($maxheight/$maxwidth); ?>' />
1534
- <input type='hidden' name='attachments[singleurl][kgflashmediaplayer-titlecode]' id='attachments[singleurl][kgflashmediaplayer-titlecode]' value='<?php echo get_option('wp_FMP_titlecode'); ?>' />
1535
  </form>
1536
 
1537
  <?php
1538
  } //end media_embedurl_process
1539
 
1540
- function kg_embedurl_handle() {
1541
- return wp_iframe( 'media_embedurl_process');
1542
  }
1543
- add_action('media_upload_embedurl', 'kg_embedurl_handle');
1544
 
 
 
 
 
 
1545
 
1546
- function kg_video_attachment_template() {
1547
 
1548
  global $post;
1549
- $embed_enabled = get_post_meta($post->ID, "_kgflashmediaplayer-embed", true);
1550
- $poster = get_post_meta($post->ID, "_kgflashmediaplayer-poster", true);
1551
- $width = get_post_meta($post->ID, "_kgflashmediaplayer-width", true);
1552
- $height = get_post_meta($post->ID, "_kgflashmediaplayer-height", true);
1553
- $url = wp_get_attachment_url($post->ID);
1554
-
1555
- if ($embed_enabled == "checked" ) {
1556
- $shortcode = '[FMP';
1557
- if ($poster !="" ) { $shortcode .= ' poster="'.$poster.'"';}
1558
- if ($width !="" ) { $shortcode .= ' width="'.$width.'"';}
1559
- if ($height !="" ) { $shortcode .= ' height="'.$height.'"';}
1560
- $shortcode .= ']'.$url.'[/FMP]';
1561
- echo "<html>\n<head>";
1562
- echo "\n<script src=\"".plugins_url("", __FILE__)."/flash/swfobject.js\" type=\"text/javascript\"></script>\n";
1563
- echo "</head>\n<body>";
1564
- echo do_shortcode( $shortcode );
1565
- echo '</body></html>';
1566
- exit;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1567
  }
1568
  }
1569
- if ( get_option('wp_FMP_template') == 'true' ) { add_action('template_redirect', 'kg_video_attachment_template'); }
1570
-
1571
 
1572
- function kg_cleanup_generated_logfiles_handler($logfile) {
1573
  $lastmodified = "";
1574
  if ( file_exists($logfile) ) { $lastmodified = filemtime($logfile); }
1575
  if ( $lastmodified != false ) {
1576
  if ( time() - $lastmodified > 120 ) { unlink($logfile); }
1577
  else {
1578
- $timestamp = wp_next_scheduled( 'kg_cleanup_generated_logfiles' );
1579
- wp_unschedule_event($timestamp, 'kg_cleanup_generated_logfiles' );
1580
  $args = array('logfile'=>$logfile);
1581
- wp_schedule_single_event(time()+600, 'kg_cleanup_generated_logfiles', $args);
1582
  }
1583
  }
1584
  }
1585
- add_action('kg_cleanup_generated_logfiles','kg_cleanup_generated_logfiles_handler');
1586
 
1587
- function kg_cleanup_generated_thumbnails_handler() {
1588
  $uploads = wp_upload_dir();
1589
- rrmdir($uploads['path'].'/thumb_tmp'); //remove the whole tmp file directory
 
1590
  }
1591
- add_action('kg_cleanup_generated_thumbnails','kg_cleanup_generated_thumbnails_handler');
1592
 
1593
- function kg_schedule_cleanup_generated_files() { //schedules deleting all tmp thumbnails or logfiles if no files are generated in an hour
1594
 
1595
  check_ajax_referer( 'video-embed-thumbnail-generator-nonce', 'security' );
1596
 
1597
  if (isset($_POST['thumbs'])) {
1598
- $timestamp = wp_next_scheduled( 'kg_cleanup_generated_thumbnails' );
1599
- wp_unschedule_event($timestamp, 'kg_cleanup_generated_thumbnails' );
1600
- wp_schedule_single_event(time()+3600, 'kg_cleanup_generated_thumbnails');
1601
  }
1602
 
1603
  if (isset($_POST['logfile'])) {
1604
- $timestamp = wp_next_scheduled( 'kg_cleanup_generated_logfiles' );
1605
- wp_unschedule_event($timestamp, 'kg_cleanup_generated_logfiles' );
1606
  $args = array('logfile'=>$_POST['logfile']);
1607
- wp_schedule_single_event(time()+600, 'kg_cleanup_generated_logfiles', $args);
 
 
 
 
 
 
1608
  }
 
1609
  die(); // this is required to return a proper result
1610
  }
1611
- add_action('wp_ajax_kg_schedule_cleanup_generated_files', 'kg_schedule_cleanup_generated_files');
1612
 
1613
- function kg_callffmpeg() {
1614
 
1615
  check_ajax_referer( 'video-embed-thumbnail-generator-nonce', 'security' );
1616
  global $wpdb;
1617
- include_once dirname( __FILE__ ) .'/kg_callffmpeg.php';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1618
  die(); // this is required to return a proper result
1619
  }
 
1620
 
1621
- add_action('wp_ajax_kg_callffmpeg', 'kg_callffmpeg');
1622
 
1623
- function kg_check_encode_progress() {
1624
-
1625
- check_ajax_referer( 'video-embed-thumbnail-generator-nonce', 'security' );
1626
- global $wpdb;
1627
- $pid = $_POST['pid'];
1628
- $logfile = $_POST['logfile'];
1629
- $movie_duration = $_POST['movie_duration'];
1630
  $embed_display = "";
1631
- $percent_done = "";
1632
- $other_message = "";
1633
- $logfilecontents = "";
1634
- $lastline = "";
1635
-
1636
- if ( is_file($logfile) ) {
1637
-
1638
- $logfilecontents = file_get_contents($logfile);
1639
- $fp = fopen($logfile, 'w');
1640
- fclose($fp);
1641
- $lastlines = kg_explodeX(array("\r","\n"), $logfilecontents);
1642
- $lastlines_output = print_r($lastlines, true);
1643
- $lastline = end($lastlines);
1644
- if ( $lastline == "" ) { $lastline = prev($lastlines); }
1645
-
1646
- $last_match = "";
1647
- $time_matches = "";
1648
- $video_matches = "";
1649
- $libx264_matches = "";
1650
- $fps_matches = "";
1651
- $fps_match = "";
1652
- $basename = "";
1653
-
1654
- preg_match('/time=(.*?) /', $lastline, $time_matches);
1655
-
1656
- if ( array_key_exists(1, $time_matches) != true ) {
1657
- preg_match('/video:(.*?) /', $lastline, $video_matches);
1658
- preg_match('/libx264 (.*?) /', $lastline, $libx264_matches);
1659
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1660
 
1661
- if ( array_key_exists(1, $time_matches) == true ) {
1662
- if ( strpos($time_matches[1], ':') !== false ) {
1663
- $current_hours = intval(substr($time_matches[1], -11, 2));
1664
- $current_minutes = intval(substr($time_matches[1], -8, 2));
1665
- $current_seconds = intval(substr($time_matches[1], -5, 2));
1666
- $current_seconds = ($current_hours * 60 * 60) + ($current_minutes * 60) + $current_seconds;
1667
  }
1668
- else { $current_seconds = $time_matches[1]; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1669
 
1670
- $percent_done = round(intval($current_seconds)/intval($movie_duration)*100);
 
 
 
 
1671
 
1672
- preg_match('/fps=\s+(.*?) /', $lastline, $fps_matches);
1673
- if ( array_key_exists(1, $fps_matches) == true ) { $fps_match = $fps_matches[1]; }
1674
- else { $fps_match = "10"; }
1675
- }
1676
- elseif ( array_key_exists(1, $video_matches) == true || array_key_exists(1, $libx264_matches) == true ) {
1677
- $percent_done = 100;
1678
- }
1679
- else {
1680
- $other_message = $lastline;
1681
- $basename = substr($logfile, 0, -16);
1682
- if ( is_file($basename."-ipod.m4v") ) {
1683
- if ( (time() - filemtime($basename."-ipod.m4v")) < 30 ) { //unlink($basename."-ipod.m4v");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1684
  }
 
 
1685
  }
1686
- if ( is_file($basename.".ogv") ) {
1687
- if ( (time() - filemtime($basename.".ogv")) < 30 ) { //unlink($basename.".ogv");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1688
  }
 
 
 
 
 
 
 
 
 
 
1689
  }
1690
- if ( is_file($basename.".webm") ) {
1691
- if ( (time() - filemtime($basename.".webm")) < 30 ) { //unlink($basename.".webm");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1692
  }
1693
  }
1694
  }
 
 
 
 
 
 
 
1695
 
1696
- //if ( $percent_done == "100" || $other_message != "" ) { if ( file_exists($logfile) ) { unlink($logfile); } }
 
 
 
 
 
 
 
 
 
 
 
1697
 
1698
- $embed_display .= $lastline;
1699
- $arr = array ( "embed_display"=>$embed_display, "percent_done"=>$percent_done, "other_message"=>$other_message, "fps"=>$fps_match );
 
 
 
 
 
 
 
 
 
 
1700
  }
1701
- else { $arr = array ( "other_message"=>"Encoding Failed" ); }
 
 
 
 
 
 
1702
 
1703
- echo json_encode($arr);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1704
 
1705
- die(); // this is required to return a proper result
1706
  }
1707
- add_action('wp_ajax_kg_check_encode_progress', 'kg_check_encode_progress');
1708
 
1709
- function kg_cancel_encode() {
1710
 
1711
  check_ajax_referer( 'video-embed-thumbnail-generator-nonce', 'security' );
1712
 
1713
- if (isset($_POST['kg_pid'])) {
1714
- $kg_pid = $_POST['kg_pid'];
1715
- if ( intval($kg_pid) > 0 ) {
1716
- //$command = escapeshellcmd('kill '.$kg_pid);
1717
- //exec($command);
1718
- posix_kill($kg_pid, 15);
1719
  }
 
 
 
 
 
1720
  }
1721
-
1722
  die(); // this is required to return a proper result
1723
  }
1724
- add_action('wp_ajax_kg_cancel_encode', 'kg_cancel_encode');
1725
 
1726
- function enqueue_kg_script() { //loads plugin-related javascripts
1727
- wp_enqueue_script( 'video_embed_thumbnail_generator_script', plugins_url('/kg_video_plugin.js', __FILE__) );
1728
- }
1729
- add_action('admin_enqueue_scripts', 'enqueue_kg_script');
1730
 
1731
- function enqueue_kg_style() { //loads plugin-related CSS
1732
- $myStyleUrl = plugins_url('video-embed-thumbnail-generator.css', __FILE__);
1733
- wp_enqueue_style('kg_progressbar_style', $myStyleUrl);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1734
  }
1735
- add_action('admin_print_styles', 'enqueue_kg_style');
1736
 
1737
- add_action('admin_menu', 'addFMPOptionsPage');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1738
 
1739
  ?>
2
  /*
3
  Plugin Name: Video Embed & Thumbnail Generator
4
  Plugin URI: http://www.kylegilman.net/2011/01/18/video-embed-thumbnail-generator-wordpress-plugin/
5
+ Description: Generates thumbnails, HTML5-compliant videos, and embed codes for locally hosted videos. Requires FFMPEG for thumbnails and encodes. <a href="options-general.php?page=video-embed-thumbnail-generator/video-embed-thumbnail-generator.php">Settings</a> | <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=kylegilman@gmail.com&item_name=Video%20Embed%20And%20Thumbnail%20Generator%20Plugin%20Donation/">Donate</a>
6
+ Version: 3.0
7
  Author: Kyle Gilman
8
  Author URI: http://www.kylegilman.net/
9
 
24
  1) Includes Strobe Media Playback Flash Player
25
  Website: http://osmf.org/strobe_mediaplayback.html
26
  License: http://creativecommons.org/licenses/by-nc/3.0/
27
+ 2) Includes code adapted from Joshua Eldridge's Flash Media Player Plugin
 
 
 
28
  Website: http://wordpress.org/extend/plugins/flash-video-player/
29
+ 3) Includes code adapted from Gary Cao's Make Shortcodes User-Friendly tutorial
30
  Website: http://www.wphardcore.com/2010/how-to-make-shortcodes-user-friendly/
31
+ 4) Includes code adapted from Justin Gable's "Modifying Wordpress' Default Method for Inserting Media"
32
  Website: http://justingable.com/2008/10/03/modifying-wordpress-default-method-for-inserting-media/
33
+ 5) Includes Video-JS Player
34
+ Website: http://www.videojs.com/
35
+ License: http://www.gnu.org/licenses/lgpl.html
36
+ 6) Includes code adapted from Kathy Darling's custom solution for saving thumbnails
37
+ Website: http://www.kathyisawesome.com/
38
  */
39
 
40
  if ( ! defined( 'ABSPATH' ) )
41
  die( "Can't load this file directly" );
42
+
43
+ function kgvid_default_options_fn() {
44
+ $options = array("version"=>3.0,
45
+ "embed_method"=>"Video.js",
46
+ "template"=>false,
47
+ "encode_1080"=>"on",
48
+ "encode_720"=>"on",
49
+ "encode_mobile"=>"on",
50
+ "encode_webm"=>false,
51
+ "encode_ogg"=>false,
52
+ "app_path"=>"/usr/local/bin",
53
+ "video_app" => "ffmpeg",
54
+ "ffmpeg_exists"=>"notchecked",
55
+ "ffmpeg_vpre"=>false,
56
+ "moov"=>"none",
57
+ "generate_thumbs"=>4,
58
+ "titlecode"=>"<strong>",
59
+ "poster"=>"",
60
+ "width"=>"640",
61
+ "height"=>"360",
62
+ "gallery_width"=>"960",
63
+ "gallery_height"=>"540",
64
+ "gallery_thumb"=>"250",
65
+ "controlbar_style"=>"docked",
66
+ "autoplay"=>false,
67
+ "loop"=>false,
68
+ "endOfVideoOverlay"=>"",
69
+ "endOfVideoOverlaySame"=>"",
70
+ "bgcolor"=>"",
71
+ "configuration"=>"",
72
+ "skin"=>plugins_url("", __FILE__)."/flash/skin/kg_skin.xml",
73
+ "js_skin"=>"kg-video-js-skin",
74
+ "stream_type"=>"liveOrRecorded",
75
+ "scale_mode"=>"letterbox",
76
+ "autohide"=>"true",
77
+ "playbutton"=>"true");
78
+ return $options;
79
+ }
80
+
81
+ function kgvid_register_default_options_fn() { //add default values for options
82
+ $options = get_option('kgvid_video_embed_options');
83
+ if( !is_array($options) ) {
84
+ $options = kgvid_default_options_fn();
85
+ update_option('kgvid_video_embed_options', $options);
86
+ }
87
+ if ( !isset($options['ffmpeg_exists']) || $options['ffmpeg_exists'] == "notchecked" ) { kgvid_check_ffmpeg_exists($options, true); }
88
+ }
89
+ register_activation_hook(__FILE__, 'kgvid_register_default_options_fn');
90
+
91
+ function kgvid_video_formats() {
92
+
93
+ $video_formats = array(
94
+ "1080" => array("name" => "1080p H.264", "width" => 1920, "height" => 1080, "type" => "h264", "suffix" => "-1080.m4v"),
95
+ "720" => array("name" => "720p H.264", "width" => 1280, "height" => 720, "type" => "h264", "suffix" => "-720.m4v"),
96
+ "mobile" => array("name" => "480p H.264", "width" => 640, "height" => 480, "type" => "h264", "suffix" => "-ipod.m4v"),
97
+ "webm" => array("name" => "WEBM", "width" => 0, "height" => 0, "type" => "webm", "suffix" => ".webm"),
98
+ "ogg" => array("name" => "OGV", "width" => 0, "height" => 0, "type" => "ogv", "suffix" => ".ogv")
99
+ );
100
+ return $video_formats;
101
+
102
+ }
103
 
104
+ function kgvid_add_upload_mimes ( $existing_mimes=array() ) {
105
 
106
  // allows uploading .webm videos
107
  $existing_mimes['webm'] = 'video/webm';
108
  return $existing_mimes;
109
 
110
  }
111
+ add_filter('upload_mimes', 'kgvid_add_upload_mimes');
112
 
113
+ function kgvid_url_exists($url) {
114
  $hdrs = @get_headers($url);
115
  return is_array($hdrs) ? preg_match('/^HTTP\\/\\d+\\.\\d+\\s+2\\d\\d\\s+.*$/',$hdrs[0]) : false;
116
  }
117
 
118
+ function kgvid_is_empty_dir($dir)
119
  {
120
  if ($dh = @opendir($dir))
121
  {
132
  else return false; // whatever the reason is : no such dir, not a dir, not readable
133
  }
134
 
135
+ function kgvid_explodeX($delimiters,$string)
136
  {
137
  $return_array = Array($string); // The array to return
138
  $d_count = 0;
153
  return $return_array; // Return the exploded elements
154
  }
155
 
156
+ function kgvid_rrmdir($dir) {
157
  if (is_dir($dir)) {
158
  $objects = scandir($dir);
159
  foreach ($objects as $object) {
160
  if ($object != "." && $object != "..") {
161
+ if (filetype($dir."/".$object) == "dir") kgvid_rrmdir($dir."/".$object); else unlink($dir."/".$object);
162
  }
163
  }
164
  reset($objects);
166
  }
167
  }
168
 
169
+ function kgvid_check_ffmpeg_exists($options, $save) {
 
170
  $exec_enabled = false;
171
  $ffmpeg_exists = false;
172
  $output = array();
 
173
  $uploads = wp_upload_dir();
174
 
175
  if(function_exists('exec')) {
176
+ $exec_enabled = true;
177
+ //$plugin_url = plugins_url("", __FILE__);
178
+ //$plugin_url = str_replace("https://", "http://", $plugin_url);
179
+ exec ( $options['app_path'].'/'.$options['video_app'].' -i '.plugin_dir_path(__FILE__).'/flash/skin/images/PlayNormal.png '.$uploads['path'].'/ffmpeg_exists_test.jpg', $output, $returnvalue );
180
  }
181
 
182
  if ( $exec_enabled == true && file_exists($uploads['path'].'/ffmpeg_exists_test.jpg') ) { //if FFMPEG has executed successfully
 
183
  $ffmpeg_exists = true;
184
  unlink($uploads['path'].'/ffmpeg_exists_test.jpg');
185
  }
 
186
 
187
+ if ( $save == true ) {
188
+ if ( $ffmpeg_exists == true ) { $options['ffmpeg_exists'] = "on"; }
189
+ else { $options['ffmpeg_exists'] = "notinstalled"; }
190
+ update_option('kgvid_video_embed_options', $options);
191
+ }
192
 
193
+ $output_output = implode("/n", $output);
194
  $arr = array ("exec_enabled"=>$exec_enabled, "ffmpeg_exists"=>$ffmpeg_exists, "return_value"=>$returnvalue, "output"=>$output_output);
 
195
  return $arr;
196
  }
197
 
198
+ function kgvid_encodevideo_info($movieurl, $postID) {
199
+
200
+ $options = get_option('kgvid_video_embed_options');
201
 
202
  $uploads = wp_upload_dir();
203
  $movie_extension = pathinfo(parse_url($movieurl, PHP_URL_PATH), PATHINFO_EXTENSION);
204
+ $movieurl_noextension = preg_replace("/\\.[^.\\s]{3,4}$/", "", $movieurl);
205
  $encodevideo_info['moviefilebasename'] = basename($movieurl,'.'.$movie_extension);
206
  $moviefilepath = str_replace(" ", "%20", $movieurl);
207
+ $video_formats = kgvid_video_formats();
208
 
209
+ if ( is_numeric($postID) ) { //if it's an attachment, not from URL
210
  $moviefile = get_attached_file($postID);
211
  $path_parts = pathinfo($moviefile);
212
  $encodevideo_info['encodepath'] = $path_parts['dirname']."/";
233
  }
234
  }
235
 
 
 
 
 
 
236
  if ( !is_writable($encodevideo_info['encodepath']) ) { //if the original directory is not writable use a directory in base wp_upload
237
  $encodevideo_info['encodepath'] = $uploads['basedir']."/html5encodes/";
238
  $encodevideo_info['html5encodes'] = true;
239
+ foreach ( $video_formats as $format => $format_stats ) {
240
+ $encodevideo_info[$format.'url'] = $uploads['baseurl']."/html5encodes/".$encodevideo_info['moviefilebasename'].$format_stats['suffix'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
241
  }
 
242
  }
243
 
244
+ foreach ( $video_formats as $format => $format_stats ) { //loop through each format
245
+ $encodevideo_info[$format.'url'] = $movieurl_noextension.$format_stats['suffix'];
246
+ $encodevideo_info[$format.'filepath'] = $encodevideo_info['encodepath'].$encodevideo_info['moviefilebasename'].$format_stats['suffix'];
247
+ $encodevideo_info[$format.'filepath_html5encodes'] = $uploads['basedir']."/html5encodes/".$encodevideo_info['moviefilebasename'].$format_stats['suffix'];
248
+
249
+ if ( file_exists($encodevideo_info[$format.'filepath']) ) { $encodevideo_info[$format.'_exists'] = true; }
250
+ else {
251
+ if ( file_exists($encodevideo_info[$format.'filepath_html5encodes']) ) {
252
+ $encodevideo_info[$format.'filepath'] = $encodevideo_info[$format.'filepath_html5encodes'];
253
+ $encodevideo_info[$format.'_exists'] = true;
 
 
254
  }
255
+ else { $encodevideo_info[$format.'_exists'] = false; }
256
  }
257
+
258
+ if ( !$encodevideo_info['sameserver'] ) { //last resort if it's not on the same server, check url_exists
259
+ if ( !file_exists($encodevideo_info[$format.'filepath']) ) {
260
+ if ( kgvid_url_exists($movieurl_noextension.$format_stats['suffix']) ) {
261
+ $encodevideo_info[$format.'_exists'] = true;
262
+ $encodevideo_info[$format.'url'] = $movieurl_noextension.$format_stats['suffix']; ;
263
+ }
264
+ else { $encodevideo_info[$format.'_exists'] = false; }
265
  }
266
  }
267
  }
269
  return $encodevideo_info;
270
  }
271
 
272
+ /**
273
+ * Get the dimensions of a video file
274
+ *
275
+ * @param unknown_type $video
276
+ * @return array(width,height)
277
+ * @author Jamie Scott
278
+ */
279
+ function kgvid_get_video_dimensions($video = false) {
280
+ $options = get_option('kgvid_video_embed_options');
281
+ $ffmpegPath = $options['app_path']."/".$options['video_app'];
282
+
283
+ $video = str_replace("https://", "http://", $video);
284
+
285
+ $command = $ffmpegPath . ' -i "' . $video . '" -codecs 2>&1';
286
+
287
+ exec ( $command, $output );
288
+ $lastline = end($output);
289
+ $lastline = prev($output)."<br />".$lastline;
290
+ $output = implode("\n", $output);
291
+
292
+ $result = ereg ( '[0-9]?[0-9][0-9][0-9]x[0-9][0-9][0-9][0-9]?', $output, $regs );
293
+
294
+ if (isset ( $regs [0] )) {
295
+ $vals = (explode ( 'x', $regs [0] ));
296
+ $width = $vals [0] ? $vals [0] : null;
297
+ $height = $vals [1] ? $vals [1] : null;
298
+ preg_match('/Duration: (.*?),/', $output, $matches);
299
+ $duration = $matches[1];
300
+ preg_match('/rotate : (.*?)\n/', $output, $matches);
301
+ if ( array_key_exists(1, $matches) == true ) { $rotate = $matches[1]; }
302
+ else $rotate = "0";
303
+ $configuration = array();
304
+ $lib_list = array('libfaac', 'libvo_aacenc', 'libtheora', 'libvorbis', 'libvpx', 'libx264');
305
+ foreach ($lib_list as $lib) {
306
+ if ( strpos($output, $lib) !== false ) { $configuration[$lib] = "true"; }
307
+ else { $configuration[$lib] = "false"; }
308
+ }
309
+
310
+ return array ('width' => $width, 'height' => $height, 'duration' => $duration, 'configuration' => $configuration, 'rotate' => $rotate, 'worked'=>true );
311
+ } else {
312
+ return array ('output'=>$lastline, 'worked'=>false);
313
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
314
 
315
  }
 
316
 
317
+ class kgvid_Process{
318
+ private $pid;
319
+ private $command;
320
+
321
+ public function __construct($cl=false){
322
+ if ($cl != false){
323
+ $this->command = $cl;
324
+ $this->runCom();
325
+ }
326
+ }
327
+ private function runCom(){
328
+
329
+ //$command = 'nohup '.$this->command.' > /dev/null 2>&1 & echo $!'; //this is the original command
330
+
331
+ $sys = strtoupper(PHP_OS); // Get OS Name
332
+ if(substr($sys,0,3) == "WIN") {
333
+ $command = $this->command;
334
+ $this->OS = "windows";
335
+ } //exec this way if it's Windows
336
+
337
+ else {
338
+ $command = 'nohup nice '.$this->command;
339
+ $this->OS = "linux";
340
+ }
341
+
342
+ exec($command ,$op);
343
+ $this->output = $op;
344
+ if(substr($sys,0,3) != "WIN") { $this->pid = (int)$op[0]; }
345
+ }
346
+
347
+ public function setPid($pid){
348
+ $this->pid = $pid;
349
+ }
350
+
351
+ public function getPid(){
352
+ return $this->pid;
353
+ }
354
+
355
+ public function status(){
356
+ $command = 'ps -p '.$this->pid;
357
+ exec($command,$op);
358
+ if (!isset($op[1]))return false;
359
+ else return true;
360
+ }
361
+
362
+ public function start(){
363
+ if ($this->command != '')$this->runCom();
364
+ else return true;
365
+ }
366
+
367
+ public function stop(){
368
+ $command = 'kill '.$this->pid;
369
+ exec($command);
370
+ if ($this->status() == false)return true;
371
+ else return false;
372
+ }
373
+ }// class Process
374
+
375
+ function kgvid_video_embed_enqueue_scripts() {
376
+ $options = get_option('kgvid_video_embed_options');
377
+ if ( $options['embed_method'] == "Strobe Media Playback" ) {
378
+ wp_enqueue_script( 'swfobject' );
379
+ }
380
+
381
+ if ( $options['embed_method'] == "Video.js" ) {
382
+ wp_enqueue_script( 'video-js', plugins_url("", __FILE__).'/video-js/video.js' );
383
+ wp_enqueue_style( 'video-js-css', plugins_url("", __FILE__).'/video-js/video-js.css' );
384
+ wp_enqueue_style( 'video-js-kg-skin', plugins_url("", __FILE__).'/video-js/kg-video-js-skin.css' );
385
  }
386
+
387
+ wp_enqueue_script( 'jquery-ui-dialog' );
388
+ wp_enqueue_script( 'kgvid_video_embed', plugins_url("", __FILE__).'/js/kgvid_video_embed.js' );
389
+ wp_localize_script( 'kgvid_video_embed', 'ajax_object', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) ); // setting ajaxurl
390
+ }
391
+ add_action('wp_enqueue_scripts', 'kgvid_video_embed_enqueue_scripts');
392
+
393
+ function kgvid_video_embed_print_scripts() {
394
+
395
+ $options = get_option('kgvid_video_embed_options');
396
+
397
+ if ( $options['embed_method'] == "Video.js" ) { echo '<script type="text/javascript">_V_.options.flash.swf = "'.plugins_url("", __FILE__).'/video-js/video-js.swf"</script>'."\n"; }
398
+
399
  }
400
+ add_action('wp_head', 'kgvid_video_embed_print_scripts');
401
+
402
 
403
+ function KGVID_shortcode($atts, $content = ''){
404
+
405
+ $options = get_option('kgvid_video_embed_options');
406
+ $post_ID = get_the_ID();
407
 
408
  // workaround for relative video URL (contributed by Lee Fernandes)
409
  if(substr($content, 0, 1) == '/') $content = get_bloginfo('url').$content;
410
 
411
  $query_atts = shortcode_atts(
412
+ array('width' => $options['width'],
413
+ 'height' => $options['height'],
414
+ 'controlbar' => $options['controlbar_style'],
415
+ 'autohide' => $options['autohide'],
416
+ 'poster' => $options['poster'],
417
+ 'endOfVideoOverlay' => $options['endOfVideoOverlay'],
418
+ 'endOfVideoOverlaySame' => $options['endOfVideoOverlaySame'],
419
+ 'playbutton' => $options['playbutton'],
420
+ 'loop' => $options['loop'],
421
+ 'autoplay' => $options['autoplay'],
422
+ 'streamtype' => $options['stream_type'],
423
+ 'scalemode' => $options['scale_mode'],
424
+ 'backgroundcolor' => $options['bgcolor'],
425
+ 'configuration' => $options['configuration'],
426
+ 'skin' => $options['skin'],
427
+ 'gallery' => 'false',
428
+ 'gallery_thumb' => $options['gallery_thumb'],
429
+ 'gallery_orderby' => 'menu_order',
430
+ 'gallery_order' => 'ASC',
431
+ 'gallery_exclude' => '',
432
+ 'gallery_include' => '',
433
+ 'gallery_id' => $post_ID,
434
+ 'volume' => ''
435
+ ), $atts);
436
+
437
+ if ( $query_atts["loop"] == "on" ) { $query_atts["loop"] = "true"; }
438
+ if ( $query_atts["autoplay"] == "on" ) { $query_atts["autoplay"] = "true"; }
439
+
440
+ if ( $query_atts["gallery"] != "true" ) {
441
 
442
+ $content = trim($content);
 
443
 
444
+ global $wpdb;
445
+ $query = "SELECT ID FROM {$wpdb->posts} WHERE guid='{$content}'";
446
+ $id = $wpdb->get_var($query);
447
+ $moviefiletype = pathinfo($content, PATHINFO_EXTENSION);
448
+ $flashcompatible = array("flv", "f4v", "mp4", "mov", "m4v");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
449
  $h264compatible = array("mp4", "mov", "m4v");
450
+ $div_suffix = substr(uniqid(rand(), true),0,4);
451
+
452
+ if ($id != "") {
453
+ $div_suffix = $id;
454
+ $encodevideo_info = kgvid_encodevideo_info($content, $id);
455
+ $attachment_info = get_post( $id );
456
+ }
457
+ else { $encodevideo_info = kgvid_encodevideo_info($content, 'singleurl'); }
458
 
459
+ if ( $options['embed_method'] == "Strobe Media Playback" ) {
460
+
461
+ $video_swf = plugins_url('', __FILE__)."/flash/StrobeMediaPlayback.swf";
462
+ $minimum_flash = "10.1.0";
463
+
464
+ if ( in_array($moviefiletype, $flashcompatible) ) { $flashvars = "{src:'".urlencode($content)."'"; }
465
+ else { $flashvars = "{src:'".urlencode(trim($encodevideo_info['mobileurl']))."'"; }
466
+
467
+ if($query_atts["poster"] != '') {
468
+ $flashvars .= ", poster:'".urlencode(trim($query_atts["poster"]))."'";
469
+ }
470
+ if($query_atts["endOfVideoOverlaySame"] == "true") { $query_atts["endOfVideoOverlay"] = $query_atts["poster"]; }
471
+ if($query_atts["endOfVideoOverlay"] != '') {
472
+ $flashvars .= ", endOfVideoOverlay:'".urlencode(trim($query_atts["endOfVideoOverlay"]))."'";
473
+ }
474
+ if($query_atts["controlbar"] != '') {
475
+ $flashvars .= ", controlBarMode:'".$query_atts["controlbar"]."'";
476
+ }
477
+ if($query_atts["autohide"] != '') {
478
+ $flashvars .= ", controlBarAutoHide:'".$query_atts["autohide"]."'";
479
+ }
480
+ if($query_atts["playbutton"] != '') {
481
+ $flashvars .= ", playButtonOverlay:'".$query_atts["playbutton"]."'";
482
+ }
483
+ if($query_atts["loop"] != '') {
484
+ $flashvars .= ", loop:'".$query_atts["loop"]."'";
485
+ }
486
+ if($query_atts["autoplay"] != '') {
487
+ $flashvars .= ", autoPlay:'".$query_atts["autoplay"]."'";
488
+ }
489
+ if($query_atts["streamtype"] != '') {
490
+ $flashvars .= ", streamType:'".$query_atts["streamtype"]."'";
491
+ }
492
+ if($query_atts["scalemode"] != '') {
493
+ $flashvars .= ", scaleMode:'".$query_atts["scalemode"]."'";
494
+ }
495
+ if($query_atts["backgroundcolor"] != '') {
496
+ $flashvars .= ", backgroundColor:'".$query_atts["backgroundcolor"]."'";
497
+ }
498
+ if($query_atts["configuration"] != '') {
499
+ $flashvars .= ", configuration:'".urlencode($query_atts["configuration"])."'";
500
  }
501
+ if($query_atts["skin"] != '') {
502
+ $flashvars .= ", skin:'".urlencode($query_atts["skin"])."'";
503
+ }
504
+ $flashvars .= ", verbose:'true'";
505
+ $flashvars .= "}";
506
+
507
+ $params = "{wmode:'opaque', allowfullscreen:'true', allowscriptaccess:'always', base:'".plugins_url("", __FILE__)."/flash/'}";
508
+ } //if Strobe Media Playback
509
+
510
+ if ( in_array($moviefiletype, $h264compatible) ) {
511
+ $encodevideo_info["original_exists"] = true;
512
+ $encodevideo_info["originalurl"] = $content;
513
+ }
514
+ else { $encodevideo_info["original_exists"] = false; }
515
+
516
+ $video_formats = array(
517
+ "original" => "mp4",
518
+ "1080" => "mp4",
519
+ "720" => "mp4",
520
+ "mobile" => "mp4",
521
+ "webm" => "webm",
522
+ "ogg" => "ogg"
523
+ );
524
+
525
+ $sources = "";
526
+ foreach ($video_formats as $name => $type) {
527
+ if ( $encodevideo_info[$name."_exists"] ) { $sources .= "<source id='video_".$div_suffix."_src_".$name."' src='".$encodevideo_info[$name."url"]."' type='video/".$type."'>\n";
528
+ if ( $type == "mp4" ) { $mp4_srcs["src_".$name] = $encodevideo_info[$name."url"]; }
529
  }
530
+ }
531
+
532
+ /* if ( $mp4_srcs ) {
533
+ $mp4_srcs["id"] = $div_suffix;
534
+ $JSON_mp4_srcs = json_encode($mp4_srcs);
535
+ } */
536
+
537
+ $code = "";
538
+
539
+ if ($id !="") {
540
+ if ( !empty($attachment_info->post_excerpt) ) { $code .= '<div id="attachment_'.$id.'" class="wp-caption alignnone">'; }
541
+ }
542
+
543
+ $code .= "<div id=\"video_".$div_suffix."_div\" class=\"kgvid_videodiv\">";
544
+ $code .= "<video id=\"video_".$div_suffix."\" ";
545
+ if ($query_atts["loop"] == 'true') { $code .= "loop " ;}
546
+ if ($query_atts["autoplay"] == 'true') { $code .= "autoplay " ;}
547
+ if ($query_atts["controlbar"] != 'none') { $code .= "controls " ;}
548
+ //if ($isAndroid) { $code .= "onclick='this.play();' "; }
549
+ $code .= "preload='metadata' ";
550
+ if($query_atts["poster"] != '' ) { $code .= "poster='".$query_atts["poster"]."' "; }
551
  $code .= "width='".$query_atts["width"]."' height='".$query_atts["height"]."'";
552
+ if ( $options['embed_method'] == "Video.js" ) {
553
+ if ( $options['js_skin'] == "" ) { $options['js_skin'] = "vjs-default-skin"; }
554
+ if ( array_key_exists('skin', $atts) ) { $options['js_skin'] = $atts['skin']; } //allows user to set skin for individual videos using the same skin="" attribute
555
+ $code .= " class='video-js ".$options['js_skin']."' data-setup='{}'";
556
+ }
557
+ else { }
558
  $code .= ">\n";
559
+
560
+ $code .= $sources; //add the <source> tags created earlier
561
 
562
+ if ( !in_array($moviefiletype, $flashcompatible) && $encodevideo_info["mobile_exists"] && $options['embed_method'] == "Strobe Media Playback" ) { // Flash fallback if WEBM/OGV embed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
563
  $flashvars_remove = array("{", "}", "'");
564
  $flashvars_reformat = str_replace($flashvars_remove, "", $flashvars);
565
  $flashvars_reformat = str_replace(":", "=", $flashvars_reformat);
574
  }
575
  $code .= "</video>\n";
576
  $code .= "</div>\n\n";
577
+ //if ( $options['embed_method'] == "Video.js" ) { $code .= "<script type='text/javascript'>_V_('video_".$div_suffix."').ready(kgvid_set_mp4_src($JSON_mp4_srcs));</script>\n"; }
578
+ if ( $options['embed_method'] == "Video.js" ) {
579
+ if ($id != "") {
580
+ $plays = intval(get_post_meta($id, "_kgflashmediaplayer-starts", true));
581
+ $ends = intval(get_post_meta($id, "_kgflashmediaplayer-completeviews", true));
582
+ }
583
+ else {
584
+ $plays = "not_countable";
585
+ $ends = "not_countable";
586
+ }
587
+ $aspect_ratio = round($query_atts["height"] / $query_atts["width"], 3);
588
+
589
+ $volume_code = "";
590
+ if ( !empty($query_atts["volume"]) ) { $volume_code = "this.volume(".$query_atts['volume'].")"; }
591
+
592
+ $code .= "<input type='hidden' id='".$div_suffix."_played' value='not_played'><script type='text/javascript'>
593
+ _V_('video_".$div_suffix."').ready(function(){
594
+ var width = document.getElementById(this.id).parentElement.offsetWidth;
595
+ if ( width < ".$query_atts["width"]." ) { this.width(width).height( width * ".$aspect_ratio." ); }
596
+ ".$volume_code."
597
+ this.addEvent('play', function(){
598
+ kgvid_video_counter('".$div_suffix."', '".$plays."', '".$ends."', 'play');
599
+ if (typeof _gaq != 'undefined') { _gaq.push(['_trackEvent', 'Videos', 'Play Start', '".get_the_title($id)."']); }
600
+ });
601
+ this.addEvent('ended', function(){
602
+ kgvid_video_counter('".$div_suffix."', '".$plays."', '".$ends."', 'ended');
603
+ if (typeof _gaq != 'undefined') { _gaq.push(['_trackEvent', 'Videos', 'Complete View', '".get_the_title($id)."']); }
604
+ });
605
+ });
606
+ </script>\n";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
607
  }
 
 
608
 
609
+ if ($id !="") {
610
+ $iframeurl = site_url('/')."?attachment_id=".$id;
611
+ $iframecode = '<iframe src="'.$iframeurl.'" frameborder="0" scrolling="no" width="'.$query_atts['width'].'" height="'.$query_atts["height"].'"></iframe>';
612
+ $code .= "<div class='kgvid_embed_code' type='text' value='".$iframecode."' width='10' onClick='this.select();'></div>\n";
613
+ if ( !empty($attachment_info->post_excerpt) ) { $code .= '<p class="wp-caption-text">'.$attachment_info->post_excerpt.'</p></div>'; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
614
  }
615
+
616
+ if ( in_array($moviefiletype, $flashcompatible) && $options['embed_method'] == "Strobe Media Playback" ) {
617
+ $code .= "<script type=\"text/javascript\">\n\t";
618
+ $code .= "swfobject.embedSWF('".$video_swf."', 'video_".$div_suffix."_div', '".trim($query_atts['width'])."', '".trim($query_atts['height'])."', '".$minimum_flash."', '".plugins_url("", __FILE__)."/flash/expressInstall.swf', $flashvars, $params)\n";
619
+ $code .= "</script>\n";
 
 
 
 
 
 
620
  }
621
 
622
+ } //if not gallery
623
+
624
+ else { //if gallery
625
+ $code = "";
626
+ $args = array( 'post_type' => 'attachment', 'orderby' => $query_atts['gallery_orderby'], 'order' => $query_atts['gallery_order'], 'post_mime_type' => 'video', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $post_ID, 'exclude' => $query_atts['gallery_exclude'] );
627
+ if ( !empty($query_atts['gallery_include']) ) { $args['include'] = $query_atts['gallery_include']; }
628
+ $attachments = get_posts($args);
629
+ if ($attachments) {
630
+ foreach ( $attachments as $attachment ) {
631
+ $thumbnail_url = get_post_meta($attachment->ID, "_kgflashmediaplayer-poster", true);
632
+ if (!$thumbnail_url) { $thumbnail_url = $options['poster']; }
633
+ if (!$thumbnail_url) { $thumbnail_url = plugins_url('/images/nothumbnail.jpg', __FILE__);}
634
+
635
+ $video_width = get_post_meta($attachment->ID, "_kgflashmediaplayer-actualwidth", true);
636
+ if ( !$video_width ) { $video_width = get_post_meta($attachment->ID, "_kgflashmediaplayer-width", true); }
637
+ if ( !$video_width || $video_width > intval($options['gallery_width']) ) { $video_width = $options['gallery_width']; }
638
+
639
+ $video_height = get_post_meta($attachment->ID, "_kgflashmediaplayer-actualheight", true);
640
+ if ( !$video_height ) { $video_height = get_post_meta($attachment->ID, "_kgflashmediaplayer-height", true); }
641
+ if ( !$video_height || $video_height > intval($options['gallery_height']) ) { $video_height = $options['gallery_height']; }
642
+
643
+ $code .= '<div class="kgvid_video_gallery_thumb" style="width:'.$query_atts["gallery_thumb"].'px"><a href="#" onclick="javascript:kgvid_SetVideo(\''.site_url('/').'?attachment_id='.$attachment->ID.'&kgvid_video_embed[gallery]=true&kgvid_video_embed[width]='.$video_width.'&kgvid_video_embed[height]='.$video_height.'\', \''.$video_width.'\', \''.$video_height.'\');return false;"><img src="'.$thumbnail_url.'"></a><span class="videotitle">'.$attachment->post_title.'</span></div>';
644
+ }
645
+ $code .= '<div id="kgvid_GalleryPlayerDiv"><iframe id="kgvid_GalleryVideo" src="" width="640" height="360" frameborder="0" webkitallowfullscreen="" allowfullscreen=""></iframe></div>';
646
+ $code .= '<script type="text/javascript">jQuery(document).ready(function() { jQuery(\'head\').append(\'<link rel="stylesheet" href="'.plugins_url("", __FILE__).'/css/kgvid_video_gallery.css" type="text/css" />\'); jQuery(\'#kgvid_GalleryPlayerDiv\').dialog({ zIndex: 10000, autoOpen: false, modal: true, resizable: false, dialogClass: \'notitle\' }); jQuery(\'#kgvid_GalleryPlayerDiv\').bind("dialogclose", function (event, ui) { jQuery(\'#kgvid_GalleryVideo\').attr(\'src\', \'\'); });});</script>';
647
+
648
+ } //if there are attachments
649
+ } //if gallery
650
+ return $code;
651
+ }
652
+ add_shortcode('FMP', 'KGVID_shortcode');
653
+ add_shortcode('KGVID', 'KGVID_shortcode');
654
 
655
+ function kgvid_ajax_generate_encode_checkboxes() {
 
 
 
 
656
 
657
+ global $wpdb;
 
 
 
 
658
 
659
+ check_ajax_referer( 'video-embed-thumbnail-generator-nonce', 'security' );
660
+ $movieurl = $_POST['movieurl'];
661
+ $post_id = $_POST['post_id'];
662
+ $page = $_POST['page'];
663
+
664
+ if (isset($_POST['encodeformats'])) {
665
+ $encode_checked = $_POST['encodeformats'];
666
+ foreach ( $encode_checked as $format => $checked ) {
667
+ if ( $checked == "true" ) { update_post_meta($post_id, '_kgflashmediaplayer-encode'.$format, 'on'); }
668
+ else { update_post_meta($post_id, '_kgflashmediaplayer-encode'.$format, 'notchecked'); }
669
  }
670
+ }
671
 
672
+ $checkboxes = kgvid_generate_encode_checkboxes($movieurl, $post_id, $page);
673
+ $arr = array("embed_display" => $checkboxes);
674
+ echo json_encode($arr);
675
+ die();
676
+
677
+ }
678
+ add_action('wp_ajax_kgvid_generate_encode_checkboxes', 'kgvid_ajax_generate_encode_checkboxes');
679
 
680
+ function kgvid_generate_encode_checkboxes($movieurl, $post_id, $page) {
681
+
682
+ $options = get_option('kgvid_video_embed_options');
683
+ $video_embed_queue = get_option('kgvid_video_embed_queue');
684
+ $video_formats = kgvid_video_formats();
685
+
686
+ $video_queued = false;
687
+ $something_to_encode = false;
688
+ $encoding_now = false;
689
+ $encode_disabled = "";
690
+ $post_mime_type = "";
691
+ $actualwidth = "1921";
692
+ $actualheight = "1081";
693
+ $encodevideo_info = array();
694
+
695
+ if ( !empty($movieurl) ) {
696
+ $encodevideo_info = kgvid_encodevideo_info($movieurl, $post_id);
697
+
698
+ if ( is_numeric($post_id) ) {
699
+ $post_mime_type = get_post_mime_type($post_id);
700
+ $actualwidth = get_post_meta($post_id, "_kgflashmediaplayer-actualwidth", true);
701
+ $actualheight = get_post_meta($post_id, "_kgflashmediaplayer-actualheight", true);
702
  }
703
+ else {
704
+
705
+ $post_mime_type = pathinfo($movieurl, PATHINFO_EXTENSION);
706
+ if ( $post_mime_type == "m4v" ) { $post_mime_type = "mp4"; }
707
+
708
+ if ( !empty($video_embed_queue) ) {
709
+ foreach ($video_embed_queue as $video_key => $video_entry) {
710
+ if ( $video_entry['movieurl'] == $movieurl ) {
711
+ if ( array_key_exists('movie_info', $video_entry) ) {
712
+ $actualwidth = $video_entry['movie_info']['width'];
713
+ $actualheight = $video_entry['movie_info']['height'];
714
+ }
715
+ break;
716
+ }
717
+ }
718
+ }
719
+ reset($video_embed_queue);
720
+
721
+ if ( $page == "queue" ) {
722
+ $info = pathinfo($movieurl);
723
+ $post_id = 'singleurl_'.basename($movieurl,'.'.$info['extension']);
724
+ }
 
 
 
 
 
 
725
  }
726
+ }
727
+ else {
728
+ $encode_disabled = ' disabled title="Please enter a valid video URL"';
729
+ }
730
+
731
+ if ( $options['ffmpeg_exists'] == "notinstalled" ) {
732
+ $ffmpeg_disabled_text = 'disabled="disabled" title="'.strtoupper($options['video_app']).' not found at '.$options['app_path'].'"';
733
+ }
734
+ else { $ffmpeg_disabled_text = ""; }
735
+
736
+ $video_key = false;
737
+
738
+ if ( !empty($video_embed_queue) && !empty($movieurl) ) {
739
+ foreach ($video_embed_queue as $video_key => $video_entry) {
740
+ if ( $video_entry['movieurl'] == $movieurl ) {
741
+ foreach ( $video_entry['encode_formats'] as $format => $value ) {
742
+ $video_formats[$format]['status'] = $value['status'];
743
+ }
744
+ $video_queued = true;
745
+ break;
746
+ }
747
  }
748
  }
749
+ $checkboxes = '<div id="attachments-'.$post_id.'-kgflashmediaplayer-encodeboxes">';
750
+ foreach ( $video_formats as $format => $format_stats ) {
751
+ $encodeset[$format] = "";
752
+ $checked[$format] = "";
753
+ $meta[$format] = "";
754
+ $disabled[$format] = "";
755
 
756
+ if ( !array_key_exists('status', $format_stats) ) { $format_stats['status'] = "notchecked"; } //if this video isn't in the queue
757
 
758
+ if ( is_numeric($post_id) ) { $encodeset[$format] = get_post_meta($post_id, "_kgflashmediaplayer-encode".$format, true); }
759
+ if ( $encodeset[$format] == "" ) { $encodeset[$format] = $options['encode_'.$format]; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
760
 
761
+ if ( $format_stats['status'] == "lowres" || $actualheight != "" && ($format == "1080" || $format == "720") && ( (strpos($post_mime_type, "mp4") && $actualheight <= $format_stats['height']) || (!strpos($post_mime_type, "mp4") && $actualheight < $format_stats['height']) ) ) { continue; } //if the format is bigger than the original video, skip the checkbox
762
 
763
+ if ( $encodeset[$format] == "on" || $format_stats['status'] == "queued" ) { $checked[$format] = 'checked'; }
764
 
765
+ if ( $format_stats['status'] != "notchecked" ) { //File is in queue
766
+ $meta[$format] = ' <strong>'.ucfirst($format_stats['status']).'</strong>';
767
+ if ( $format_stats['status'] == "error" ) {
768
+ $meta[$format] .= ': <span style="color:red;">'.$video_embed_queue[$video_key]['encode_formats'][$format]['lastline']."</span>";
769
+ }
770
+ }
771
+
772
+ if ( !empty($encodevideo_info) ) {
773
+ if ( $encodevideo_info[$format.'_exists'] ) { //if the video file exists
774
+ if ( $format_stats['status'] != "encoding" ) { // not currently encoding
775
+ if ( $format_stats['status'] == "notchecked" ) { $meta[$format] = ' <strong>Encoded</strong>'; }
776
+ $meta[$format] .= '<a id="delete-'.$post_id.'-'.$format.'" class="kgvid_delete-format" onclick="kgvid_delete_video(\''.$movieurl.'\', \''.$post_id.'\', \''.$format.'\');" href="javascript:void(0)">Delete Permanently</a>';
777
+ $disabled[$format] = ' disabled title="Format already exists"';
778
+ $checked[$format] = '';
779
+ }
780
+ if ( $format_stats['status'] == "encoding" ) {
781
+ $encoding_now = true;
782
+ $disabled[$format] = ' disabled title="Currently Encoding"';
783
+ $checked[$format] = 'checked';
784
+ $progress = kgvid_encode_progress($video_key, $format, $page);
785
+ $meta[$format] = $progress['embed_display'];
786
+ }
787
+
788
+ }
789
+ }
790
+
791
+ if ( $checked[$format] == "" ) { $something_to_encode = true; }
792
+
793
+ $checkboxes .= "\n\t\t\t".'<input type="checkbox" id="attachments-'.$post_id.'-kgflashmediaplayer-encode'.$format.'" name="attachments['.$post_id.'][kgflashmediaplayer-encode'.$format.']" '.$checked[$format].' '.$ffmpeg_disabled_text.$disabled[$format].'> <label for="attachments-'.$post_id.'-kgflashmediaplayer-encode'.$format.'">'.$format_stats['name'].'</label> <span id="attachments-'.$post_id.'-kgflashmediaplayer-meta'.$format.'">'.$meta[$format].'</span><br />';
794
 
795
+ }
796
+ if ( $something_to_encode == false ) {
797
+ $encode_disabled = ' disabled title="Nothing to encode" style="display:none;"';
798
+ }
799
+
800
+ if ( $page == "queue" ) { $button_text = "Update"; }
801
+ else { $button_text = "Encode"; }
802
+
803
+ $checkboxes .= '<input type="button" id="attachments-'.$post_id.'-kgflashmediaplayer-encode" name="attachments['.$post_id.'][kgflashmediaplayer-encode]" class="button-secondary" value="'.$button_text.'" onclick="kgvid_generate_thumb(\''.$post_id.'\', \'enqueue\');" '.$ffmpeg_disabled_text.$encode_disabled.'/><div style="display:block;" id="attachments-'.$post_id.'-encodeplaceholder"></div>';
804
+
805
+ if ( $page != "queue" ) {
806
+ $checkboxes .= '<small><em>Generates additional video formats compatible with most mobile & HTML5-compatible browsers.</em></small>';
807
+ }
808
+
809
+ if ( $video_queued == true ) {
810
+ while ( count($video_formats) > 0 ) {
811
+ $last_format = array_pop( $video_formats );
812
+ if ( $last_format['status'] != "notchecked" ) { break; } //get the final queued format
813
+ }
814
+
815
+ if ( !$encoding_now && ($last_format['status'] == "queued" || $last_format['status'] == "canceling") ) {
816
+ $checkboxes .= '<script type="text/javascript">percent_timeout = setTimeout(function(){ kgvid_redraw_encode_checkboxes("'.$video_entry['movieurl'].'", "'.$video_entry['attachmentID'].'", "'.$page.'") }, 10000); jQuery(\'#wpwrap\').data("KGVIDCheckboxTimeout", percent_timeout);</script>';
817
+ }
818
+ }
819
+ $checkboxes .= '</div>'; //close encodeboxes div
820
+
821
+ return $checkboxes;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
822
  }
 
823
 
824
+ function kgvid_generate_queue_table() {
825
 
826
+ $html = "";
 
 
 
 
 
 
 
 
 
 
 
827
 
828
+ $video_embed_queue = get_option('kgvid_video_embed_queue');
829
+ $nonce = wp_create_nonce('video-embed-thumbnail-generator-nonce');
 
830
 
831
+ if ( !empty($video_embed_queue) ) {
832
+
833
+ $video_formats = kgvid_video_formats();
834
+ $currently_encoding = array();
835
+ $nonce = wp_create_nonce('video-embed-thumbnail-generator-nonce');
836
+ $html .= "<input type='hidden' name='attachments[kgflashmediaplayer-security]' value='".$nonce."' />";
837
+
838
+ foreach ( $video_embed_queue as $order => $video_entry ) {
839
+ /* if ( $video_entry['attachmentID'] == "singleurl" ) {
840
+ $info = pathinfo($video_entry['movieurl']);
841
+ $video_entry['attachmentID'] = 'singleurl_'.basename($video_entry['movieurl'],'.'.$info['extension']);
842
+ } */
843
+ $html .= "\t<tr id='tr_".$video_entry['attachmentID']."'";
844
+ foreach ( $video_formats as $format => $format_stats ) {
845
+ if ( $video_entry['encode_formats'][$format]['status'] == "encoding" ) {
846
+ $currently_encoding[$order] = true;
847
+ $html .= " class='currently_encoding' ";
848
+ break;
849
+ }
850
+ else { $currently_encoding[$order] = false; }
851
+ }
852
+ $html .= "><input type='hidden' name='attachments[kgflashmediaplayer-security]' value='".$nonce."' />";
853
+ $html .= "<td id='td_".$video_entry['attachmentID']."'>".strval(intval($order)+1)."</td>\n";
854
+ $thumbnail_url = get_post_meta($video_entry['attachmentID'], "_kgflashmediaplayer-poster", true);
855
+ $thumbnail_html = "";
856
+ if ($thumbnail_url != "" ) {
857
+ $thumbnail_html = '<img width="100" src="'.$thumbnail_url.'">';
858
+ }
859
+ if ( is_numeric($video_entry['attachmentID']) ) {
860
+ $moviefilepath = get_attached_file($video_entry['attachmentID']);
861
+ $attachmentlink = "media.php?attachment_id=".$video_entry['attachmentID']."&action=edit";
862
+ }
863
+ else {
864
+ $moviefilepath = $video_entry['movieurl'];
865
+ $attachmentlink = $video_entry['movieurl'];
866
+ }
867
+ $html .= "\t\t\t\t\t<td><a href='".$attachmentlink."'> ".$thumbnail_html."</a></td>\n";
868
+ $html .= "\t\t\t\t\t<td><a id='".$moviefilepath."' href='".$attachmentlink."'>".basename($moviefilepath)."</a><input type='hidden' name='attachments[".$video_entry['attachmentID']."][kgflashmediaplayer-url]' value='".$video_entry['movieurl']."'></td>\n";
869
+ $html .= "\t\t\t\t\t<td class='queue_encode_formats' id='formats_".$video_entry['attachmentID']."'>";
870
+ $html .= kgvid_generate_encode_checkboxes($video_entry['movieurl'], $video_entry['attachmentID'], 'queue');
871
+ $html .= "</td>\n";
872
+ $html .= "\t\t\t\t\t<td>";
873
+ $html .= "<a id='clear_".$video_entry['attachmentID']."' class='submitdelete' href='javascript:void(0)' onclick='kgvid_encode_queue(\"delete\", ".$order.")'";
874
+ if ( $currently_encoding[$order] ) { $html .= " style='display:none;'"; }
875
+ $html .= ">Clear</a>";
876
+ $html .= "</td></tr>\n";
877
+ }
878
+ }
879
+ else { $html = "\t<tr><td colspan='5'>Queue is Empty</td></tr>\n"; }
880
 
881
+ return $html;
 
 
 
 
882
 
883
+ }
 
884
 
885
+ function kgvid_add_FFMPEG_Queue_Page() {
886
+ $options = get_option('kgvid_video_embed_options');
887
+ if ( $options['ffmpeg_exists'] == "on" ) { //only add the queue page if FFMPEG is installed
888
+ add_submenu_page('tools.php', 'Video Embed & Thumbnail Generator Encoding Queue', 'Video Encode Queue', 'administrator', 'kgvid_video_encoding_queue', 'kgvid_FFMPEG_Queue_Page');
889
+ }
890
+ }
891
+ add_action('admin_menu', 'kgvid_add_FFMPEG_Queue_Page');
892
 
893
+ function kgvid_FFMPEG_Queue_Page() {
894
+
895
+ ?>
896
+ <div class="wrap">
897
+ <script>
898
+ jQuery(function() {
899
+ jQuery( "#sortable tbody.rows" ).sortable({
900
+ items: "tr:not(.currently_encoding)",
901
+ containment: "parent",
902
+ opacity: 0.6,
903
+ helper: function(e, tr) {
904
+ var $originals = tr.children();
905
+ var $helper = tr.clone();
906
+ $helper.children().each(function(index)
907
+ {
908
+ // Set helper cell sizes to match the original sizes
909
+ jQuery(this).width($originals.eq(index).width())
910
+ });
911
+ return $helper;
912
+ }
913
+ });
914
+ jQuery( "#sortable tbody.rows" ).disableSelection();
915
+ jQuery( "#sortable tbody.rows" ).bind("sortupdate", function(event, ui) {
916
+ jQuery('table tr').each(function(){
917
+ var $new_index = jQuery(this).index();
918
+ var $new_ID = "tr_" + $new_index;
919
+ jQuery(this).children('td:first-child').html($new_index);
920
+ jQuery(this).attr("id", $new_ID);
921
+ if ( $new_index == 0 ) { jQuery(this).addClass("currently_encoding"); }
922
+ else { jQuery(this).removeClass("currently_encoding"); }
923
+ })
924
+ });
925
+ });
926
+
927
+ jQuery("#sortable .submitdelete").live("click", function (e) {
928
+ jQuery(this).closest("tr").fadeOut("slow", function(){ jQuery(this).remove(); });
929
+ jQuery("#sortable tbody.rows").trigger("sortupdate");
930
+ });
931
+
932
+
933
+
934
+ </script>
935
+ <div id="icon-tools" class="icon32"><br /></div>
936
+ <h2>Video Embed & Thumbnail Generator Encoding Queue</h2>
937
+ <p></p>
938
+ <form method="post" action="tools.php?page=kgvid_video_encoding_queue">
939
+ <?php wp_nonce_field('video-embed-thumbnail-generator-nonce','video-embed-thumbnail-generator-nonce'); ?>
940
+ <table class="widefat">
941
+ <thead>
942
+ <tr>
943
+ <th>Order</th>
944
+ <th>Thumbnail</th>
945
+ <th>File</th>
946
+ <th>Formats</th>
947
+ <th>Actions</th>
948
+ </thead>
949
+ <tfoot>
950
+ <tr>
951
+ <th>Order</th>
952
+ <th>Thumbnail</th>
953
+ <th>File</th>
954
+ <th>Formats</th>
955
+ <th>Actions</th>
956
+ </tfoot>
957
+ <tbody class="rows">
958
+ <?php echo kgvid_generate_queue_table(); ?>
959
+ </tbody>
960
+ </table>
961
+ <!-- <input type='button' class='button-secondary' value='sort' onclick='jQuery("#sortable tbody.rows").trigger("sortupdate"); jQuery( "#sortable tbody.rows" ).sortable("refresh");'> -->
962
+ <p>
963
+
964
+ <input type='button' class='button-secondary' value='Clear All Completed' onclick='kgvid_encode_queue("clear_completed", 0);'>
965
+ </p>
966
+ </form>
967
+ </div>
968
+ <?php
969
+ }
970
 
971
+ function kgvid_addFMPOptionsPage() {
972
+ add_options_page('Video Embed & Thumbnail Generator', 'Video Embed & Thumbnail Generator', 'administrator', __FILE__, 'kgvid_FMPOptionsPage');
973
+ }
974
+ add_action('admin_menu', 'kgvid_addFMPOptionsPage');
975
+
976
+ function kgvid_FMPOptionsPage() {
977
+ ?>
978
+ <div class="wrap">
979
+ <div class="icon32" id="icon-options-general"><br></div>
980
+ <h2>Video Embed & Thumbnail Generator</h2>
981
+ <form method="post" action="options.php">
982
+ <?php settings_fields('kgvid_video_embed_options'); ?>
983
+ <?php do_settings_sections(__FILE__); ?>
984
+ <p class='submit'>
985
+ <?php submit_button('Save Changes', 'primary', 'submit', false); submit_button('Reset Options', 'secondary', 'video-embed-thumbnail-generator-reset', false); ?>
986
+ </p>
987
+ </form>
988
+ <script type="text/javascript">
989
+ var embed_method = jQuery('#embed_method').val();
990
+ var video_app = jQuery('#video_app').val();
991
+ jQuery(document).ready(function() {
992
+ kgvid_hide_plugin_settings(embed_method);
993
+ kgvid_hide_ffmpeg_settings(video_app);
994
+ }
995
+ );
996
+ </script>
997
+ </div>
998
+ <?php
999
+ }
1000
 
1001
+ function kgvid_video_embed_options_init() {
 
1002
 
1003
+ register_setting('kgvid_video_embed_options', 'kgvid_video_embed_options', 'kgvid_video_embed_options_validate' );
1004
+
1005
+ $options = get_option('kgvid_video_embed_options');
1006
+
1007
+ add_settings_section('kgvid_video_embed_plugin_settings', 'Plugin Settings', 'kgvid_plugin_settings_section_callback', __FILE__);
1008
+ add_settings_section('kgvid_video_embed_playback_settings', 'Default Video Playback Settings', 'kgvid_plugin_playback_settings_section_callback', __FILE__);
1009
+ add_settings_section('kgvid_video_embed_flash_settings', 'The following options will only affect Flash playback', 'kgvid_plugin_flash_settings_section_callback', __FILE__);
1010
+
1011
+
1012
+ add_settings_field('embed_method', 'Player:', 'kgvid_embed_method_callback', __FILE__, 'kgvid_video_embed_plugin_settings', array( 'label_for' => 'embed_method' ) );
1013
+ add_settings_field('template', 'Attachment Template Override:', 'kgvid_template_callback', __FILE__, 'kgvid_video_embed_plugin_settings', array( 'label_for' => 'template' ) );
1014
+ add_settings_field('encode_formats', 'Default Mobile/HTML5 Video encode formats:', 'kgvid_encode_formats_callback', __FILE__, 'kgvid_video_embed_plugin_settings');
1015
+ add_settings_field('app_path', 'Path to applications on server:', 'kgvid_app_path_callback', __FILE__, 'kgvid_video_embed_plugin_settings', array( 'label_for' => 'app_path' ) );
1016
+ add_settings_field('video_app', 'Application for thumbnails & encoding:', 'kgvid_video_app_callback', __FILE__, 'kgvid_video_embed_plugin_settings', array( 'label_for' => 'video_app' ) );
1017
+ add_settings_field('ffmpeg_vpre', 'FFMPEG Options:', 'kgvid_ffmpeg_vpre_callback', __FILE__, 'kgvid_video_embed_plugin_settings', array( 'label_for' => 'ffmpeg_vpre' ) );
1018
+ add_settings_field('moov', 'Application to fix encoded H.264 headers for streaming:', 'kgvid_moov_callback', __FILE__, 'kgvid_video_embed_plugin_settings', array( 'label_for' => 'moov' ) );
1019
+ add_settings_field('generate_thumbs', 'Default number of thumbnails to generate:', 'kgvid_generate_thumbs_callback', __FILE__, 'kgvid_video_embed_plugin_settings', array( 'label_for' => 'generate_thumbs' ) );
1020
+ add_settings_field('titlecode', 'Video Title Text HTML Formatting:', 'kgvid_titlecode_callback', __FILE__, 'kgvid_video_embed_plugin_settings', array( 'label_for' => 'titlecode' ) );
1021
+ add_settings_field('poster', 'Poster image:', 'kgvid_poster_callback', __FILE__, 'kgvid_video_embed_playback_settings', array( 'label_for' => 'poster' ) );
1022
+ add_settings_field('width', 'Max video width:', 'kgvid_width_callback', __FILE__, 'kgvid_video_embed_playback_settings', array( 'label_for' => 'width' ) );
1023
+ add_settings_field('height', 'Max video height:', 'kgvid_height_callback', __FILE__, 'kgvid_video_embed_playback_settings', array( 'label_for' => 'height' ) );
1024
+ add_settings_field('gallery_width', 'Max gallery video width:', 'kgvid_gallery_width_callback', __FILE__, 'kgvid_video_embed_playback_settings', array( 'label_for' => 'gallery_width' ) );
1025
+ add_settings_field('gallery_height', 'Max gallery video height:', 'kgvid_gallery_height_callback', __FILE__, 'kgvid_video_embed_playback_settings', array( 'label_for' => 'gallery_height' ) );
1026
+ add_settings_field('gallery_thumb', 'Gallery thumbnail width:', 'kgvid_gallery_thumb_callback', __FILE__, 'kgvid_video_embed_playback_settings', array( 'label_for' => 'gallery_thumb' ) );
1027
+ add_settings_field('controlbar_style', 'Controlbar style:', 'kgvid_controlbar_style_callback', __FILE__, 'kgvid_video_embed_playback_settings', array( 'label_for' => 'controlbar_style' ) );
1028
+ add_settings_field('autoplay', 'Autoplay behavior:', 'kgvid_autoplay_callback', __FILE__, 'kgvid_video_embed_playback_settings', array( 'label_for' => 'autoplay' ) );
1029
+ add_settings_field('loop', 'Loop behavior:', 'kgvid_loop_callback', __FILE__, 'kgvid_video_embed_playback_settings', array( 'label_for' => 'loop' ) );
1030
+ add_settings_field('js_skin', 'Skin Class:', 'kgvid_js_skin_callback', __FILE__, 'kgvid_video_embed_playback_settings', array( 'label_for' => 'js_skin' ) );
1031
+ add_settings_field('endOfVideoOverlay', 'End of video image:', 'kgvid_endOfVideoOverlay_callback', __FILE__, 'kgvid_video_embed_flash_settings' );
1032
+ add_settings_field('bgcolor', 'Background color:', 'kgvid_bgcolor_callback', __FILE__, 'kgvid_video_embed_flash_settings', array( 'label_for' => 'bgcolor' ) );
1033
+ add_settings_field('configuration', 'XML configuration file:', 'kgvid_configuration_callback', __FILE__, 'kgvid_video_embed_flash_settings', array( 'label_for' => 'configuration' ) );
1034
+ add_settings_field('skin', 'Video skin file:', 'kgvid_skin_callback', __FILE__, 'kgvid_video_embed_flash_settings', array( 'label_for' => 'skin' ) );
1035
+ add_settings_field('stream_type', 'Video stream type:', 'kgvid_stream_type_callback', __FILE__, 'kgvid_video_embed_flash_settings', array( 'label_for' => 'stream_type' ) );
1036
+ add_settings_field('scale_mode', 'Video scale mode:', 'kgvid_scale_mode_callback', __FILE__, 'kgvid_video_embed_flash_settings', array( 'label_for' => 'scale_mode' ) );
1037
+ add_settings_field('autohide', 'Autohide behavior:', 'kgvid_autohide_callback', __FILE__, 'kgvid_video_embed_flash_settings', array( 'label_for' => 'autohide' ) );
1038
+ add_settings_field('playbutton', 'Play button overlay:', 'kgvid_playbutton_callback', __FILE__, 'kgvid_video_embed_flash_settings', array( 'label_for' => 'playbutton' ) );
1039
+ }
1040
+ add_action('admin_init', 'kgvid_video_embed_options_init' );
1041
 
1042
+ function kgvid_update_settings() {
1043
+
1044
+ global $wpdb;
1045
+
1046
+ $options = get_option('kgvid_video_embed_options');
1047
+
1048
+ if ( empty($options) ) { // run if the new settings don't exist yet (before version 3.0)
1049
+
1050
+ $default_options = kgvid_default_options_fn();
1051
+ $options = array();
1052
+
1053
+ $old_setting_equivalents = array (
1054
+ "width"=>"wp_FMP_width",
1055
+ "height"=>"wp_FMP_height",
1056
+ "controlbar_style"=>"wp_FMP_controlbar_style",
1057
+ "poster"=>"wp_FMP_poster",
1058
+ "endOfVideoOverlay"=>"wp_FMP_endOfVideoOverlay",
1059
+ "autohide"=>"wp_FMP_autohide",
1060
+ "autoplay"=>"wp_FMP_autoplay",
1061
+ "loop"=>"wp_FMP_loop",
1062
+ "playbutton"=>"wp_FMP_playbutton",
1063
+ "stream_type"=>"wp_FMP_stream_type",
1064
+ "scale_mode"=>"wp_FMP_scale_mode",
1065
+ "bgcolor"=>"wp_FMP_bgcolor",
1066
+ "configuration"=>"wp_FMP_configuration",
1067
+ "skin"=>"wp_FMP_skin",
1068
+ "app_path"=>"wp_FMP_ffmpeg",
1069
+ "ffmpeg_exists"=>"wp_FMP_ffmpeg_exists",
1070
+ "encode_mobile"=>"wp_FMP_encodemobile",
1071
+ "encode_ogg"=>"wp_FMP_encodeogg",
1072
+ "encode_webm"=>"wp_FMP_encodewebm",
1073
+ "ffmpeg_vpre"=>"wp_FMP_vpre",
1074
+ "template"=>"wp_FMP_template",
1075
+ "titlecode"=>"wp_FMP_titlecode");
1076
+
1077
+ foreach ($old_setting_equivalents as $new_setting => $old_setting) { //apply any old settings to the new database entry then delete them
1078
+ $old_setting_value = get_option($old_setting, "no_setting");
1079
+ if ( $old_setting_value != "no_setting" ) {
1080
+ if ( $old_setting_value == "true" ) { $old_setting_value = "on"; }
1081
+ $options[$new_setting] = $old_setting_value;
1082
+ delete_option($old_setting);
1083
+ }
1084
+ }
1085
+ $wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE 'wp_FMP%'" );
1086
+
1087
+ foreach ( $default_options as $key => $value ) { //apply default values for any settings that didn't exist before
1088
+ if ( !array_key_exists($key, $options) ) { $options[$key] = $value; }
1089
+ $options['embed_method'] = "Strobe Media Playback";
1090
+ }
1091
+
1092
+ update_option('kgvid_video_embed_options', $options);
1093
+ }
1094
+ }
1095
+ add_action('init', 'kgvid_update_settings' );
1096
+
1097
+ function kgvid_video_embed_options_validate($input) { //validate & sanitize input from settings form
1098
+
1099
+ $default_options = kgvid_default_options_fn();
1100
+
1101
+ if (isset ($_POST["video-embed-thumbnail-generator-reset"])) {
1102
+ $input = $default_options;
1103
+ add_settings_error( __FILE__, "options-reset", "Video Embed & Thumbnail Generator settings reset to default values.", "updated" );
1104
+ }
1105
+
1106
+ $ffmpeg_info = kgvid_check_ffmpeg_exists($input, false);
1107
+
1108
+ if ( $ffmpeg_info['exec_enabled'] == false ) {
1109
+ add_settings_error( __FILE__, "exec-disabled", "EXEC function is disabled in PHP settings. You can embed existing videos, but video thumbnail generation and Mobile/HTML5 video encoding will not work. Contact your System Administrator to find out if you can enable EXEC.", "error");
1110
+ $input['ffmpeg_exists'] = "notinstalled";
1111
+ }
1112
+ elseif ( $ffmpeg_info['ffmpeg_exists'] == false ) {
1113
+ add_settings_error( __FILE__, "ffmpeg-not-found", strtoupper($input['video_app'])." not found at ".$input['app_path'].". You can embed existing videos, but video thumbnail generation and Mobile/HTML5 video encoding will not work.", "error");
1114
+ $input['ffmpeg_exists'] = "notinstalled";
1115
+ }
1116
+ if ( $ffmpeg_info['ffmpeg_exists'] == true ) { $input['ffmpeg_exists'] = "on"; }
1117
+
1118
+ $input['titlecode'] = wp_kses_post( $input['titlecode'] );
1119
+
1120
+ // load all settings and make sure they get a value of false if they weren't entered into the form
1121
+ foreach ( $default_options as $key => $value ) {
1122
+ if ( !array_key_exists($key, $input) ) { $input[$key] = false; }
1123
+ }
1124
+
1125
+ $input['version'] = $default_options['version']; //since this isn't user selectable it has to be re-entered every time
1126
+
1127
+ return $input;
1128
+ }
1129
+
1130
+ //callback functions generating HTML for the settings form
1131
+
1132
+ function kgvid_plugin_settings_section_callback() { }
1133
+ function kgvid_plugin_playback_settings_section_callback() { }
1134
+ function kgvid_plugin_flash_settings_section_callback() { }
1135
+
1136
+ function kgvid_embed_method_callback() {
1137
+ $options = get_option('kgvid_video_embed_options');
1138
+ $items = array("Strobe Media Playback", "Video.js");
1139
+ echo "<select onchange='kgvid_hide_plugin_settings(this.value);' id='embed_method' name='kgvid_video_embed_options[embed_method]'>";
1140
+ foreach($items as $item) {
1141
+ $selected = ($options['embed_method']==$item) ? 'selected="selected"' : '';
1142
+ echo "<option value='$item' $selected>$item</option>";
1143
+ }
1144
+ echo "</select> <a class='kgvid_tooltip' href='#'><img src='../wp-includes/images/blank.gif'><span class='kgvid_tooltip_classic'>This plugin has used Strobe Media Playback for Flash playback in the past, but you can choose to use the newer and lighter Video-js method which will give priority to HTML5 and only use Flash as a fallback.</span></a>";
1145
+ }
1146
+
1147
+ function kgvid_template_callback() {
1148
+ $options = get_option('kgvid_video_embed_options');
1149
+ echo "<input ".checked( $options['template'], "on", false )." id='template' name='kgvid_video_embed_options[template]' type='checkbox' /> <label for='template'>Enable minimalist video attachment template.</label><a class='kgvid_tooltip' href='#'><img src='../wp-includes/images/blank.gif'><span class='kgvid_tooltip_classic'>Allows easy iframe embedding on other sites. Will override any existing video attachment template page, which is usually a good thing.</span></a>";
1150
+ }
1151
+
1152
+ function kgvid_encode_formats_callback() {
1153
+ $options = get_option('kgvid_video_embed_options');
1154
+ echo "<input ".checked( $options['encode_1080'], "on", false )." id='encode_1080' name='kgvid_video_embed_options[encode_1080]' type='checkbox' /> <label for='encode_1080'>1080p H.264 <small><em>(iPhone 4s+, iPad 2+, few Android, Windows Phone 8, Chrome, Safari, IE 9+)</em></small></label> <a class='kgvid_tooltip' href='#'><img src='../wp-includes/images/blank.gif'><span class='kgvid_tooltip_classic'>This is complicated. If you have FFMPEG/LIBAV and the proper libraries installed, you can choose to encode your uploaded video into as many as five additional formats depending on your original source. Different browsers have different playback capabilities. Most desktop browsers can play H.264, and all modern mobile devices can play at least 480p H.264. If you create multiple H.264 resolutions, the highest resolution supported by the device will be served up automatically. The plugin will not upconvert your video, so if you upload a 720p video, it will not waste your time creating a 1080p version. There was a time when it seemed like a good idea to provide OGV or WEBM for some desktop browsers, but even Firefox is planning to allow H.264 playback in the future and I no longer recommend encoding OGV or WEBM unless you expect a large number of no-Flash sticklers visiting your site.</span></a><br />";
1155
+ echo "<input ".checked( $options['encode_720'], "on", false )." id='encode_720' name='kgvid_video_embed_options[encode_720]' type='checkbox' /> <label for='encode_720'>720p H.264 <small><em>(iPhone 4+, iPad, some Android, Chrome, Safari, IE 9+)</em></small></label><br />";
1156
+ echo "<input ".checked( $options['encode_mobile'], "on", false )." id='encode_mobile' name='kgvid_video_embed_options[encode_mobile]' type='checkbox' /> <label for='encode_mobile'>480p H.264 <small><em>(iOS, Android, Windows Phone 7, Chrome, Safari, IE 9+)</em></small></label><br />";
1157
+ echo "<input ".checked( $options['encode_webm'], "on", false )." id='encode_webm' name='kgvid_video_embed_options[encode_webm]' type='checkbox' /> <label for='encode_webm'>WEBM <small><em>(Firefox, Chrome, Android 2.3+, Opera)</em></small></label><br />";
1158
+ echo "<input ".checked( $options['encode_ogg'], "on", false )." id='encode_ogg' name='kgvid_video_embed_options[encode_ogg]' type='checkbox' /> <label for='encode_ogg'>OGV <small><em>(Firefox, Chrome, Android 2.3+, Opera)</em></small></label>";
1159
+ }
1160
+
1161
+ function kgvid_app_path_callback() {
1162
+ $options = get_option('kgvid_video_embed_options');
1163
+ echo "<input id='app_path' name='kgvid_video_embed_options[app_path]' size='40' type='text' value='".stripslashes($options['app_path'])."' /><a class='kgvid_tooltip' href='#'><img src='../wp-includes/images/blank.gif'><span class='kgvid_tooltip_classic'>Don't include trailing slash. Example: <code>/usr/local/bin</code>. On Windows servers, use / instead of C:\\";
1164
+ }
1165
+
1166
+ function kgvid_video_app_callback() {
1167
+ $options = get_option('kgvid_video_embed_options');
1168
+ $items = array("FFMPEG"=>"ffmpeg", "LIBAV"=>"avconv");
1169
+ echo "<select onchange='kgvid_hide_ffmpeg_settings(this.value);' id='video_app' name='kgvid_video_embed_options[video_app]'>";
1170
+ foreach($items as $name => $value) {
1171
+ $selected = ($options['video_app']==$value) ? 'selected="selected"' : '';
1172
+ echo "<option value='$value' $selected>$name</option>";
1173
+ }
1174
+ echo "</select> <a class='kgvid_tooltip' href='#'><img src='../wp-includes/images/blank.gif'><span class='kgvid_tooltip_classic'>FFMPEG split into two separate branches in 2011. The new branch is called LIBAV. Both are still actively developed. Debian & Ubuntu users probably have LIBAV installed.</span></a>";
1175
+ }
1176
+
1177
+ function kgvid_ffmpeg_vpre_callback() {
1178
+ $options = get_option('kgvid_video_embed_options');
1179
+ echo "<input ".checked( $options['ffmpeg_vpre'], "on", false )." id='ffmpeg_vpre' name='kgvid_video_embed_options[ffmpeg_vpre]' type='checkbox' /> <label for='ffmpeg_vpre'>Enable FFMPEG 'vpre' flags.</label> <a class='kgvid_tooltip' href='#'><img src='../wp-includes/images/blank.gif'><span class='kgvid_tooltip_classic'>Enable if your installed version of FFMPEG is old enough that libx264 requires vpre flags to operate (Dreamhost users must turn this on). This should help if you can encode WEBM or OGV files but H264/Mobile files fail. It will cause newer versions of FFMPEG to fail and probably won't work on Windows servers.</span></a>";
1180
+ }
1181
+
1182
+ function kgvid_moov_callback() {
1183
+ $options = get_option('kgvid_video_embed_options');
1184
+ $items = array("none", "qt-faststart", "MP4Box");
1185
+ echo "<select id='moov' name='kgvid_video_embed_options[moov]'>";
1186
+ foreach($items as $item) {
1187
+ $selected = ($options['moov']==$item) ? 'selected="selected"' : '';
1188
+ echo "<option value='$item' $selected>$item</option>";
1189
+ }
1190
+ echo "</select> <a class='kgvid_tooltip' href='#'><img src='../wp-includes/images/blank.gif'><span class='kgvid_tooltip_classic'>FFMPEG & LIBAV place moov atoms at the end of H.264 encoded files, which forces the entire file to download before playback can start and prevents the Flash player from playing them at all. If either of these programs is installed in the application path, you can choose to run it after encoding is finished in order to allow playback while downloading.</span></a>";
1191
+ }
1192
+
1193
+ function kgvid_generate_thumbs_callback() {
1194
+ $options = get_option('kgvid_video_embed_options');
1195
+ echo "<input id='generate_thumbs' name='kgvid_video_embed_options[generate_thumbs]' size='3' type='text' value='".strval($options['generate_thumbs'])."' />";
1196
+ }
1197
+
1198
+ function kgvid_titlecode_callback() {
1199
+ $options = get_option('kgvid_video_embed_options');
1200
+ echo "<input id='titlecode' name='kgvid_video_embed_options[titlecode]' size='40' type='text' value='".htmlentities(stripslashes($options['titlecode']))."' /> <a class='kgvid_tooltip' href='#'><img src='../wp-includes/images/blank.gif'><span class='kgvid_tooltip_classic'>HTML tag applied to video titles inserted by the plugin. Ex: &lt;strong&gt;, &lt;em&gt;, &lt;H2&gt;, &lt;span class='videotitle'&gt;. Corresponding closing tags will be applied to the end of the title automatically.</span></a>";
1201
+ }
1202
+
1203
+ function kgvid_poster_callback() {
1204
+ $options = get_option('kgvid_video_embed_options');
1205
+ echo "<input id='poster' name='kgvid_video_embed_options[poster]' size='60' type='text' value='".$options['poster']."' />";
1206
+ }
1207
+
1208
+ function kgvid_width_callback() {
1209
+ $options = get_option('kgvid_video_embed_options');
1210
+ echo "<input id='width' name='kgvid_video_embed_options[width]' size='5' type='text' value='".$options['width']."' />";
1211
+ }
1212
+
1213
+ function kgvid_height_callback() {
1214
+ $options = get_option('kgvid_video_embed_options');
1215
+ echo "<input id='height' name='kgvid_video_embed_options[height]' size='5' type='text' value='".$options['height']."' />";
1216
+ }
1217
+
1218
+ function kgvid_gallery_width_callback() {
1219
+ $options = get_option('kgvid_video_embed_options');
1220
+ echo "<input id='width' name='kgvid_video_embed_options[gallery_width]' size='5' type='text' value='".$options['gallery_width']."' /> ";
1221
+ }
1222
+
1223
+ function kgvid_gallery_height_callback() {
1224
+ $options = get_option('kgvid_video_embed_options');
1225
+ echo "<input id='width' name='kgvid_video_embed_options[gallery_height]' size='5' type='text' value='".$options['gallery_height']."' />";
1226
+ }
1227
+
1228
+ function kgvid_gallery_thumb_callback() {
1229
+ $options = get_option('kgvid_video_embed_options');
1230
+ echo "<input id='width' name='kgvid_video_embed_options[gallery_thumb]' size='5' type='text' value='".$options['gallery_thumb']."' />";
1231
+ }
1232
+
1233
+ function kgvid_controlbar_style_callback() {
1234
+ $options = get_option('kgvid_video_embed_options');
1235
+ $items = array("docked", "floating", "none");
1236
+ echo "<select id='controlbar_style' name='kgvid_video_embed_options[controlbar_style]'>";
1237
+ foreach($items as $item) {
1238
+ $selected = ($options['controlbar_style']==$item) ? 'selected="selected"' : '';
1239
+ echo "<option value='$item' $selected>$item</option>";
1240
+ }
1241
+ echo "</select> HTML5 video players only respond to the \"none\" option.";
1242
+ }
1243
+
1244
+ function kgvid_autoplay_callback() {
1245
+ $options = get_option('kgvid_video_embed_options');
1246
+ echo "<input ".checked( $options['autoplay'], "on", false )." id='autoplay' name='kgvid_video_embed_options[autoplay]' type='checkbox' /> <label for='autoplay'>Play automatically when page loads.</label>";
1247
+ }
1248
+
1249
+ function kgvid_loop_callback() {
1250
+ $options = get_option('kgvid_video_embed_options');
1251
+ echo "<input ".checked( $options['loop'], "on", false )." id='loop' name='kgvid_video_embed_options[loop]' type='checkbox' /> <label for='loop'>Loop to beginning when video ends.</label>";
1252
+ }
1253
+
1254
+ function kgvid_js_skin_callback() {
1255
+ $options = get_option('kgvid_video_embed_options');
1256
+ echo "<input id='skin' name='kgvid_video_embed_options[js_skin]' size='60' type='text' value='".$options['js_skin']."' /><br /><em><small>Use <code>kg-video-js-skin</code> for a nice, circular play button. Leave blank for the default square play button. <a href='http://videojs.com/docs/skins/'>Or build your own CSS skin.</a></small></em>";
1257
+ }
1258
+
1259
+ function kgvid_endOfVideoOverlay_callback() {
1260
+ $options = get_option('kgvid_video_embed_options');
1261
+ echo "<input ".checked( $options['endOfVideoOverlaySame'], "true", false )." id='endOfVideoOverlaySame' name='kgvid_video_embed_options[endOfVideoOverlaySame]' type='checkbox' onclick='if (this.checked == true) { document.getElementById(\"endOfVideoOverlay\").disabled=true; } else { document.getElementById(\"endOfVideoOverlay\").disabled=false; }'/> <label for='endOfVideoOverlaySame'>Display poster image again when video ends.</label><br />";
1262
+ echo "<input id='endOfVideoOverlay' name='kgvid_video_embed_options[endOfVideoOverlay]' size='60' ".disabled( $options['endOfVideoOverlaySame'], "true", false )." type='text' value='".$options['endOfVideoOverlay']."' /> Display alternate image when video ends.<br /><small><em>Leave blank to display the first frame of the video when video ends.</em></small>";
1263
+ }
1264
+
1265
+ function kgvid_bgcolor_callback() {
1266
+ $options = get_option('kgvid_video_embed_options');
1267
+ echo "<input id='bgcolor' name='kgvid_video_embed_options[bgcolor]' size='8' type='text' value='".$options['bgcolor']."' /> #rrggbb";
1268
+ }
1269
+
1270
+ function kgvid_configuration_callback() {
1271
+ $options = get_option('kgvid_video_embed_options');
1272
+ echo "<input id='configuration' name='kgvid_video_embed_options[configuration]' size='60' type='text' value='".$options['configuration']."' />";
1273
+ }
1274
+
1275
+ function kgvid_skin_callback() {
1276
+ $options = get_option('kgvid_video_embed_options');
1277
+ echo "<input id='skin' name='kgvid_video_embed_options[skin]' size='60' type='text' value='".$options['skin']."' /><br /><em><small>Use <code>".plugins_url("", __FILE__)."/flash/skin/kgvid_skin.xml</code> for a modern, circular play button.<br /> Leave blank for the older style square play button.</small></em>";
1278
+ }
1279
+
1280
+ function kgvid_stream_type_callback() {
1281
+ $options = get_option('kgvid_video_embed_options');
1282
+ $items = array("liveOrRecorded", "live", "recorded", "dvr");
1283
+ echo "<select id='stream_type' name='kgvid_video_embed_options[stream_type]'>";
1284
+ foreach($items as $item) {
1285
+ $selected = ($options['stream_type']==$item) ? 'selected="selected"' : '';
1286
+ echo "<option value='$item' $selected>$item</option>";
1287
+ }
1288
+ echo "</select>";
1289
+ }
1290
+
1291
+ function kgvid_scale_mode_callback() {
1292
+ $options = get_option('kgvid_video_embed_options');
1293
+ $items = array("letterbox", "none", "stretch", "zoom");
1294
+ echo "<select id='scale_mode' name='kgvid_video_embed_options[scale_mode]'>";
1295
+ foreach($items as $item) {
1296
+ $selected = ($options['scale_mode']==$item) ? 'selected="selected"' : '';
1297
+ echo "<option value='$item' $selected>$item</option>";
1298
+ }
1299
+ echo "</select>";
1300
+ }
1301
+
1302
+ function kgvid_autohide_callback() {
1303
+ $options = get_option('kgvid_video_embed_options');
1304
+ echo "<input ".checked( $options['autohide'], "true", false )." id='autohide' name='kgvid_video_embed_options[autohide]' type='checkbox' /> <label for='autohide'>Autohide controlbar.</label>";
1305
+ }
1306
+
1307
+ function kgvid_playbutton_callback() {
1308
+ $options = get_option('kgvid_video_embed_options');
1309
+ echo "<input ".checked( $options['playbutton'], "true", false )." id='playbutton' name='kgvid_video_embed_options[playbutton]' type='checkbox' /> <label for='playbutton'>Overlay play button on poster frame.</label>";
1310
+ }
1311
+ //end of settings page callback functions
1312
+
1313
+ /**
1314
+ * Adding our custom fields to the $form_fields array
1315
+ *
1316
+ * @param array $form_fields
1317
+ * @param object $post
1318
+ * @return array
1319
+ */
1320
+ function kgvid_image_attachment_fields_to_edit($form_fields, $post) {
1321
+
1322
+ $options = get_option('kgvid_video_embed_options');
1323
+
1324
+ if( substr($post->post_mime_type, 0, 5) == 'video' ){
1325
+
1326
+ //$form_fields["kgflashmediaplayer-security"]["input"] = "hidden";
1327
+ //$form_fields["kgflashmediaplayer-security"]["value"] = wp_create_nonce('video-embed-thumbnail-generator-nonce');
1328
+
1329
+ $movieurl = wp_get_attachment_url($post->ID);
1330
+ $form_fields["kgflashmediaplayer-url"]["input"] = "hidden";
1331
+ $form_fields["kgflashmediaplayer-url"]["value"] = $movieurl;
1332
+
1333
+ $maxwidth = $options['width'];
1334
+ $widthset = get_post_meta($post->ID, "_kgflashmediaplayer-width", true);
1335
+ if ($widthset == "") { $widthset = $maxwidth; }
1336
+
1337
+ $form_fields["kgflashmediaplayer-maxwidth"]["input"] = "hidden";
1338
+ $form_fields["kgflashmediaplayer-maxwidth"]["value"] = $maxwidth;
1339
+
1340
+ $maxheight = $options['height'];
1341
+ $heightset = get_post_meta($post->ID, "_kgflashmediaplayer-height", true);
1342
+ if ($heightset == "") { $heightset = $maxheight; }
1343
 
1344
+ $form_fields["kgflashmediaplayer-maxheight"]["input"] = "hidden";
1345
+ $form_fields["kgflashmediaplayer-maxheight"]["value"] = $maxheight;
1346
+
1347
+ $form_fields["kgflashmediaplayer-aspect"]["input"] = "hidden";
1348
+ $form_fields["kgflashmediaplayer-aspect"]["value"] = $heightset/$widthset;
1349
+
1350
+ $embedset = get_post_meta($post->ID, "_kgflashmediaplayer-embed", true);
1351
+ if ($embedset == "") { $embedset = "Single Video"; }
1352
+
1353
+ $thumbnail_url = get_post_meta($post->ID, "_kgflashmediaplayer-poster", true);
1354
 
1355
  $uploads = wp_upload_dir();
1356
  $url_parts = parse_url($uploads['baseurl']);
1361
  $originalpath = $home_path."public_html".$moviefiledirectory."/".$moviefilebasename;
1362
  if ( !file_exists($originalpath) ) { $thumbnail_url = ""; }
1363
  }
1364
+ else { if ( !kgvid_url_exists($thumbnail_url) ) { $thumbnail_url = ""; } }
1365
 
1366
  $thumbnail_html = "";
1367
+ if ($thumbnail_url != "" ) {
1368
+ $thumbnail_html = '<div style="border-style:solid; border-color:#ccc; border-width:3px; width:200px; text-align:center; margin:10px;"><img width="200" src="'.$thumbnail_url.'?'.rand().'"></div>';
1369
  }
1370
+
1371
+ $numberofthumbs_value = get_post_meta($post->ID, "_kgflashmediaplayer-numberofthumbs", true);
1372
  if (get_post_meta($post->ID, "_kgflashmediaplayer-thumbtime", true) != "") { $numberofthumbs_value = "1"; }
1373
+ if ( empty($numberofthumbs_value) ) { $numberofthumbs_value = $options['generate_thumbs']; }
 
 
1374
 
1375
+ if ( !isset($options['ffmpeg_exists']) || $options['ffmpeg_exists'] == "notchecked" ) {
1376
+ kgvid_check_ffmpeg_exists($options, true);
1377
+ }
1378
+
1379
+ $forcefirstchecked = get_post_meta($post->ID, "_kgflashmediaplayer-forcefirst", true);
1380
 
1381
+ if ( $options['ffmpeg_exists'] == "notinstalled" ) { $ffmpeg_disabled_text = 'disabled="disabled" title="'.strtoupper($options['video_app']).' not found at '.$options['app_path'].'"'; }
1382
  else { $ffmpeg_disabled_text = ""; }
1383
+
1384
+ $nonce = wp_create_nonce('video-embed-thumbnail-generator-nonce');
1385
+
1386
+ if ( $options['embed_method'] == "Video.js" ) {
1387
+
1388
+ $starts = intval(get_post_meta($post->ID, "_kgflashmediaplayer-starts", true));
1389
+ $completeviews = intval(get_post_meta($post->ID, "_kgflashmediaplayer-completeviews", true));
1390
+
1391
+ $form_fields["views"]["label"] = __("Video Stats");
1392
+ $form_fields["views"]["input"] = "html";
1393
+ $form_fields["views"]["html"] = $starts." Starts, ".$completeviews." Complete Views";
1394
+
1395
+ }
1396
 
1397
  $form_fields["generator"]["label"] = __("Thumbnails");
1398
+ $form_fields["generator"]["input"] = "html";
1399
+ $form_fields["generator"]["html"] = '<input type="hidden" name="attachments[kgflashmediaplayer-security]" id="attachments-kgflashmediaplayer-security" value="'.$nonce.'" /><div id="attachments-'.$post->ID.'-thumbnailplaceholder">'. $thumbnail_html .'</div>
1400
+ <input id="attachments-'. $post->ID .'-numberofthumbs" name="attachments['.$post->ID.'][kgflashmediaplayer-numberofthumbs]" type="text" value="'.$numberofthumbs_value.'" maxlength="2" style="width:35px;text-align:center;" onchange="kgvid_disable_thumb_buttons(\''.$post->ID.'\', \'onchange\');document.getElementById(\'attachments-'.$post->ID.'-thumbtime\').value =\'\';" '.$ffmpeg_disabled_text.'/>
1401
+ <input type="button" id="attachments-'. $post->ID .'-thumbgenerate" class="button-secondary" value="Generate" name="thumbgenerate" onclick="kgvid_generate_thumb('. $post->ID .', \'generate\');" '.$ffmpeg_disabled_text.'/>
1402
+ <input type="button" id="attachments-'. $post->ID .'-thumbrandomize" class="button-secondary" value="Randomize" name="thumbrandomize" onclick="kgvid_generate_thumb('. $post->ID .', \'random\');" '.$ffmpeg_disabled_text.'/> <br />
1403
+ <input type="checkbox" id="attachments-'. $post->ID .'-firstframe" name="attachments['.$post->ID.'][kgflashmediaplayer-forcefirst]" onchange="document.getElementById(\'attachments-'.$post->ID.'-thumbtime\').value =\'\';" value="checked" '.$forcefirstchecked.' '.$ffmpeg_disabled_text.'/>
1404
+ <label for="attachments-'. $post->ID .'-firstframe">Force 1st Frame Thumbnail</label>';
1405
+
1406
+ $form_fields["thumbtime"]["label"] = __("Thumbnail Time");
1407
+ $form_fields["thumbtime"]["value"] = get_post_meta($post->ID, "_kgflashmediaplayer-thumbtime", true);
1408
+ $form_fields["thumbtime"]["helps"] = "<small>Optional: generates a single thumbnail at the specified time (hh:mm:ss, mm:ss, or s).</small>";
1409
+
1410
+ $form_fields["kgflashmediaplayer-poster"]["label"] = __("Thumbnail URL");
1411
+ $form_fields["kgflashmediaplayer-poster"]["value"] = get_post_meta($post->ID, "_kgflashmediaplayer-poster", true);
1412
+ $form_fields["kgflashmediaplayer-poster"]["helps"] = "<small>Leave blank to use <a href='options-general.php?page=video-embed-thumbnail-generator/video-embed-thumbnail-generator.php' target='_blank'>default thumbnail</a>.</small>";
1413
+
1414
+ $lockaspectchecked = get_post_meta($post->ID, "_kgflashmediaplayer-lockaspect", true);
1415
+ if ( $lockaspectchecked == "notchecked" ) { $lockaspectchecked = ""; }
1416
+ else { $lockaspectchecked = "checked"; }
1417
+
1418
+ $form_fields["kgflashmediaplayer-dimensions"]["label"] = __("Video Embed Dimensions");
1419
+ $form_fields["kgflashmediaplayer-dimensions"]["input"] = "html";
1420
+ $form_fields["kgflashmediaplayer-dimensions"]["html"] = 'Width: <input name="attachments['. $post->ID .'][kgflashmediaplayer-width]" id="attachments-'. $post->ID .'-kgflashmediaplayer-width" type="text" value="'.$widthset.'" style="width:50px;" onchange="kgvid_set_dimension('.$post->ID.', \'height\', this.value);" onkeyup="kgvid_set_dimension('.$post->ID.', \'height\', this.value);"> Height:
1421
+ <input name="attachments['. $post->ID .'][kgflashmediaplayer-height]" id="attachments-'. $post->ID .'-kgflashmediaplayer-height" type="text" value="'.$heightset.'" style="width:50px;" onchange="kgvid_set_dimension('.$post->ID.', \'width\', this.value);" onkeyup="kgvid_set_dimension('.$post->ID.', \'width\', this.value);"> <br />
1422
+ <input type="checkbox" name="attachments['. $post->ID .'][kgflashmediaplayer-lockaspect]" id="attachments-'. $post->ID .'-kgflashmediaplayer-lockaspect" onclick="kgvid_set_aspect('.$post->ID.', this.checked);" value="checked" '.$lockaspectchecked.'>
1423
+ <label for="attachments-'. $post->ID .'-kgflashmediaplayer-lockaspect"><small>Lock to Aspect Ratio</small></label>';
1424
+ $form_fields["kgflashmediaplayer-dimensions"]["helps"] = "<small>Leave blank to use <a href='options-general.php?page=video-embed-thumbnail-generator/video-embed-thumbnail-generator.php' target='_blank'>default dimensions</a>.</small>";
1425
+
1426
+ $checkboxes = kgvid_generate_encode_checkboxes($movieurl, $post->ID, "attachment");
1427
+
1428
+ $form_fields["kgflashmediaplayer-encode"]["label"] = __("Additional Formats");
1429
+ $form_fields["kgflashmediaplayer-encode"]["input"] = "html";
1430
+ $form_fields["kgflashmediaplayer-encode"]["html"] = $checkboxes;
1431
+
1432
+ $showtitlechecked = get_post_meta($post->ID, "_kgflashmediaplayer-showtitle", true);
1433
+ if ( $showtitlechecked == "notchecked" ) { $showtitlechecked = ""; }
1434
+ $downloadlinkchecked = get_post_meta($post->ID, "_kgflashmediaplayer-downloadlink", true);
1435
+ if ( $downloadlinkchecked == "notchecked" ) { $downloadlinkchecked = ""; }
1436
+ $embed_option = get_post_meta($post->ID, "_kgflashmediaplayer-embed", true);
1437
+
1438
+ $items = array("Single Video", "Video Gallery", "WordPress Default");
1439
+ $shortcode_select = '<select name="attachments['.$post->ID.'][kgflashmediaplayer-embed]" id="attachments['.$post->ID.'][kgflashmediaplayer-embed]">';
1440
+ foreach($items as $item) {
1441
+ $selected = ($embed_option==$item) ? 'selected="selected"' : '';
1442
+ $shortcode_select .= "<option value='$item' $selected>$item</option>";
1443
+ }
1444
+ $shortcode_select .= "</select>";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1445
 
1446
+ $form_fields["kgflashmediaplayer-options"]["label"] = __("Video Embed Options");
1447
+ $form_fields["kgflashmediaplayer-options"]["input"] = "html";
1448
+ $form_fields["kgflashmediaplayer-options"]["html"] = '<input type="checkbox" name="attachments['.$post->ID.'][kgflashmediaplayer-showtitle]" id="attachments-'.$post->ID.'-kgflashmediaplayer-showtitle" value="checked" '.$showtitlechecked.'>
1449
+ <label for="attachments-'.$post->ID.'-kgflashmediaplayer-showtitle">Include Title Above Video</label><br />
1450
+
1451
+ <input type="checkbox" name="attachments['.$post->ID.'][kgflashmediaplayer-downloadlink]" id="attachments-'.$post->ID.'-kgflashmediaplayer-downloadlink" value="checked" '.$downloadlinkchecked.'>
1452
+ <label for="attachments-'.$post->ID.'-kgflashmediaplayer-downloadlink">Generate Download Link Below Video<em><small>(Makes it easier for users to download video file)</em></small></label><br />
1453
+ '.$shortcode_select.'
1454
+ <label for="attachments-'.$post->ID.'-kgflashmediaplayer-embed">Insert</small></em></label><script type="text/javascript">window.onload=kgvid_hide_standard_wordpress_display_settings('.$post->ID.');</script>';
1455
+
1456
+ if ( get_post_meta($post->ID, "_kgflashmediaplayer-embed", true) == "Video Gallery" ) {
1457
+
1458
+ $gallery_thumb_width = get_post_meta($post->ID, "_kgflashmediaplayer-gallery_thumb_width", true);
1459
+ if ( empty($gallery_thumb_width) ) { $gallery_thumb_width = $options['gallery_thumb']; }
1460
+
1461
+ $gallery_exclude = get_post_meta($post->ID, "_kgflashmediaplayer-gallery_exclude", true);
1462
+ $gallery_include = get_post_meta($post->ID, "_kgflashmediaplayer-gallery_include", true);
1463
+ $gallery_orderby = get_post_meta($post->ID, "_kgflashmediaplayer-gallery_orderby", true);
1464
+ $gallery_order = get_post_meta($post->ID, "_kgflashmediaplayer-gallery_order", true);
1465
+
1466
+ $gallery_id = get_post_meta($post->ID, "_kgflashmediaplayer-gallery_id", true);
1467
+ if ( empty($gallery_id) ) { $gallery_id = $post->post_parent; }
1468
+
1469
+ $items = array("menu_order", "title", "post_date", "rand", "ID");
1470
+ $gallery_orderby_select = '<select name="attachments['.$post->ID.'][kgflashmediaplayer-gallery_orderby]" id="attachments-'.$post->ID.'-kgflashmediaplayer-gallery_orderby">';
1471
+ foreach($items as $item) {
1472
+ $selected = ($gallery_orderby==$item) ? 'selected="selected"' : '';
1473
+ $gallery_orderby_select .= "<option value='$item' $selected>$item</option>";
1474
+ }
1475
+ $gallery_orderby_select .= "</select>";
1476
+
1477
+ $items = array("ASC", "DESC");
1478
+ $gallery_order_select = '<select name="attachments['.$post->ID.'][kgflashmediaplayer-gallery_order]" id="attachments-'.$post->ID.'-kgflashmediaplayer-gallery_order">';
1479
+ foreach($items as $item) {
1480
+ $selected = ($gallery_order==$item) ? 'selected="selected"' : '';
1481
+ $gallery_order_select .= "<option value='$item' $selected>$item</option>";
1482
+ }
1483
+ $gallery_order_select .= "</select>";
1484
+
1485
+ $form_fields["kgflashmediaplayer-gallery"]["label"] = __("Gallery Settings (all optional)");
1486
+ $form_fields["kgflashmediaplayer-gallery"]["input"] = "html";
1487
+ $form_fields["kgflashmediaplayer-gallery"]["html"] = '<input name="attachments['.$post->ID.'][kgflashmediaplayer-gallery_thumb_width]" id="attachments-'.$post->ID.'-kgflashmediaplayer-gallery_thumb_width" type ="text" value="'.$gallery_thumb_width.'" style="width:50px;"> <label for="attachments-'.$post->ID.'-kgflashmediaplayer-gallery_thumb_width">Thumbnail Width</label><br />
1488
+ '.$gallery_orderby_select.' Order By<br />
1489
+ '.$gallery_order_select.' Sort Order<br />
1490
+ <input name="attachments['.$post->ID.'][kgflashmediaplayer-gallery_exclude]" id="attachments-'.$post->ID.'-kgflashmediaplayer-gallery_exclude" type ="text" value="'.$gallery_exclude.'" style="width:50px;"> <label for="attachments-'.$post->ID.'-kgflashmediaplayer-gallery_exclude">Exclude</label><br />
1491
+ <input name="attachments['.$post->ID.'][kgflashmediaplayer-gallery_include]" id="attachments-'.$post->ID.'-kgflashmediaplayer-gallery_include" type ="text" value="'.$gallery_include.'" style="width:50px;"> <label for="attachments-'.$post->ID.'-kgflashmediaplayer-gallery_include">Include</label><br />
1492
+ <input name="attachments['.$post->ID.'][kgflashmediaplayer-gallery_id]" id="attachments-'.$post->ID.'-kgflashmediaplayer-gallery_id" type ="text" value="'.$gallery_id.'" style="width:50px;"> <label for="attachments-'.$post->ID.'-kgflashmediaplayer-gallery_id">Post ID</label>
1493
+ ';
1494
+
1495
+ }
1496
+
1497
+ //$form_fields["kgflashmediaplayer-attachment"]["label"] = __("All Meta");
1498
+ //$form_fields["kgflashmediaplayer-attachment"]["value"] = get_post_meta($post->ID, "_kgflashmediaplayer-attachment", true);
1499
+
1500
+ } //only add fields if attachment is video
1501
+ return $form_fields;
1502
+ }
1503
+ // attach our function to the correct hook
1504
+ add_filter("attachment_fields_to_edit", "kgvid_image_attachment_fields_to_edit", null, 2);
1505
+
1506
+ function kgvid_save_thumb($post_id, $post_name, $thumb_url) {
1507
+
1508
+ $uploads = wp_upload_dir();
1509
+
1510
+ $posterfile = pathinfo($thumb_url, PATHINFO_BASENAME);
1511
  $tmp_posterpath = $uploads['path'].'/thumb_tmp/'.$posterfile;
1512
  if ( !is_file($uploads['path'].'/'.$posterfile) ) {
1513
  if ( is_file($tmp_posterpath) ) {
1517
  unlink($thumbfilename);
1518
  }
1519
  }
1520
+ if ( kgvid_is_empty_dir($uploads["path"].'/thumb_tmp') ) { kgvid_rrmdir($uploads["path"].'/thumb_tmp'); }
1521
+ }
1522
+
1523
+ //insert the $thumb_url into the media library if it does not already exist
1524
+
1525
+ global $wpdb;
1526
+ $query = "SELECT ID FROM {$wpdb->posts} WHERE guid='".$thumb_url."'"; //check for existing entry in the db
1527
+ $thumb_id = $wpdb->get_var($query);
1528
+
1529
+ if ( !$thumb_id ) {
1530
+
1531
+ $desc = $post_name . ' thumbnail';
1532
+
1533
+ //is image in uploads directory?
1534
+ $upload_dir = wp_upload_dir();
1535
+
1536
+ if ( FALSE !== strpos( $thumb_url, $upload_dir['baseurl'] ) ) {
1537
+ $wp_filetype = wp_check_filetype(basename($thumb_url), null );
1538
+ $filename = preg_replace('/\.[^.]+$/', '', basename($thumb_url));
1539
+
1540
+ $attachment = array(
1541
+ 'guid' => $thumb_url,
1542
+ 'post_mime_type' => $wp_filetype['type'],
1543
+ 'post_title' => $desc,
1544
+ 'post_content' => '',
1545
+ 'post_status' => 'inherit'
1546
+ );
1547
+ $thumb_id = wp_insert_attachment( $attachment, $uploads['path'].'/'.$posterfile, $post_id );
1548
+ // you must first include the image.php file
1549
+ // for the function wp_generate_attachment_metadata() to work
1550
+ require_once(ABSPATH . 'wp-admin/includes/image.php');
1551
+ $attach_data = wp_generate_attachment_metadata( $thumb_id, $uploads['path'].'/'.$posterfile );
1552
+ wp_update_attachment_metadata( $thumb_id, $attach_data );
1553
+ } else { //not in uploads so we'll have to sideload it
1554
+ $tmp = download_url( $thumb_url );
1555
+
1556
+ // Set variables for storage
1557
+ // fix file filename for query strings
1558
+ preg_match('/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $thumb_url, $matches);
1559
+ $file_array['name'] = basename($matches[0]);
1560
+ $file_array['tmp_name'] = $tmp;
1561
+
1562
+ // If error storing temporarily, unlink
1563
+ if ( is_wp_error( $tmp ) ) {
1564
+ @unlink($file_array['tmp_name']);
1565
+ $file_array['tmp_name'] = '';
1566
+ }
1567
+
1568
+ // do the validation and storage stuff
1569
+ $thumb_id = media_handle_sideload( $file_array, $post_id, $desc );
1570
+
1571
+ // If error storing permanently, unlink
1572
+ if ( is_wp_error($thumb_id) ) {
1573
+ @unlink($file_array['tmp_name']);
1574
+ return $thumb_id;
1575
+ }
1576
+
1577
+ if ( $local_src = wp_get_attachment_url( $thumb_id ) ) {
1578
+ update_post_meta($post_id, '_kgflashmediaplayer-poster', $local_src);
1579
+ }
1580
+
1581
+ } //end sideload
1582
+
1583
+ } //end get_attachment_id_from_src
1584
+
1585
+ if(!is_wp_error($thumb_id)) {
1586
+ $thumb_id = intval( $thumb_id );
1587
+ update_post_meta($post_id, '_kgflashmediaplayer-poster-id', $thumb_id);
1588
  }
1589
+
1590
+ }
1591
+
1592
+ /**
1593
+ * @param array $post
1594
+ * @param array $attachment
1595
+ * @return array
1596
+ */
1597
+ function kgvid_video_attachment_fields_to_save($post, $attachment) {
1598
+ // $attachment part of the form $_POST ($_POST[attachments][postID])
1599
+ // $post attachments wp post array - will be saved after returned
1600
+ // $post['post_type'] == 'attachment'
1601
+
1602
+ if( isset($attachment['kgflashmediaplayer-poster']) ) {
1603
+
1604
+ $thumb_url = $attachment['kgflashmediaplayer-poster'];
1605
+ kgvid_save_thumb($post['ID'], $post['post_name'], $thumb_url);
1606
+ update_post_meta($post['ID'], '_kgflashmediaplayer-poster', $thumb_url);
1607
+
1608
  }
1609
+ if( isset($attachment['kgflashmediaplayer-numberofthumbs']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-numberofthumbs', $attachment['kgflashmediaplayer-numberofthumbs']); }
1610
+ if( isset($attachment['kgflashmediaplayer-forcefirst']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-forcefirst', $attachment['kgflashmediaplayer-forcefirst']); }
1611
+ else { update_post_meta($post['ID'], '_kgflashmediaplayer-forcefirst', ""); }
1612
  if( isset($attachment['thumbtime']) ) {update_post_meta($post['ID'], '_kgflashmediaplayer-thumbtime', $attachment['thumbtime']); }
1613
+ if( isset($attachment['kgflashmediaplayer-width']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-width', $attachment['kgflashmediaplayer-width']); }
1614
+ if( isset($attachment['kgflashmediaplayer-height']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-height', $attachment['kgflashmediaplayer-height']); }
1615
+ /*if( isset($attachment['kgflashmediaplayer-actualwidth']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-actualwidth', $attachment['kgflashmediaplayer-actualwidth']); }
1616
+ if( isset($attachment['kgflashmediaplayer-actualheight']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-actualheight', $attachment['kgflashmediaplayer-actualheight']); } */
1617
  if( isset($attachment['kgflashmediaplayer-aspect']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-aspect', $attachment['kgflashmediaplayer-aspect']); }
1618
+ if( isset($attachment['kgflashmediaplayer-lockaspect']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-lockaspect', $attachment['kgflashmediaplayer-lockaspect']); }
1619
+ else { update_post_meta($post['ID'], '_kgflashmediaplayer-lockaspect', "notchecked"); }
1620
+
1621
+ $video_formats = kgvid_video_formats();
1622
+ foreach ( $video_formats as $format => $format_stats ) {
1623
+ if( isset($attachment['kgflashmediaplayer-encode'.$format]) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-encode'.$format, "on"); }
1624
+ else { update_post_meta($post['ID'], '_kgflashmediaplayer-encode'.$format, "notchecked"); }
1625
+ }
1626
+
1627
+ if( isset($attachment['kgflashmediaplayer-showtitle']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-showtitle', $attachment['kgflashmediaplayer-showtitle']); }
1628
+ else { update_post_meta($post['ID'], '_kgflashmediaplayer-showtitle', "notchecked"); }
1629
+
1630
+ if( isset($attachment['kgflashmediaplayer-downloadlink']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-downloadlink', $attachment['kgflashmediaplayer-downloadlink']); }
1631
+ else { update_post_meta($post['ID'], '_kgflashmediaplayer-downloadlink', "notchecked"); }
1632
+
1633
+ if( isset($attachment['kgflashmediaplayer-embed']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-embed', $attachment['kgflashmediaplayer-embed']); }
1634
+ if( isset($attachment['kgflashmediaplayer-gallery_thumb_width']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-gallery_thumb_width', $attachment['kgflashmediaplayer-gallery_thumb_width']); }
1635
+ if( isset($attachment['kgflashmediaplayer-gallery_exclude']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-gallery_exclude', $attachment['kgflashmediaplayer-gallery_exclude']); }
1636
+ if( isset($attachment['kgflashmediaplayer-gallery_include']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-gallery_include', $attachment['kgflashmediaplayer-gallery_include']); }
1637
+ if( isset($attachment['kgflashmediaplayer-gallery_orderby']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-gallery_orderby', $attachment['kgflashmediaplayer-gallery_orderby']); }
1638
+ if( isset($attachment['kgflashmediaplayer-gallery_order']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-gallery_order', $attachment['kgflashmediaplayer-gallery_order']); }
1639
+ if( isset($attachment['kgflashmediaplayer-gallery_id']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-gallery_id', $attachment['kgflashmediaplayer-gallery_id']); }
1640
+
1641
+ //if( isset($attachment['kgflashmediaplayer-altembed']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-altembed', $attachment['kgflashmediaplayer-altembed']); }
1642
  /* if( isset($attachment['kgflashmediaplayer-encoded']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-encoded', $attachment['kgflashmediaplayer-encoded']); } */
1643
 
1644
  //$attachment_printr = print_r($attachment, true);
1646
 
1647
  return $post;
1648
  }
1649
+ add_filter("attachment_fields_to_save", "kgvid_video_attachment_fields_to_save", null, 2);
1650
 
1651
  class kgInsertMedia {
1652
  //class constructor
1656
  //function that does the modifying
1657
  function kgmodifyMediaInsert($html, $attachment_id, $attachment) {
1658
 
1659
+ $options = get_option('kgvid_video_embed_options');
1660
  $output = $html;
1661
 
1662
  $attachment['embed'] = get_post_meta($attachment_id, "_kgflashmediaplayer-embed", true);
1663
 
1664
+ if ( $attachment['embed'] == "Single Video" || $attachment['embed'] == "checked" || !is_numeric($attachment_id) ) {
1665
  $output = "";
1666
+ $attachment['url'] = wp_get_attachment_url($attachment_id);
 
 
1667
  $attachment['title'] = get_the_title($attachment_id);
1668
  $attachment['poster'] = get_post_meta($attachment_id, "_kgflashmediaplayer-poster", true);
1669
  $attachment['width'] = get_post_meta($attachment_id, "_kgflashmediaplayer-width", true);
1671
  $attachment['downloadlink'] = get_post_meta($attachment_id, "_kgflashmediaplayer-download", true);
1672
  $attachment['showtitle'] = get_post_meta($attachment_id, "_kgflashmediaplayer-showtitle", true);
1673
  if ($attachment['showtitle'] =="checked") {
1674
+ $titlecode = html_entity_decode(stripslashes($options['titlecode']));
1675
  if ( substr($titlecode, 0, 1) != '<' ) { $titlecode = '<'.$titlecode; }
1676
  if ( substr($titlecode, -1, 1) != '>' ) { $titlecode .= '>'; }
1677
  $endtitlecode = str_replace("<", "</", $titlecode);
1679
  if ( substr($endtitlecode_array[0], -1) != ">" ) { $endtitlecode = $endtitlecode_array[0].">"; }
1680
  $output .= $titlecode.$attachment["title"].$endtitlecode.'<br />';
1681
  }
1682
+ $output .= '[KGVID';
1683
  if ($attachment['poster'] !="") { $output .= ' poster="'.$attachment["poster"].'"'; }
1684
  if ($attachment['width'] !="") { $output .= ' width="'.$attachment["width"].'"'; }
1685
  if ($attachment['height'] !="") { $output .= ' height="'.$attachment["height"].'"'; }
1686
+ $output .= ']'.$attachment["url"].'[/KGVID]<br />';
1687
  if ($attachment['downloadlink'] == "checked") { $output .= '<a href="'.$attachment["url"].'">Right-click or ctrl-click this link to download.</a><br />'; }
1688
+ } //if embed code is enabled
1689
+
1690
+ if ($attachment['embed'] == "Video Gallery" ) {
1691
+
1692
+ $attachment['gallery_thumb'] = get_post_meta($attachment_id, "_kgflashmediaplayer-gallery_thumb_width", true);
1693
+ $attachment['gallery_exclude'] = get_post_meta($attachment_id, "_kgflashmediaplayer-gallery_exclude", true);
1694
+ $attachment['gallery_include'] = get_post_meta($attachment_id, "_kgflashmediaplayer-gallery_include", true);
1695
+ $attachment['gallery_orderby'] = get_post_meta($attachment_id, "_kgflashmediaplayer-gallery_orderby", true);
1696
+ $attachment['gallery_order'] = get_post_meta($attachment_id, "_kgflashmediaplayer-gallery_order", true);
1697
+ $attachment['gallery_id'] = get_post_meta($attachment_id, "_kgflashmediaplayer-gallery_id", true);
1698
+ $post = get_post($attachment_id);
1699
+ $parent_id = $post->post_parent;
1700
+
1701
+ $output = "";
1702
+ $output .= '[KGVID gallery="true"';
1703
+ if ($attachment['gallery_thumb'] != $options['gallery_thumb'] ) { $output .= ' gallery_thumb="'.$attachment["gallery_thumb"].'"'; }
1704
+ if ($attachment['gallery_exclude'] != "" ) { $output .= ' gallery_exclude="'.$attachment["gallery_exclude"].'"'; }
1705
+ if ($attachment['gallery_include'] != "" ) { $output .= ' gallery_include="'.$attachment["gallery_include"].'"'; }
1706
+ if ($attachment['gallery_orderby'] != "menu_order" ) { $output .= ' gallery_orderby="'.$attachment["gallery_orderby"].'"'; }
1707
+ if ($attachment['gallery_order'] != "ASC" ) { $output .= ' gallery_order="'.$attachment["gallery_order"].'"'; }
1708
+ if ($attachment['gallery_id'] != $parent_id ) { $output .= ' gallery_id="'.$attachment["gallery_id"].'"'; }
1709
+ $output .= '][/KGVID]';
1710
+ }
1711
+
1712
  return $output;
1713
  }
1714
  }
1715
  //instantiate the class
1716
  $kgIM = new kgInsertMedia();
1717
 
1718
+ function kgvid_embedurl_menu($tabs) {
1719
+ $newtab = array('embedurl' => __('Embed Video from URL', 'kgoutsidevideo'));
1720
+ return array_merge($tabs, $newtab);
 
 
 
 
 
 
 
 
1721
  }
1722
+ add_filter('media_upload_tabs', 'kgvid_embedurl_menu');
1723
 
1724
  function media_embedurl_process() {
1725
 
1726
+ $options = get_option('kgvid_video_embed_options');
 
 
1727
 
1728
+ /* if ( !isset($options['ffmpeg_exists']) || $options['ffmpeg_exists'] == "notchecked" ) {
1729
+ kgvid_check_ffmpeg_exists($options, true);
1730
+ $options = get_option('kgvid_video_embed_options');
1731
+ }
1732
+ if ( $options['ffmpeg_exists'] == "notinstalled" ) { $ffmpeg_disabled_text = 'disabled="disabled" title="'.strtoupper($options['video_app']).' not found at '.$options['app_path'].'"'; }
1733
+ else { $ffmpeg_disabled_text = ""; } */
1734
+
1735
+ $video_formats = kgvid_video_formats();
1736
+ $checkboxes = kgvid_generate_encode_checkboxes("", "singleurl", "attachment");
1737
 
1738
+ $maxheight = $options['height'];
1739
+ $maxwidth = $options['width'];
 
 
 
 
1740
 
1741
  media_upload_header();
1742
  ?>
1743
+ <form class="media-upload-form type-form validate" id="kgvid-form" enctype="multipart/form-data" method="post" action="">
1744
 
1745
  <div id="media-items">
1746
  <div class="media-item media-blank">
1752
  <p class="help"><small>Add an optional header above the video.</small></p></td>
1753
  </tr>
1754
  <tr>
1755
+ <th valign="top" scope="row" class="label"><label for="attachments-singleurl-kgflashmediaplayer-url">Video URL</label></th>
1756
+ <td class="field"><input type="text" id="attachments-singleurl-kgflashmediaplayer-url" name="attachments[singleurl][kgflashmediaplayer-url]" value="" size="50" onchange="kgvid_set_singleurl();"/>
1757
  <p class="help"><small>Specify the URL of the video file.</small></p></td>
1758
  </tr>
1759
  <tr>
1760
  <th valign="top" scope="row" class="label"><span class="alignleft"><label for="numberofthumbs">Thumbnails</label></span></th>
1761
+ <td class="field"><div id="attachments-singleurl-thumbnailplaceholder"></div>
1762
+ <input id="attachments-singleurl-numberofthumbs" type="text" value="<?php echo $options['generate_thumbs']; ?>" maxlength="2" size="4" style="width:35px;text-align:center;" title="Number of Thumbnails" onchange="document.getElementById('attachments-singleurl-thumbtime').value='';" />
1763
+ <input type="button" id="attachments-singleurl-thumbgenerate" class="button-secondary" value="Generate" name="thumbgenerate" onclick="kgvid_generate_thumb('singleurl', 'generate');" disabled title="Please enter a valid video URL" />
1764
+ <input type="button" id="attachments-singleurl-thumbrandomize" class="button-secondary" value="Randomize" name="thumbrandomize" onclick="kgvid_generate_thumb('singleurl', 'random');" disabled title="Please enter a valid video URL" />
1765
+ <input type="checkbox" id="attachments-singleurl-firstframe" onchange="document.getElementById('attachments-singleurl-thumbtime').value ='';" /><label for="attachments-singleurl-firstframe">Force 1st Frame Thumbnail</label></td>
1766
  </tr>
1767
  <tr>
1768
+ <th valign="top" scope="row" class="label"><span class="alignleft"><label for="attachments-singleurl-thumbtime">Thumbnail Time</span></label><br class="clear" /></th>
1769
+ <td class="field"><input type="text" name="attachments[singleurl][thumbtime]" id="attachments-singleurl-thumbtime" value="" size="50" />
1770
  <p class="help"><small>Optional: generates a single thumbnail at the specified time (hh:mm:ss, mm:ss, or s).</small></p></td>
1771
  </tr>
1772
  <tr>
1773
+ <th valign="top" scope="row" class="label"><span class="alignleft"><label for="attachments-singleurl_kgflashmediaplayer_poster">Thumbnail URL</label></span></th>
1774
+ <td class="field"><input type="text" name="attachments[singleurl][kgflashmediaplayer-poster]" id="attachments-singleurl-kgflashmediaplayer-poster" value="" size="50" />
1775
+ <p class="help"><small>Leave blank to use <a href="options-general.php?page=video-embed-thumbnail-generator/video-embed-thumbnail-generator.php" target="_blank">default thumbnail</a>.</small></p></td>
1776
  </tr>
1777
  <tr>
1778
+ <th valign="top" scope="row" class="label"><span class="alignleft"><label for="attachments-singleurl-kgflashmediaplayer-width">Dimensions</label></span></th>
1779
+ <td class="field">Width: <input name="attachments[singleurl][kgflashmediaplayer-width]" type="text" value="" id="attachments-singleurl-kgflashmediaplayer-width" type="text" style="width:50px;" onchange="kgvid_set_dimension('singleurl', 'height', this.value);" onkeyup="kgvid_set_dimension('singleurl', 'height', this.value);"> Height: <input name="attachments[singleurl][kgflashmediaplayer-height]" id="attachments-singleurl-kgflashmediaplayer-height" type="text" value="" style="width:50px;" onchange="kgvid_set_dimension('singleurl', 'width', this.value);" onkeyup="kgvid-set-dimension('singleurl', 'width', this.value);"> <input type="checkbox" name="attachments[singleurl][kgflashmediaplayer-lockaspect]" id="attachments-singleurl-kgflashmediaplayer-lockaspect" onclick="kgvid_set_aspect('singleurl', this.checked);" checked> <label for="attachments-singleurl-kgflashmediaplayer-lockaspect"><small>Lock to Aspect Ratio</small></label>
1780
+ <p class="help"><small>Leave blank to use <a href="options-general.php?page=video-embed-thumbnail-generator/video-embed-thumbnail-generator.php" target="_blank">default dimensions</a>.</small></p></td>
1781
  </tr>
1782
  <tr>
1783
  <th valign="top" scope="row" class="label"><span class="alignleft"><label for="html5">HTML5 & Mobile</span></label></th>
1784
+ <td><?php echo $checkboxes; ?></td>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1785
  </tr>
1786
  <tr>
1787
  <th valign="top" scope="row" class="label"><span class="alignleft"><label>Options</span></label></th>
1790
  <tr class="submit">
1791
  <td></td>
1792
  <td>
1793
+ <input type="button" onclick="kgvid_insert_shortcode();" name="insertonlybutton" id="insertonlybutton" class="button" value="Insert into Post" disabled title="Please enter a valid video URL" />
1794
  </td>
1795
  </tr>
1796
  </tbody></table>
1797
  </div>
1798
  </div>
1799
 
1800
+ <input type='hidden' name='attachments[kgflashmediaplayer-security]' id='attachments-kgflashmediaplayer-security' value='<?php echo wp_create_nonce('video-embed-thumbnail-generator-nonce'); ?>' />
1801
+ <input type='hidden' name='attachments[singleurl][kgflashmediaplayer-maxwidth]' id='attachments-singleurl-kgflashmediaplayer-maxwidth' value='<?php echo($maxwidth); ?>' />
1802
+ <input type='hidden' name='attachments[singleurl][kgflashmediaplayer-maxheight]' id='attachments-singleurl-kgflashmediaplayer-maxheight' value='<?php echo($maxheight); ?>' />
1803
+ <input type='hidden' name='attachments[singleurl][kgflashmediaplayer-aspect]' id='attachments-singleurl-kgflashmediaplayer-aspect' value='<?php echo(round($maxheight/$maxwidth, 3)); ?>' />
1804
+ <input type='hidden' name='attachments[singleurl][kgflashmediaplayer-titlecode]' id='attachments-singleurl-kgflashmediaplayer-titlecode' value='<?php echo $options['titlecode']; ?>' />
1805
+ <input type='hidden' name='attachments[singleurl][kgflashmediaplayer-titlecode]' id='attachments-singleurl-kgflashmediaplayer-titlecode' value='<?php echo $options['titlecode']; ?>' />
1806
+ <input type='hidden' name='attachments[singleurl][kgflashmediaplayer-ffmpegexists]' id='attachments-singleurl-kgflashmediaplayer-ffmpegexists' value='<?php echo $options['ffmpeg_exists']; ?>' />
 
 
 
 
 
 
 
1807
  </form>
1808
 
1809
  <?php
1810
  } //end media_embedurl_process
1811
 
1812
+ function kgvid_embedurl_handle() {
1813
+ return wp_iframe( 'media_embedurl_process' );
1814
  }
1815
+ add_action('media_upload_embedurl', 'kgvid_embedurl_handle');
1816
 
1817
+ function kgvid_parameter_queryvars( $qvars ) { //add kgvid_video_embed variable for passing information using URL queries
1818
+ $qvars[] = 'kgvid_video_embed';
1819
+ return $qvars;
1820
+ }
1821
+ add_filter('query_vars', 'kgvid_parameter_queryvars' );
1822
 
1823
+ function kgvid_video_attachment_template() {
1824
 
1825
  global $post;
1826
+ global $wp_query;
1827
+
1828
+ $options = get_option('kgvid_video_embed_options');
1829
+
1830
+ $kgvid_video_embed = "";
1831
+ if ( isset($wp_query->query_vars['kgvid_video_embed']) ) { $kgvid_video_embed = $wp_query->query_vars['kgvid_video_embed']; }
1832
+
1833
+ if ( ($options['template'] == "on" && is_attachment()) || isset($kgvid_video_embed['gallery']) ) {
1834
+
1835
+ $embed_enabled = get_post_meta($post->ID, "_kgflashmediaplayer-embed", true);
1836
+
1837
+ if ( $embed_enabled != "WordPress Default" || isset($kgvid_video_embed['gallery']) ) {
1838
+
1839
+ remove_action('wp_head', '_admin_bar_bump_cb');
1840
+
1841
+ $poster = get_post_meta($post->ID, "_kgflashmediaplayer-poster", true);
1842
+
1843
+ if (isset($kgvid_video_embed['width'])) { $width = $kgvid_video_embed['width']; }
1844
+ else { $width = get_post_meta($post->ID, "_kgflashmediaplayer-width", true); }
1845
+ if ( !$width ) { $width = get_post_meta($post->ID, "_kgflashmediaplayer-actualwidth", true); }
1846
+ if ( !$width ) { $width = $options['width']; }
1847
+
1848
+ if (isset($kgvid_video_embed['height'])) { $height = $kgvid_video_embed['height']; }
1849
+ else { $height = get_post_meta($post->ID, "_kgflashmediaplayer-height", true); }
1850
+ if ( !$height ) { $height = get_post_meta($post->ID, "_kgflashmediaplayer-actualheight", true); }
1851
+ if ( !$height ) { $width = $options['width']; }
1852
+
1853
+ $url = wp_get_attachment_url($post->ID);
1854
+
1855
+ $shortcode = '[KGVID';
1856
+ if ($poster !="" ) { $shortcode .= ' poster="'.$poster.'"';}
1857
+ if ($width !="" ) { $shortcode .= ' width="'.$width.'"';}
1858
+ if ($height !="" ) { $shortcode .= ' height="'.$height.'"';}
1859
+ if (isset($kgvid_video_embed["gallery"])) { $shortcode .= ' autoplay="true"'; }
1860
+ $shortcode .= ']'.$url.'[/KGVID]';
1861
+ echo "<html>\n<head>";
1862
+ echo wp_head();
1863
+ echo "</head>\n<body>";
1864
+ echo do_shortcode( $shortcode );
1865
+ echo '</body></html>';
1866
+ exit;
1867
+ }
1868
  }
1869
  }
1870
+ add_action('template_redirect', 'kgvid_video_attachment_template');
 
1871
 
1872
+ function kgvid_cleanup_generated_logfiles_handler($logfile) {
1873
  $lastmodified = "";
1874
  if ( file_exists($logfile) ) { $lastmodified = filemtime($logfile); }
1875
  if ( $lastmodified != false ) {
1876
  if ( time() - $lastmodified > 120 ) { unlink($logfile); }
1877
  else {
1878
+ $timestamp = wp_next_scheduled( 'kgvid_cleanup_generated_logfiles' );
1879
+ wp_unschedule_event($timestamp, 'kgvid_cleanup_generated_logfiles' );
1880
  $args = array('logfile'=>$logfile);
1881
+ wp_schedule_single_event(time()+600, 'kgvid_cleanup_generated_logfiles', $args);
1882
  }
1883
  }
1884
  }
1885
+ add_action('kgvid_cleanup_generated_logfiles','kgvid_cleanup_generated_logfiles_handler');
1886
 
1887
+ function kgvid_cleanup_generated_thumbnails_handler() {
1888
  $uploads = wp_upload_dir();
1889
+ kgvid_rrmdir($uploads['path'].'/thumb_tmp'); //remove the whole tmp file directory
1890
+ kgvid_clear_completed_queue();
1891
  }
1892
+ add_action('kgvid_cleanup_generated_thumbnails','kgvid_cleanup_generated_thumbnails_handler');
1893
 
1894
+ function kgvid_schedule_cleanup_generated_files() { //schedules deleting all tmp thumbnails or logfiles if no files are generated in an hour
1895
 
1896
  check_ajax_referer( 'video-embed-thumbnail-generator-nonce', 'security' );
1897
 
1898
  if (isset($_POST['thumbs'])) {
1899
+ $timestamp = wp_next_scheduled( 'kgvid_cleanup_generated_thumbnails' );
1900
+ wp_unschedule_event($timestamp, 'kgvid_cleanup_generated_thumbnails' );
1901
+ wp_schedule_single_event(time()+3600, 'kgvid_cleanup_generated_thumbnails');
1902
  }
1903
 
1904
  if (isset($_POST['logfile'])) {
1905
+ $timestamp = wp_next_scheduled( 'kgvid_cleanup_generated_logfiles' );
1906
+ wp_unschedule_event($timestamp, 'kgvid_cleanup_generated_logfiles' );
1907
  $args = array('logfile'=>$_POST['logfile']);
1908
+ wp_schedule_single_event(time()+600, 'kgvid_cleanup_generated_logfiles', $args);
1909
+ }
1910
+
1911
+ if (isset($_POST['queue'])) {
1912
+ $timestamp = wp_next_scheduled( 'kgvid_cleanup_queue' );
1913
+ wp_unschedule_event($timestamp, 'kgvid_cleanup_queue' );
1914
+ wp_schedule_single_event(time()+86400, 'kgvid_cleanup_queue');
1915
  }
1916
+
1917
  die(); // this is required to return a proper result
1918
  }
1919
+ add_action('wp_ajax_kgvid_schedule_cleanup_generated_files', 'kgvid_schedule_cleanup_generated_files');
1920
 
1921
+ function kgvid_callffmpeg() {
1922
 
1923
  check_ajax_referer( 'video-embed-thumbnail-generator-nonce', 'security' );
1924
  global $wpdb;
1925
+
1926
+ $options = get_option('kgvid_video_embed_options');
1927
+ $ffmpegPath = $options['app_path']."/".$options['video_app'];
1928
+ $uploads = wp_upload_dir();
1929
+ if (isset($_POST['encodeformats'])) { $encode_checked = $_POST['encodeformats']; }
1930
+ if (isset($_POST['movieurl'])) { $movieurl = esc_url_raw($_POST['movieurl']); }
1931
+ if (isset($_POST['numberofthumbs'])) { $numberofthumbs = $_POST['numberofthumbs']; }
1932
+ if (isset($_POST['thumbnumber'])) { $i = $_POST['thumbnumber']; }
1933
+ if (isset($_POST['thumbnumberplusincreaser'])) { $iincreaser = $_POST['thumbnumberplusincreaser']; }
1934
+ if (isset($_POST['ffmpeg_action'])) { $action = $_POST['ffmpeg_action']; }
1935
+ if (isset($_POST['poster'])) { $poster = $_POST['poster']; }
1936
+ if (isset($_POST['attachmentID'])) { $postID = $_POST['attachmentID']; }
1937
+ if (isset($_POST['thumbtimecode'])) { $thumbtimecode = $_POST['thumbtimecode']; }
1938
+ if (isset($_POST['dofirstframe'])) { $dofirstframe = $_POST['dofirstframe']; }
1939
+ if (isset($_POST['generate_button'])) { $generate_button = $_POST['generate_button']; }
1940
+
1941
+ if ( is_numeric($postID) ) { $moviefilepath = get_attached_file($postID); }
1942
+ else {
1943
+ $moviefilepath = str_replace(" ", "%20", $movieurl);
1944
+ $moviefilepath = str_replace("https://", "http://", $moviefilepath);
1945
+ }
1946
+
1947
+ $movie_extension = pathinfo(parse_url($movieurl, PHP_URL_PATH), PATHINFO_EXTENSION);
1948
+ $moviefilebasename = basename($movieurl,'.'.$movie_extension);
1949
+ $thumbnailfilebase = $uploads['url']."/thumb_tmp/".$moviefilebasename;
1950
+
1951
+ if ($action == "generate" || $action == "encode" || $action == "enqueue" ) {
1952
+
1953
+ if ( $options['ffmpeg_exists'] == true ) { //if FFMPEG is installed
1954
+
1955
+ $movie_info = kgvid_get_video_dimensions($moviefilepath);
1956
+
1957
+ if ($movie_info['worked'] == true) { //if FFMPEG was able to open the file
1958
+
1959
+ $movie_duration_hours = intval(substr($movie_info['duration'], -11, 2));
1960
+ $movie_duration_minutes = intval(substr($movie_info['duration'], -8, 2));
1961
+ $movie_duration_seconds = intval(substr($movie_info['duration'], -5, 2));
1962
+ $movie_duration_seconds = ($movie_duration_hours * 60 * 60) + ($movie_duration_minutes * 60) + $movie_duration_seconds;
1963
+ $movie_width = $movie_info['width'];
1964
+ $movie_height = $movie_info['height'];
1965
+
1966
+ if ( is_numeric($postID) ) {
1967
+ update_post_meta($postID, '_kgflashmediaplayer-actualwidth', $movie_width);
1968
+ update_post_meta($postID, '_kgflashmediaplayer-actualheight', $movie_height);
1969
+ }
1970
+
1971
+ switch ($movie_info['rotate']) {
1972
+ case "90": $movie_rotate = '-vf "transpose=1"'; break;
1973
+ case "180": $movie_rotate = '-vf "hflip,vflip"'; break;
1974
+ case "270": $movie_rotate = '-vf "transpose=2"'; break;
1975
+ default: $movie_rotate = ""; break;
1976
+ }
1977
+
1978
+ if ($action == "generate") {
1979
+
1980
+ if (!file_exists($uploads['path'].'/thumb_tmp')) { mkdir($uploads['path'].'/thumb_tmp'); }
1981
+
1982
+ $thumbnailheight = strval(round(floatval($movie_height) / floatval($movie_width) * 200));
1983
+
1984
+ switch ($movie_info['rotate']) { //if it's a sideways mobile video
1985
+ case "90";
1986
+ case "270": $thumbnailheight = strval(round(floatval($movie_width) / floatval($movie_height) * 200));
1987
+ }
1988
+
1989
+ $jpgpath = $uploads['path']."/thumb_tmp/";
1990
+
1991
+ $movieoffset = round(($movie_duration_seconds * $iincreaser) / ($numberofthumbs * 2));
1992
+
1993
+ if ($generate_button == "random") { //adjust offset random amount
1994
+ $movieoffset = $movieoffset - rand(0, round($movie_duration_seconds / $numberofthumbs));
1995
+ if ($movieoffset < 0) { $movieoffset = "0"; }
1996
+ }
1997
+
1998
+ if ($thumbtimecode) { //if a specific thumbnail timecode is set
1999
+ if ($thumbtimecode == "firstframe") { $thumbtimecode = "0"; }
2000
+ $timecode_array = explode(":", $thumbtimecode);
2001
+ $timecode_array = array_reverse($timecode_array);
2002
+ if ( array_key_exists(1, $timecode_array) ) { $timecode_array[1] = $timecode_array[1] * 60; }
2003
+ if ( array_key_exists(2, $timecode_array) ) { $timecode_array[2] = $timecode_array[2] * 3600; }
2004
+ $thumbtimecode = array_sum($timecode_array);
2005
+ $movieoffset = $thumbtimecode;
2006
+ $i = $numberofthumbs + 1;
2007
+ }
2008
+
2009
+ if ($dofirstframe == "true" && $i == 1) {
2010
+ $movieoffset = "0";
2011
+ }
2012
+
2013
+ $thumbnailfilename[$i] = $jpgpath.$moviefilebasename."_thumb".$movieoffset.".jpg";
2014
+ $thumbnailfilename[$i] = str_replace(" ", "_", $thumbnailfilename[$i]);
2015
+ $ffmpeg_options = '-y -ss '.$movieoffset.' -i "'.$moviefilepath.'" '.$movie_rotate.' -vframes 1 "'.$thumbnailfilename[$i].'"';
2016
+ $thumbnailurl = $thumbnailfilebase."_thumb".$movieoffset.'.jpg';
2017
+ $thumbnailurl = str_replace(" ", "_", $thumbnailurl);
2018
+
2019
+ exec($ffmpegPath." ".$ffmpeg_options);
2020
+
2021
+ if (floatval($movieoffset) > 60) {
2022
+ $movieoffset_minutes = sprintf("%02s", intval(intval($movieoffset) / 60) );
2023
+ $movieoffset_seconds = sprintf("%02s", round(fmod( floatval($movieoffset), 60), 2) );
2024
+ $movieoffset_display = $movieoffset_minutes.":".$movieoffset_seconds;
2025
+ }
2026
+ else { $movieoffset_display = "00:".sprintf("%02s", $movieoffset); }
2027
+
2028
+ $thumbnaildisplaycode = '<div class="kgvid_thumbnail_select" name="attachments['.$postID.'][thumb'.$i.']" id="attachments-'.$postID.'-thumb'.$i.'"><label for="kgflashmedia_'.$postID.'_thumb'.$i.'"><img src="'.$thumbnailurl.'?'.rand().'" width="200" height="'.$thumbnailheight.'" class="kgvid_thumbnail"></label><br /><input type="radio" name="kgflashmedia-thumb" id="kgflashmedia_'.$postID.'_thumb'.$i.'" value="'.str_replace('/thumb_tmp/', '/', $thumbnailurl).'" onchange="getElementById(\'attachments-'. $postID .'-kgflashmediaplayer-poster\').value = this.value; getElementById(\'attachments-'. $postID .'-thumbtime\').value = \''. $movieoffset_display .'\'; getElementById(\'attachments-'. $postID .'-numberofthumbs\').value =\'1\';"></div>';
2029
+
2030
+ switch ($movie_info['rotate']) {
2031
+ case "90";
2032
+ case "270": $movie_width ^= $movie_height ^= $movie_width ^= $movie_height; break; //swap height & width
2033
+ }
2034
+
2035
+ $i++;
2036
+
2037
+ $arr = array ( "thumbnaildisplaycode"=>$thumbnaildisplaycode, "movie_width"=>$movie_width, "movie_height"=>$movie_height, "lastthumbnumber"=>$i, "movieoffset"=>$movieoffset );
2038
+
2039
+ echo json_encode($arr);
2040
+ }//if generate
2041
+
2042
+ if ($action == "enqueue") {
2043
+
2044
+ $embed_display = "";
2045
+ $start_encoding = false;
2046
+ $encode_these = array();
2047
+ $encode_list = array();
2048
+ $embeddable = array("flv", "f4v", "mp4", "mov", "m4v", "ogv", "ogg", "webm");
2049
+ $h264extensions = array("mp4", "m4v");
2050
+ $video_formats = kgvid_video_formats();
2051
+
2052
+ /*if ( !is_numeric($postID) ) {
2053
+ $info = pathinfo($movieurl);
2054
+ $postID = 'singleurl_'.basename($movieurl,'.'.$info['extension']);
2055
+ }*/
2056
+
2057
+ $encodevideo_info = kgvid_encodevideo_info($movieurl, $postID);
2058
+
2059
+ foreach ( $video_formats as $format => $format_stats ) {
2060
+ if ( $encode_checked[$format] == "true" ) {
2061
+ if ( !$encodevideo_info[$format.'_exists'] ) {
2062
+ if ( ($format == "1080" && $movie_height <= 1080) || ($format == "720" && $movie_height <= 720) ) {
2063
+ if ( in_array($movie_extension, $h264extensions) || $movie_height < intval($format) ) {
2064
+ $encode_formats[$format]['status'] = "lowres";
2065
+ } //skip if the resolution of an existing video is lower than the HD format
2066
+ }
2067
+ else {
2068
+ $encode_formats[$format]['status'] = "queued";
2069
+ $encode_formats[$format]['name'] = $format_stats['name'];
2070
+ $encode_list[$format] = $format_stats['name'];
2071
+ update_post_meta($postID, '_kgflashmediaplayer-encode'.$format, 'on');
2072
+ }
2073
+ } // if video doesn't already exist
2074
+ else { $encode_formats[$format]['status'] = "encoded"; }
2075
+ } // if user wants to encode format
2076
+ else {
2077
+ $encode_formats[$format]['status'] = "notchecked";
2078
+ update_post_meta($postID, '_kgflashmediaplayer-encode'.$format, 'notchecked');
2079
+ }
2080
+ }
2081
+
2082
+ if ( !empty($encode_list) ) {
2083
+ $video_embed_queue = get_option('kgvid_video_embed_queue');
2084
+ $queue_entry = array (
2085
+ 'attachmentID'=>$postID,
2086
+ 'movieurl' => $movieurl,
2087
+ 'encode_formats'=> $encode_formats,
2088
+ 'movie_info' => $movie_info
2089
+ );
2090
+ $already_queued = false;
2091
+ if ( !empty($video_embed_queue ) ) {
2092
+ foreach ($video_embed_queue as $index => $entry) {
2093
+ if ( $entry['movieurl'] == $movieurl ) {
2094
+ $already_queued = $index;
2095
+ foreach ( $entry['encode_formats'] as $format => $value ) {
2096
+ if ( $value['status'] == "queued" && array_key_exists($format, $encode_list) ) { unset($encode_list[$format]); }
2097
+ if ( $value['status'] == "encoding" ) { $queue_entry['encode_formats'][$format] = $entry['encode_formats'][$format]; } //don't edit queue entry for anything that's currently encoding
2098
+ }
2099
+ }
2100
+ }
2101
+ }
2102
+
2103
+ if ( $already_queued !== false ) {
2104
+ $video_embed_queue[$already_queued] = $queue_entry;
2105
+ update_option('kgvid_video_embed_queue', $video_embed_queue);
2106
+ if ( !empty($encode_list) ) { $embed_display = "<strong>".implode(", " , $encode_list)." updated in existing queue entry in position ".strval(intval($already_queued)+1).". </strong>"; }
2107
+ else { $embed_display = "<strong>Video is already queued in position ".strval(intval($already_queued)+1).". </strong>"; }
2108
+ }
2109
+ else {
2110
+ $video_embed_queue[] = $queue_entry;
2111
+ update_option('kgvid_video_embed_queue', $video_embed_queue);
2112
+ $queue_position = intval(key( array_slice( $video_embed_queue, -1, 1, TRUE ) ));
2113
+ if ( $queue_position == 0 ) { $embed_display = "<strong>Starting ".strtoupper($options['video_app'])."... </strong>"; }
2114
+ else { $embed_display = "<strong>".implode(", " , $encode_list)." added to queue in position ".strval(intval($queue_position)+1). ". </strong>";
2115
+ }
2116
+ }
2117
+ } //if any video formats don't already exist, add to queue
2118
+ else { $embed_display = "<strong>Nothing to encode.</strong>"; }
2119
+
2120
+ $replaceoptions = "";
2121
+ $originalselect = "";
2122
+
2123
+ $arr = array ( "embed_display"=>$embed_display );
2124
+ echo json_encode($arr);
2125
+
2126
+ }//if enqueue
2127
+
2128
+ }//if ffmpeg can open movie
2129
+
2130
+ else { $thumbnaildisplaycode = "<strong>Can't open movie file.</strong><br />".$movie_info['output'];
2131
+ $arr = array ( "thumbnaildisplaycode"=>$thumbnaildisplaycode, "embed_display"=>$thumbnaildisplaycode, "lastthumbnumber"=>"break" );
2132
+ echo json_encode($arr);
2133
+ } //can't open movie
2134
+
2135
+ }//if ffmpeg exists
2136
+
2137
+ else { $thumbnaildisplaycode = '<strong>Error: '.strtoupper($options["video_app"]).' not found. Verify that '.strtoupper($options["video_app"]).' is installed at '.strtoupper($options["app_path"]).' and check the <a href="options-general.php?page=video-embed-thumbnail-generator/video-embed-thumbnail-generator.php">application path plugin setting</a>.</strong>' ;
2138
+ $arr = array ( "thumbnaildisplaycode"=>$thumbnaildisplaycode, "embed_display"=>$thumbnaildisplaycode, "lastthumbnumber"=>"break" );
2139
+ echo json_encode($arr);
2140
+ } //no ffmpeg
2141
+
2142
+
2143
+ }// if encoding or generating
2144
+
2145
+ if ($action == "submit") { //called by the "Embed Video from URL" tab when submitting
2146
+
2147
+ if (isset($_POST['post_id'])) { $post_id = $_POST['post_id']; }
2148
+ $post_name = get_the_title($post_id);
2149
+ kgvid_save_thumb($post_id, $post_name, $poster);
2150
+ }//if submit
2151
+
2152
  die(); // this is required to return a proper result
2153
  }
2154
+ add_action('wp_ajax_kgvid_callffmpeg', 'kgvid_callffmpeg');
2155
 
2156
+ function kgvid_encode_videos() {
2157
 
 
 
 
 
 
 
 
2158
  $embed_display = "";
2159
+ $video = "";
2160
+ $video_key = "";
2161
+ $queued_format = "";
2162
+ $encoding = "";
2163
+ $movie_info = array("width"=>"", "height"=>"");
2164
+ $video_embed_queue = get_option('kgvid_video_embed_queue');
2165
+ $video_formats = kgvid_video_formats();
2166
+
2167
+ if ( !empty($video_embed_queue) ) {
2168
+
2169
+ $simultaneous = 1;
2170
+
2171
+ foreach ( $video_embed_queue as $video_key => $queue_entry ) { //search the queue for any encoding video
2172
+ foreach ( $queue_entry['encode_formats'] as $format => $value ) {
2173
+ if ( $value['status'] == "encoding" ) {
2174
+ $video[] = $video_embed_queue[$video_key];
2175
+ $encoding[] = $value;
2176
+ $simultaneous--;
2177
+ if ( !empty($simultaneous) ) { break 2; }
2178
+ }
2179
+ }
 
 
 
 
 
 
 
2180
  }
2181
+
2182
+ if ( empty($encoding) ) {
2183
+ foreach ( $video_embed_queue as $video_key => $queue_entry ) {
2184
+ foreach ( $queue_entry['encode_formats'] as $format => $value ) {
2185
+ if ( $value['status'] == "queued" ) {
2186
+ $video = $video_embed_queue[$video_key];
2187
+ $queued_format = $format;
2188
+ break 2;
2189
+ }
2190
+ }
2191
+ }
2192
+ }
2193
+
2194
+ if ( !empty($queued_format) ) {
2195
+
2196
+ $options = get_option('kgvid_video_embed_options');
2197
+
2198
+ $ffmpegPath = $options['app_path']."/".$options['video_app'];
2199
+ if ( is_numeric($video['attachmentID']) ) { $moviefilepath = get_attached_file($video['attachmentID']); }
2200
+ else {
2201
+ $moviefilepath = str_replace(" ", "%20", esc_url_raw($video['movieurl']));
2202
+ $moviefilepath = str_replace("https://", "http://", $moviefilepath);
2203
+ }
2204
+
2205
+
2206
+ $movie_info = $video['movie_info'];
2207
+ $encodevideo_info = kgvid_encodevideo_info($video['movieurl'], $video['attachmentID']);
2208
+
2209
+ $logfile = "";
2210
+ $processPID = "";
2211
+ $serverOS = "";
2212
+ $ffmpeg_options = "";
2213
 
2214
+ switch ($movie_info['rotate']) {
2215
+ case "90": $movie_rotate = '-vf "transpose=1"'; break;
2216
+ case "180": $movie_rotate = '-vf "hflip,vflip"'; break;
2217
+ case "270": $movie_rotate = '-vf "transpose=2"'; break;
2218
+ default: $movie_rotate = ""; break;
 
2219
  }
2220
+
2221
+ if ( ! file_exists($encodevideo_info['encodepath']) ) { mkdir($encodevideo_info['encodepath']); }
2222
+
2223
+ if ( $options['video_app'] == "avconv" ) {
2224
+ $video_bitrate_flag = "b:v";
2225
+ $audio_bitrate_flag = "b:a";
2226
+ }
2227
+
2228
+ if ( $options['video_app'] == "ffmpeg" ) {
2229
+ $video_bitrate_flag = "b";
2230
+ $audio_bitrate_flag = "ab";
2231
+ }
2232
+
2233
+ if ( ($movie_info['configuration']['libfaac'] == "true" || $movie_info['configuration']['libvo_aacenc'] == "true" ) && $movie_info['configuration']['libx264'] == "true" ) {
2234
+ foreach( $video_formats as $format => $format_stats ) {
2235
+ if ( $queued_format == $format && $format_stats['type'] == "h264" ) {
2236
+ if ( ! $encodevideo_info[$format.'_exists'] || ($encodevideo_info['sameserver'] && filesize($encodevideo_info[$format.'filepath']) < 24576) ) {
2237
+
2238
+ if ( intval($movie_info['width']) > $format_stats['width'] ) { $h264_movie_width = $format_stats['width']; }
2239
+ else { $h264_movie_width = $movie_info['width']; }
2240
+ $h264_movie_height = strval(round(floatval($movie_info['height']) / floatval($movie_info['width']) * $h264_movie_width));
2241
+ if ( intval($h264_movie_height) > $format_stats['height'] ) { $h264_movie_height = $format_stats['height']; }
2242
+ $h264_movie_width = strval(round(floatval($movie_info['width']) / floatval($movie_info['height']) * $h264_movie_height));
2243
+
2244
+ if ($h264_movie_height % 2 != 0) { $h264_movie_height++; } //if it's odd, increase by 1 to make sure it's an even number
2245
+ if ($h264_movie_width % 2 != 0) { $h264_movie_width--; } //if it's odd, increase by 1 to make sure it's an even number
2246
+
2247
+ if ( $movie_info['configuration']['libvo_aacenc'] == "true" ) { $aaclib = "libvo_aacenc"; }
2248
+ else { $aaclib = "libfaac"; }
2249
+
2250
+ $h264bitrate = round($h264_movie_height * 2.75);
2251
+ $vpre_flags = "";
2252
+ if ( $options['ffmpeg_vpre'] == 'on' ) { $vpre_flags = '-vpre slow -vpre ipod640'; }
2253
+
2254
+ /* $faststart = "";
2255
+ $faststart_app = get_option('wp_FMP_faststart');
2256
+ if ( $faststart_app = 'qt-faststart' ) {
2257
+ $faststart_tmp_file = str_replace('.m4v' '-faststart.m4v', $encodevideo_info['mobilefilepath']);
2258
+ $faststart = ' && '.get_option("wp_FMP_ffmpeg").'/'.$faststart_app.' '.$encodevideo_info["mobilefilepath"].' '.$faststart_tmp_file.' && rm '.$encodevideo_info["mobilefilepath"].' && mv '.$faststart_tmp_file.' '.$encodevideo_info["mobilefilepath"];
2259
+ }
2260
+ if ( $faststart_app = 'MP4Box' ) {
2261
+ $faststart = ' && '.get_option("wp_FMP_ffmpeg").'/'.$faststart_app.' -inter 500 '.$encodevideo_info["mobilefilepath"];
2262
+ } */
2263
+
2264
+ $ffmpeg_options = ' -acodec '.$aaclib.' -'.$audio_bitrate_flag.' 128k -s '.$h264_movie_width.'x'.$h264_movie_height.' -vcodec libx264 '.$vpre_flags.' -threads 1 '.$movie_rotate.' -'.$video_bitrate_flag.' '.$h264bitrate.'k -bt 800k -f ipod "'.$encodevideo_info[$format.'filepath'].'"';
2265
+ $embed_display .= "<strong>Encoding ".$format_stats['name']."</strong>";
2266
+ }//if file doesn't already exist
2267
+ else { $embed_display .= "<strong>".$format_stats['name']." already encoded. </strong>"; }
2268
+ break; //don't bother looping through the rest if we already found the format
2269
+ }//if format is chosen for encoding
2270
+ }//H.264 loop
2271
+ }//if the x264 & AAC libraries are enabled
2272
+ else {
2273
+ $missing_libraries = "";
2274
+ if($movie_info['configuration']['libfaac'] == 'false') { $missing_libraries .= 'libfaac '; }
2275
+ if($movie_info['configuration']['libvo_aacenc'] == 'false') { $missing_libraries .= 'libvo-aacenc '; }
2276
+ if($movie_info['configuration']['libfaac'] == 'false') { $missing_libraries .= 'libx264 '; }
2277
+ $embed_display .= "<strong>".strtoupper($options['video_app'])." missing library ".$missing_libraries."required for H.264/AAC encoding. </strong>";
2278
+ }
2279
+
2280
+ if ( $queued_format == "webm" ) {
2281
+ if ( ! $encodevideo_info['webm_exists'] || ($encodevideo_info['sameserver'] && filesize($encodevideo_info['webmfilepath']) < 24576) ) {
2282
+ if ( $movie_info['configuration']['libvorbis'] == "true" && $movie_info['configuration']['libvpx'] == "true" ) {
2283
+ $webmbitrate = $movie_info['height'] * 3;
2284
+ $ffmpeg_options = ' -'.$audio_bitrate_flag.' 128k -'.$video_bitrate_flag.' '.$webmbitrate.'k '.$movie_rotate.' -threads 1 "'.$encodevideo_info['webmfilepath'].'"';
2285
+ $embed_display .= "<strong>Encoding WEBM. </strong>";
2286
+ }//if the necessary webm libraries are enabled
2287
+ else {
2288
+ $missing_libraries = "";
2289
+ if($movie_info['configuration']['libvorbis'] == 'false') { $missing_libraries .= 'libvorbis '; }
2290
+ if($movie_info['configuration']['libvpx'] == 'false') { $missing_libraries .= 'libvpx '; }
2291
+ $embed_display .= "<strong>".strtoupper($options['video_app'])." missing library ".$missing_libraries."required for WEBM encoding. </strong>";
2292
+ }
2293
+ }//if webm doesn't already exist
2294
+ else { $embed_display .= "<strong>WEBM Already Encoded. </strong>"; }
2295
+ }//if encodewebm is checked
2296
+
2297
+ if ( $queued_format == "ogg" ) {
2298
+ if ( ! $encodevideo_info['ogg_exists'] || ($encodevideo_info['sameserver'] && filesize($encodevideo_info['oggfilepath']) < 24576) ) {
2299
+
2300
+ if ( $movie_info['configuration']['libvorbis'] == "true" && $movie_info['configuration']['libtheora'] == "true" ) {
2301
+ $ogvbitrate = $movie_info['height'] * 3;
2302
+ $ffmpeg_options = ' -acodec libvorbis -'.$audio_bitrate_flag.' 128k -vcodec libtheora -'.$video_bitrate_flag.' '.$ogvbitrate.'k '.$movie_rotate.' -threads 1 "'.$encodevideo_info['oggfilepath'].'"';
2303
+ $embed_display .= "<strong>Encoding OGV. </strong>";
2304
+ }//if the necessary OGV libraries are enabled
2305
+ else {
2306
+ $missing_libraries = "";
2307
+ if($movie_info['configuration']['libvorbis'] == 'false') { $missing_libraries .= 'libvorbis '; }
2308
+ if($movie_info['configuration']['libvtheora'] == 'false') { $missing_libraries .= 'libtheora '; }
2309
+ $embed_display .= "<strong>".strtoupper($options['video_app'])." missing library ".$missing_libraries."required for OGV encoding. </strong>";
2310
+ }
2311
+ }//if ogv doesn't already exist
2312
+ else { $embed_display .= "<strong>OGV Already Encoded. </strong>"; }
2313
+ }//if encodeogg is checked
2314
+
2315
+ if ( !empty($ffmpeg_options) ) {
2316
+
2317
+ $ffmpeg_args = '-y -i "'.$moviefilepath.'" '.$ffmpeg_options;
2318
+ $logfile = $encodevideo_info['encodepath'].str_replace(" ", "_", $encodevideo_info['moviefilebasename'])."_".$queued_format."_".sprintf("%04s",mt_rand(1, 1000))."_encode.txt";
2319
+
2320
+ $cmd = escapeshellcmd($ffmpegPath." ".$ffmpeg_args);
2321
+ $cmd = $cmd." > ".$logfile." 2>&1 & echo $!";
2322
+
2323
+ $process = new kgvid_Process($cmd);
2324
+
2325
+ sleep(1);
2326
+
2327
+ $processPID = $process->getPid();
2328
+ $serverOS = $process->OS;
2329
+
2330
+ $args = array('logfile'=>$logfile);
2331
+ wp_schedule_single_event(time()+600, 'kgvid_cleanup_generated_logfiles', $args);
2332
+
2333
+ //update_post_meta($video['attachmentID'], '_kgflashmediaplayer-encode'.$format, 'on');
2334
+
2335
+ $video['encode_formats'][$queued_format] = array (
2336
+ 'name' => $video_formats[$queued_format]['name'],
2337
+ 'status' => 'encoding',
2338
+ 'filepath' => $encodevideo_info[$queued_format.'filepath'],
2339
+ 'logfile' => $logfile,
2340
+ 'PID' => $processPID,
2341
+ 'OS' => $serverOS,
2342
+ 'started' => time()
2343
+ );
2344
+
2345
+ $queue_entry = array (
2346
+ 'attachmentID'=> $video['attachmentID'],
2347
+ 'movieurl' => $video['movieurl'],
2348
+ 'encode_formats'=> $video['encode_formats'],
2349
+ 'movie_info' => $video['movie_info']
2350
+ );
2351
+
2352
+ $video_embed_queue[$video_key] = $queue_entry;
2353
+
2354
+ //$encoding = $video['encode_formats'][$queued_format];
2355
+
2356
+ //$embed_display .= " <em><small>".$cmd."</small></em>";
2357
+
2358
+ } //end if there's stuff to encode
2359
+
2360
+ //$output_map = array_map(create_function('$key, $value', 'return $key.":".$value." # ";'), array_keys($process->output), array_values($process->output));
2361
+ //$output_implode = implode($output_map);
2362
+ //$embed_display .= "Command: ".$cmd." Output: ".$output_implode;
2363
+
2364
+ update_option('kgvid_video_embed_queue', $video_embed_queue);
2365
+ kgvid_encode_progress($video_key, $queued_format, "attachment");
2366
+
2367
+ } //if there's a format to encode
2368
+
2369
+ } //if there's a queue
2370
+ $arr = array ( "embed_display"=>$embed_display, "video_key"=>$video_key, "format"=>$queued_format, "actualwidth"=>$movie_info['width'], "actualheight"=>$movie_info['height'] );
2371
+ return $arr;
2372
+
2373
+ }
2374
+
2375
+ function kgvid_ajax_encode_videos() {
2376
 
2377
+ check_ajax_referer( 'video-embed-thumbnail-generator-nonce', 'security' );
2378
+ global $wpdb;
2379
+ $arr = kgvid_encode_videos();
2380
+ echo json_encode($arr);
2381
+ die();
2382
 
2383
+ }
2384
+ add_action('wp_ajax_kgvid_ajax_encode_videos', 'kgvid_ajax_encode_videos');
2385
+
2386
+ function kgvid_encode_progress($video_key, $format, $page) {
2387
+
2388
+ $video_embed_queue = get_option('kgvid_video_embed_queue');
2389
+ $video_entry = $video_embed_queue[$video_key];
2390
+
2391
+ $pid = $video_entry['encode_formats'][$format]['PID'];
2392
+ $logfile = $video_entry['encode_formats'][$format]['logfile'];
2393
+ $started = $video_entry['encode_formats'][$format]['started'];
2394
+ $movie_duration = $video_entry['movie_info']['duration'];
2395
+ $embed_display = "";
2396
+ $percent_done = "";
2397
+ $time_remaining = "";
2398
+ $other_message = "";
2399
+ $logfilecontents = "";
2400
+ $lastline = "";
2401
+
2402
+ if ( is_file($logfile) ) {
2403
+
2404
+ $fp = fopen($logfile, 'r');
2405
+ $c = '';
2406
+ $read = '';
2407
+ $offset = -1;
2408
+ $lines = 2;
2409
+ while ( $lines && fseek($fp, $offset, SEEK_END) >= 0 ) {
2410
+ $c = fgetc($fp);
2411
+ if( $c == "\n" || $c == "\r" ) {
2412
+ $lines--;
2413
  }
2414
+ $read .= $c;
2415
+ $offset--;
2416
  }
2417
+ fclose($fp);
2418
+ $lastline = strrev(rtrim($read,"\n\r"));
2419
+
2420
+ $last_match = "";
2421
+ $time_matches = "";
2422
+ $video_matches = "";
2423
+ $libx264_matches = "";
2424
+ $fps_matches = "";
2425
+ $fps_match = "";
2426
+ $basename = "";
2427
+
2428
+ $script_function = 'kgvid_redraw_encode_checkboxes("'.$video_entry['movieurl'].'", "'.$video_entry['attachmentID'].'", "'.$page.'")';
2429
+
2430
+ preg_match('/time=(.*?) /', $lastline, $time_matches);
2431
+
2432
+ if ( array_key_exists(1, $time_matches) != true ) { //if something other than the regular FFMPEG encoding output check for these
2433
+ preg_match('/video:(.*?) /', $lastline, $video_matches);
2434
+ preg_match('/libx264 (.*?) /', $lastline, $libx264_matches);
2435
+ //preg_match('/h264 (.*?) /', $lastline, $h264_matches);
2436
+ //preg_match('/Press (.*?) /', $lastline, $Press_matches);
2437
+ //preg_match('/buffer (.*?) /', $lastline, $buffer_matches);
2438
+ }
2439
+
2440
+ if ( array_key_exists(1, $time_matches) == true ) { //still encoding
2441
+
2442
+ if ( strpos($time_matches[1], ':') !== false ) {
2443
+ $current_hours = intval(substr($time_matches[1], -11, 2));
2444
+ $current_minutes = intval(substr($time_matches[1], -8, 2));
2445
+ $current_seconds = intval(substr($time_matches[1], -5, 2));
2446
+ $current_seconds = ($current_hours * 60 * 60) + ($current_minutes * 60) + $current_seconds;
2447
+ }
2448
+ else { $current_seconds = $time_matches[1]; }
2449
+
2450
+ $duration_hours = intval(substr($movie_duration, -11, 2));
2451
+ $duration_minutes = intval(substr($movie_duration, -8, 2));
2452
+ $duration_seconds = intval(substr($movie_duration, -5, 2));
2453
+ $movie_duration = ($duration_hours * 60 * 60) + ($duration_minutes * 60) + $duration_seconds;
2454
+
2455
+ $percent_done = intval($current_seconds)/intval($movie_duration);
2456
+ $time_elapsed = time() - $started;
2457
+ if ( $percent_done != 0 ) { $time_remaining = date('H:i:s', round($time_elapsed / $percent_done) - $time_elapsed); }
2458
+ else $time_remaining = "unknown";
2459
+ $percent_done = round($percent_done*100);
2460
+ if ( $percent_done < 20 ) { $percent_done_text = ""; }
2461
+ else { $percent_done_text = strval($percent_done)."%"; }
2462
+
2463
+ preg_match('/fps=\s+(.*?) /', $lastline, $fps_matches);
2464
+ if ( array_key_exists(1, $fps_matches) == true ) {
2465
+ if ( $fps_matches[1] != 0 ) { $fps_match = $fps_matches[1]; }
2466
+ else { $fps_match = "10"; }
2467
  }
2468
+ else { $fps_match = "10"; }
2469
+ $time_to_wait = strval(max(round(30000/intval($fps_match)), 1000)); //wait at least 1 second
2470
+ if ( intval($time_to_wait) > 10000 ) { //wait no more than 10 seconds
2471
+ $time_to_wait = 10000;
2472
+ }
2473
+
2474
+ $args = array($video_key, $format, $page);
2475
+ wp_schedule_single_event(time()+60, 'kgvid_cron_queue_check', $args);
2476
+
2477
+ $embed_display = '<strong>Encoding</strong> <div class="meter"><span style="width:'.$percent_done.'%;">'.$percent_done_text.' </span></div><a href="javascript:void(0)" class="kgvid_cancel_button" id="attachments-'.$video_entry["attachmentID"].'-kgflashmediaplayer-cancelencode" onclick="kgvid_cancel_encode('.$pid.', \''.$video_entry["attachmentID"].'\', \''.$video_key.'\', \''.$format.'\');">Cancel</a><div style="display:block;"><small>Elapsed: '.date('H:i:s',$time_elapsed).'. Remaining: '.$time_remaining.'. FPS:'.$fps_match.'</small></div><script type="text/javascript">percent_timeout = setTimeout(function(){'.$script_function.'}, '.$time_to_wait.');</script>';
2478
  }
2479
+ elseif ( time() - $started < 10 ) { //not enough time has passed, so check again later
2480
+ $args = array($video_key, $format, $page);
2481
+ $embed_display = '<strong>Encoding</strong> <script type="text/javascript">percent_timeout = setTimeout(function(){'.$script_function.'}, 1000);</script>';
2482
+ wp_schedule_single_event(time()+60, 'kgvid_cron_queue_check', $args);
2483
+ }
2484
+ elseif ( array_key_exists(1, $video_matches) == true || array_key_exists(1, $libx264_matches) == true ) { //encoding complete
2485
+ $percent_done = 100;
2486
+ $ended = filemtime($logfile);
2487
+ $time_elapsed = $ended - $started;
2488
+ $time_remaining = "0";
2489
+ $fps_match = "10";
2490
+ if ( array_key_exists(1, $libx264_matches) ) { kgvid_fix_moov_atom($video_key, $format); } //fix the moov atom if the file was encoded by libx264
2491
+ $video_embed_queue[$video_key]['encode_formats'][$format]['status'] = "Encoding Complete";
2492
+ $video_embed_queue[$video_key]['encode_formats'][$format]['ended'] = $ended;
2493
+ $video_embed_queue[$video_key]['encode_formats'][$format]['lastline'] = $lastline;
2494
+ update_option('kgvid_video_embed_queue', $video_embed_queue);
2495
+ $embed_display = '<strong>Encoding Complete</strong> <script type="text/javascript">percent_timeout = setTimeout(function(){'.$script_function.'}, 1000);</script>';
2496
+ $next_video = kgvid_encode_videos(); //start the next queued video
2497
+ if ( !empty($next_video['format']) ) {
2498
+ $args = array($next_video['video_key'], $next_video['format'], $page);
2499
+ wp_schedule_single_event(time()+60, 'kgvid_cron_queue_check', $args);
2500
+ }
2501
+ }
2502
+ else { //there was an error";
2503
+ if ( strpos($lastline, "signal 15") !== false ) { //if the encoding was intentionally canceled
2504
+ $lastline = "Encoding was canceled.";
2505
+ }
2506
+ $video_embed_queue[$video_key]['encode_formats'][$format]['status'] = "error";
2507
+ $video_embed_queue[$video_key]['encode_formats'][$format]['lastline'] = $lastline;
2508
+ update_option('kgvid_video_embed_queue', $video_embed_queue);
2509
+ $other_message = $lastline;
2510
+ $embed_display = '<strong>Error: </strong><span style="color:red;">'.$lastline.'.</span> <script type="text/javascript">percent_timeout = setTimeout(function(){'.$script_function.'}, 1000);</script>';
2511
+ $next_video = kgvid_encode_videos(); //start the next queued video
2512
+ if ( !empty($next_video['format']) ) {
2513
+ $args = array($next_video['video_key'], $next_video['format'], $page);
2514
+ wp_schedule_single_event(time()+60, 'kgvid_cron_queue_check', $args);
2515
+ }
2516
+ }
2517
+
2518
+ //$embed_display .= $lastline;
2519
+ $arr = array ( "embed_display"=>$embed_display );
2520
+ }
2521
+ else { $arr = array ( "embed_display"=>"<strong>No log file</strong>" ); }
2522
+
2523
+ return $arr;
2524
+
2525
+ }
2526
+ add_action('kgvid_cron_queue_check', 'kgvid_encode_progress', 1, 3);
2527
+
2528
+ function kgvid_ajax_encode_progress() {
2529
+
2530
+ check_ajax_referer( 'video-embed-thumbnail-generator-nonce', 'security' );
2531
+ $video_key = $_POST['video_key'];
2532
+ $format = $_POST['format'];
2533
+ $page = $_POST['page'];
2534
+ global $wpdb;
2535
+ $progress = kgvid_encode_progress($video_key, $format, $page);
2536
+ echo json_encode($progress);
2537
+ die();
2538
+
2539
+ }
2540
+ add_action('wp_ajax_kgvid_encode_progress', 'kgvid_ajax_encode_progress');
2541
+
2542
+ function kgvid_clear_completed_queue() {
2543
+
2544
+ $video_embed_queue = get_option('kgvid_video_embed_queue');
2545
+
2546
+ if ( !empty($video_embed_queue) ) {
2547
+
2548
+ $keep = array();
2549
+ $cleared_video_queue = array();
2550
+
2551
+ foreach ( $video_embed_queue as $video_key => $queue_entry ) {
2552
+ if ( !empty($queue_entry['encode_formats']) ) {
2553
+ foreach ( $queue_entry['encode_formats'] as $format => $value ) {
2554
+ if ( $value['status'] == "queued" || $value['status'] == "encoding" ) {
2555
+ $keep[$video_key] = true;
2556
+ break;
2557
+ }
2558
  }
2559
  }
2560
  }
2561
+
2562
+ foreach ( $keep as $video_key => $value ) {
2563
+ $cleared_video_queue[] = $video_embed_queue[$video_key];
2564
+ }
2565
+ sort($cleared_video_queue);
2566
+
2567
+ update_option('kgvid_video_embed_queue', $cleared_video_queue);
2568
 
2569
+ }
2570
+ }
2571
+ add_action('kgvid_cleanup_queue','kgvid_clear_completed_queue');
2572
+
2573
+ function kgvid_ajax_clear_completed_queue() {
2574
+
2575
+ check_ajax_referer( 'video-embed-thumbnail-generator-nonce', 'security' );
2576
+ global $wpdb;
2577
+ kgvid_clear_completed_queue();
2578
+ $table = kgvid_generate_queue_table();
2579
+ echo ($table);
2580
+ die();
2581
 
2582
+ }
2583
+ add_action('wp_ajax_kgvid_clear_completed_queue', 'kgvid_ajax_clear_completed_queue');
2584
+
2585
+ function kgvid_ajax_clear_queue_entry() {
2586
+
2587
+ check_ajax_referer( 'video-embed-thumbnail-generator-nonce', 'security' );
2588
+ global $wpdb;
2589
+ $video_key = $_POST['index'];
2590
+ $video_embed_queue = get_option('kgvid_video_embed_queue');
2591
+ if ( array_key_exists($video_key, $video_embed_queue) ) {
2592
+ unset($video_embed_queue[$video_key]);
2593
+ sort($video_embed_queue);
2594
  }
2595
+ update_option('kgvid_video_embed_queue', $video_embed_queue);
2596
+ $table = kgvid_generate_queue_table();
2597
+ echo ($table);
2598
+ die();
2599
+
2600
+ }
2601
+ add_action('wp_ajax_kgvid_clear_queue_entry', 'kgvid_ajax_clear_queue_entry');
2602
 
2603
+ function kgvid_fix_moov_atom($video_key, $format) {
2604
+
2605
+ $options = get_option('kgvid_video_embed_options');
2606
+
2607
+ if ( $options['moov'] != "none" ) {
2608
+
2609
+ $video_embed_queue = get_option('kgvid_video_embed_queue');
2610
+ $filepath = $video_embed_queue[$video_key][$format]['filepath'];
2611
+
2612
+ if ( $options['moov'] == 'qt-faststart' && file_exists($filepath) ) {
2613
+ $faststart_tmp_file = str_replace('.m4v', '-faststart.m4v', $filepath);
2614
+ $cmd = escapeshellcmd($options['app_path']."/".$options['moov']." ".$filepath." ".$faststart_tmp_file);
2615
+ exec($cmd);
2616
+ if ( file_exists($faststart_tmp_file) ) {
2617
+ unlink($filepath);
2618
+ rename($faststart_tmp_file, $filepath);
2619
+ }
2620
+ }//if qt-faststart is selected
2621
+
2622
+ if ( $options['moov'] == 'MP4Box' ) {
2623
+ $cmd = escapeshellcmd($options['app_path']."/".$options['moov']." -inter 500 ".$filepath);
2624
+ exec($cmd);
2625
+ }//if MP4Box is selected
2626
+
2627
+ //$video_embed_queue[$video_key][$format]['status'] = "moov_fixed";
2628
+ //update_option('kgvid_video_embed_options');
2629
+
2630
+ }//if there is an application selected for fixing moov atoms on libx264-encoded files.
2631
 
 
2632
  }
 
2633
 
2634
+ function kgvid_cancel_encode() {
2635
 
2636
  check_ajax_referer( 'video-embed-thumbnail-generator-nonce', 'security' );
2637
 
2638
+ if (isset($_POST['kgvid_pid'])) {
2639
+ $kgvid_pid = $_POST['kgvid_pid'];
2640
+ if ( intval($kgvid_pid) > 0 ) {
2641
+ posix_kill($kgvid_pid, 15);
 
 
2642
  }
2643
+ $video_key = $_POST['video_key'];
2644
+ $format = $_POST['format'];
2645
+ $video_embed_queue = get_option('kgvid_video_embed_queue');
2646
+ $video_embed_queue[$video_key]['encode_formats'][$format]['status'] = "canceling";
2647
+ update_option('kgvid_video_embed_queue', $video_embed_queue);
2648
  }
 
2649
  die(); // this is required to return a proper result
2650
  }
2651
+ add_action('wp_ajax_kgvid_cancel_encode', 'kgvid_cancel_encode');
2652
 
2653
+ function kgvid_ajax_delete_video() {
 
 
 
2654
 
2655
+ check_ajax_referer( 'video-embed-thumbnail-generator-nonce', 'security' );
2656
+ global $wpdb;
2657
+ $deleted = false;
2658
+ if (isset($_POST['movieurl'])) {
2659
+ $encodevideo_info = kgvid_encodevideo_info($_POST['movieurl'], $_POST['postid']);
2660
+ if ( is_file($encodevideo_info[$_POST['format'].'filepath']) ) {
2661
+ $deleted = unlink($encodevideo_info[$_POST['format'].'filepath']);
2662
+ }
2663
+ $video_embed_queue = get_option('kgvid_video_embed_queue');
2664
+ if ( !empty($video_embed_queue) ) {
2665
+ foreach ($video_embed_queue as $video_key => $video_entry) {
2666
+ if ( $video_entry['movieurl'] == $_POST['movieurl'] ) {
2667
+ $video_embed_queue[$video_key]['encode_formats'][$_POST['format']]['status'] = "deleted";
2668
+ break;
2669
+ }
2670
+ }
2671
+ }
2672
+ update_option('kgvid_video_embed_queue', $video_embed_queue);
2673
+ }
2674
+ echo($deleted);
2675
+ die();
2676
+
2677
  }
2678
+ add_action('wp_ajax_kgvid_delete_video', 'kgvid_ajax_delete_video');
2679
 
2680
+ function enqueue_kgvid_script() { //loads plugin-related javascripts
2681
+ wp_enqueue_script( 'video_embed_thumbnail_generator_script', plugins_url('/js/kgvid_video_plugin_admin.js', __FILE__) );
2682
+ wp_enqueue_style( 'kgvid_progressbar_style', plugins_url('/css/video-embed-thumbnail-generator_admin.css', __FILE__) );
2683
+ wp_enqueue_script( 'jquery-ui-sortable' );
2684
+ }
2685
+ add_action('admin_enqueue_scripts', 'enqueue_kgvid_script');
2686
+
2687
+ add_action( 'wp_ajax_kgvid_count_play', 'kgvid_count_play' ); // ajax for logged in users
2688
+ add_action( 'wp_ajax_nopriv_kgvid_count_play', 'kgvid_count_play' ); // ajax for not logged in users
2689
+
2690
+ function kgvid_count_play() {
2691
+ $post_id = $_POST['post_id'];
2692
+ $plays = $_POST['video_plays'];
2693
+ $complete_views = $_POST['complete_views'];
2694
+ // doing ajax stuff
2695
+ update_post_meta($post_id, '_kgflashmediaplayer-starts', $plays);
2696
+ update_post_meta($post_id, '_kgflashmediaplayer-completeviews', $complete_views);
2697
+ echo 'ajax submitted';
2698
+ die(); // stop executing script
2699
+ }
2700
 
2701
  ?>
video-js/kg-video-js-skin.css ADDED
@@ -0,0 +1,408 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .vjs-poster {
2
+ max-width:none !important; //fixes conflict with some themes
3
+ }
4
+
5
+ /* The default control bar. Created by bar.js */
6
+ .kg-video-js-skin .vjs-controls {
7
+ position: absolute;
8
+ bottom: 0; /* Distance from the bottom of the box/video. Keep 0. Use height to add more bottom margin. */
9
+ left: 0; right: 0; /* 100% width of div */
10
+ margin: 0; padding: 0; /* Controls are absolutely position, so no padding necessary */
11
+ height: 2.6em; /* Including any margin you want above or below control items */
12
+ color: #fff; border-top: 1px solid #404040;
13
+
14
+ /* CSS Gradient */
15
+ /* Can use the Ultimate CSS Gradient Generator: http://www.colorzilla.com/gradient-editor/ */
16
+ background: #242424; /* Old browsers */
17
+ background: -moz-linear-gradient(top, #242424 50%, #1f1f1f 50%, #171717 100%); /* FF3.6+ */
18
+ background: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(50%,#242424), color-stop(50%,#1f1f1f), color-stop(100%,#171717)); /* Chrome,Safari4+ */
19
+ background: -webkit-linear-gradient(top, #242424 50%,#1f1f1f 50%,#171717 100%); /* Chrome10+,Safari5.1+ */
20
+ background: -o-linear-gradient(top, #242424 50%,#1f1f1f 50%,#171717 100%); /* Opera11.10+ */
21
+ background: -ms-linear-gradient(top, #242424 50%,#1f1f1f 50%,#171717 100%); /* IE10+ */
22
+ /* Filter was causing a lot of weird issues in IE. Elements would stop showing up, or other styles would break. */
23
+ /*filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#242424', endColorstr='#171717',GradientType=0 );*/ /* IE6-9 */
24
+ background: linear-gradient(top, #242424 50%,#1f1f1f 50%,#171717 100%); /* W3C */
25
+
26
+ /* Start hidden and with 0 opacity. Opacity is used to fade in modern browsers. */
27
+ /* Can't use display block to hide initially because widths of slider handles aren't calculated and avaialbe for positioning correctly. */
28
+ visibility: hidden;
29
+ opacity: 0;
30
+ }
31
+
32
+ /* General styles for individual controls. */
33
+ .kg-video-js-skin .vjs-control {
34
+ position: relative; float: left;
35
+ text-align: center; margin: 0; padding: 0;
36
+ height: 2.6em; width: 2.6em;
37
+ }
38
+
39
+ .kg-video-js-skin .vjs-control:focus {
40
+ outline: 0;
41
+ /* background-color: #555;*/
42
+ }
43
+
44
+ /* Hide control text visually, but have it available for screenreaders: h5bp.com/v */
45
+ .kg-video-js-skin .vjs-control-text { border: 0; clip: rect(0 0 0 0); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; width: 1px; }
46
+
47
+
48
+ /* Play/Pause
49
+ -------------------------------------------------------------------------------- */
50
+ .kg-video-js-skin .vjs-play-control { width: 5em; cursor: pointer !important; }
51
+ /* Play Icon */
52
+ .kg-video-js-skin.vjs-paused .vjs-play-control div { width: 15px; height: 17px; background: url('kg-video-js-skin.png'); margin: 0.5em auto 0; }
53
+ .kg-video-js-skin.vjs-playing .vjs-play-control div { width: 15px; height: 17px; background: url('kg-video-js-skin.png') -25px 0; margin: 0.5em auto 0; }
54
+
55
+ /* Rewind
56
+ -------------------------------------------------------------------------------- */
57
+ .kg-video-js-skin .vjs-rewind-control { width: 5em; cursor: pointer !important; }
58
+ .kg-video-js-skin .vjs-rewind-control div { width: 19px; height: 16px; background: url('kg-video-js-skin.png'); margin: 0.5em auto 0; }
59
+
60
+ /* Volume/Mute
61
+ -------------------------------------------------------------------------------- */
62
+ .kg-video-js-skin .vjs-mute-control { width: 3.8em; cursor: pointer !important; float: right; }
63
+ .kg-video-js-skin .vjs-mute-control div { width: 22px; height: 16px; background: url('kg-video-js-skin.png') -75px -25px; margin: 0.5em auto 0; }
64
+ .kg-video-js-skin .vjs-mute-control.vjs-vol-0 div { background: url('kg-video-js-skin.png') 0 -25px; }
65
+ .kg-video-js-skin .vjs-mute-control.vjs-vol-1 div { background: url('kg-video-js-skin.png') -25px -25px; }
66
+ .kg-video-js-skin .vjs-mute-control.vjs-vol-2 div { background: url('kg-video-js-skin.png') -50px -25px; }
67
+
68
+
69
+ .kg-video-js-skin .vjs-volume-control { width: 5em; float: right; }
70
+ .kg-video-js-skin .vjs-volume-bar {
71
+ position: relative; width: 5em; height: 0.6em; margin: 1em auto 0; cursor: pointer !important;
72
+
73
+ -moz-border-radius: 0.3em; -webkit-border-radius: 0.3em; border-radius: 0.3em;
74
+
75
+ background: #666;
76
+ background: -moz-linear-gradient(top, #333, #666);
77
+ background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#333), to(#666));
78
+ background: -webkit-linear-gradient(top, #333, #666);
79
+ background: -o-linear-gradient(top, #333, #666);
80
+ background: -ms-linear-gradient(top, #333, #666);
81
+ background: linear-gradient(top, #333, #666);
82
+ }
83
+ .kg-video-js-skin .vjs-volume-level {
84
+ position: absolute; top: 0; left: 0; height: 0.6em;
85
+
86
+ -moz-border-radius: 0.3em; -webkit-border-radius: 0.3em; border-radius: 0.3em;
87
+
88
+ background: #fff;
89
+ background: -moz-linear-gradient(top, #fff, #ccc);
90
+ background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#fff), to(#ccc));
91
+ background: -webkit-linear-gradient(top, #fff, #ccc);
92
+ background: -o-linear-gradient(top, #fff, #ccc);
93
+ background: -ms-linear-gradient(top, #fff, #ccc);
94
+ background: linear-gradient(top, #fff, #ccc);
95
+ }
96
+ .kg-video-js-skin .vjs-volume-handle {
97
+ position: absolute; top: -0.2em; width: 0.8em; height: 0.8em; background: #ccc; left: 0;
98
+ border: 1px solid #fff;
99
+ -moz-border-radius: 0.6em; -webkit-border-radius: 0.6em; border-radius: 0.6em;
100
+ }
101
+
102
+ /* Progress
103
+ -------------------------------------------------------------------------------- */
104
+ .kg-video-js-skin div.vjs-progress-control {
105
+ position: absolute;
106
+ left: 4.8em; right: 4.8em; /* Leave room for time displays. */
107
+ height: 1.0em; width: auto;
108
+ top: -1.3em; /* Set above the rest of the controls. And leave room for 2px of borders (progress bottom and controls top). */
109
+ border-bottom: 1px solid #1F1F1F;
110
+ border-top: 1px solid #222;
111
+
112
+ /* CSS Gradient */
113
+ background: #333;
114
+ background: -moz-linear-gradient(top, #222, #333);
115
+ background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#222), to(#333));
116
+ background: -webkit-linear-gradient(top, #222, #333);
117
+ background: -o-linear-gradient(top, #333, #222);
118
+ background: -ms-linear-gradient(top, #333, #222);
119
+ background: linear-gradient(top, #333, #222);
120
+
121
+
122
+ /* 1px top shadow */
123
+ /* -webkit-box-shadow: 0px -1px 0px 0px rgba(0, 0, 0, 0.15); -moz-box-shadow: 0px -1px 0px 0px rgba(0, 0, 0, 0.15); box-shadow: 0px -1px 0px 0px rgba(0, 0, 0, 0.15);*/
124
+ }
125
+
126
+ /* Box containing play and load progresses. Also acts as seek scrubber. */
127
+ .kg-video-js-skin .vjs-progress-holder {
128
+ position: relative; cursor: pointer !important; /*overflow: hidden;*/
129
+ padding: 0; margin: 0; /* Placement within the progress control item */
130
+ height: 1.0em;
131
+ -moz-border-radius: 0.6em; -webkit-border-radius: 0.6em; border-radius: 0.6em;
132
+
133
+ /* CSS Gradient */
134
+ background: #111;
135
+ background: -moz-linear-gradient(top, #111, #262626);
136
+ background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#111), to(#262626));
137
+ background: -webkit-linear-gradient(top, #111, #262626);
138
+ background: -o-linear-gradient(top, #111, #262626);
139
+ background: -ms-linear-gradient(top, #111, #262626);
140
+ background: linear-gradient(top, #111, #262626);
141
+ }
142
+ .kg-video-js-skin .vjs-progress-holder .vjs-play-progress,
143
+ .kg-video-js-skin .vjs-progress-holder .vjs-load-progress { /* Progress Bars */
144
+ position: absolute; display: block; height: 1.0em; margin: 0; padding: 0;
145
+ left: 0; top: 0; /*Needed for IE6*/
146
+ -moz-border-radius: 0.6em; -webkit-border-radius: 0.6em; border-radius: 0.6em;
147
+
148
+ /*width: 0;*/
149
+ }
150
+
151
+ .kg-video-js-skin .vjs-play-progress {
152
+ /* CSS Gradient. */
153
+ background: #fff; /* Old browsers */
154
+ background: -moz-linear-gradient(top, #fff 0%, #d6d6d6 50%, #fff 100%);
155
+ background: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(0%,#fff), color-stop(50%,#d6d6d6), color-stop(100%,#fff));
156
+ background: -webkit-linear-gradient(top, #fff 0%,#d6d6d6 50%,#fff 100%);
157
+ background: -o-linear-gradient(top, #fff 0%,#d6d6d6 50%,#fff 100%);
158
+ background: -ms-linear-gradient(top, #fff 0%,#d6d6d6 50%,#fff 100%);
159
+ background: linear-gradient(top, #fff 0%,#d6d6d6 50%,#fff 100%);
160
+
161
+ background: #efefef;
162
+ background: -moz-linear-gradient(top, #efefef 0%, #f5f5f5 50%, #dbdbdb 50%, #f1f1f1 100%);
163
+ background: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(0%,#efefef), color-stop(50%,#f5f5f5), color-stop(50%,#dbdbdb), color-stop(100%,#f1f1f1));
164
+ background: -webkit-linear-gradient(top, #efefef 0%,#f5f5f5 50%,#dbdbdb 50%,#f1f1f1 100%);
165
+ background: -o-linear-gradient(top, #efefef 0%,#f5f5f5 50%,#dbdbdb 50%,#f1f1f1 100%);
166
+ background: -ms-linear-gradient(top, #efefef 0%,#f5f5f5 50%,#dbdbdb 50%,#f1f1f1 100%);
167
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#efefef', endColorstr='#f1f1f1',GradientType=0 );
168
+ background: linear-gradient(top, #efefef 0%,#f5f5f5 50%,#dbdbdb 50%,#f1f1f1 100%);
169
+ }
170
+ .kg-video-js-skin .vjs-load-progress {
171
+ opacity: 0.8;
172
+
173
+ /* CSS Gradient */
174
+ background: #666;
175
+ background: -moz-linear-gradient(top, #666, #333);
176
+ background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#666), to(#333));
177
+ background: -webkit-linear-gradient(top, #666, #333);
178
+ background: -o-linear-gradient(top, #666, #333);
179
+ background: -ms-linear-gradient(top, #666, #333);
180
+ background: linear-gradient(top, #666, #333);
181
+ }
182
+
183
+ .kg-video-js-skin div.vjs-seek-handle {
184
+ position: absolute;
185
+ width: 16px; height: 16px; /* Match img pixles */
186
+ margin-top: -0.3em;
187
+ left: 0; top: 0; /*Needed for IE6*/
188
+
189
+ background: url('kg-video-js-skin.png') 0 -50px;
190
+ /* CSS Curved Corners. Needed to make shadows curved. */
191
+ -moz-border-radius: 0.8em; -webkit-border-radius: 0.8em; border-radius: 0.8em;
192
+ /* CSS Shadows */
193
+ -webkit-box-shadow: 0 2px 4px 0 #000; -moz-box-shadow: 0 2px 4px 0 #000; box-shadow: 0 2px 4px 0 #000;
194
+ }
195
+ /* Time Display
196
+ -------------------------------------------------------------------------------- */
197
+ .kg-video-js-skin .vjs-time-controls {
198
+ position: absolute;
199
+ right: 0;
200
+ height: 1.0em; width: 4.8em;
201
+ top: -1.3em;
202
+ border-bottom: 1px solid #1F1F1F;
203
+ border-top: 1px solid #222;
204
+ background-color: #333;
205
+
206
+ font-size: 1em; line-height: 1.0em; font-weight: normal; font-family: Helvetica, Arial, sans-serif;
207
+
208
+ background: #333;
209
+ background: -moz-linear-gradient(top, #222, #333);
210
+ background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#222), to(#333));
211
+ background: -webkit-linear-gradient(top, #222, #333);
212
+ background: -o-linear-gradient(top, #333, #222);
213
+ background: -ms-linear-gradient(top, #333, #222);
214
+ background: linear-gradient(top, #333, #222);
215
+
216
+ /* 1px top shadow */
217
+ /* -webkit-box-shadow: 0px -1px 0px 0px rgba(0, 0, 0, 0.15); -moz-box-shadow: 0px -1px 0px 0px rgba(0, 0, 0, 0.15); box-shadow: 0px -1px 0px 0px rgba(0, 0, 0, 0.15);*/
218
+ }
219
+
220
+ .kg-video-js-skin .vjs-current-time { left: 0; }
221
+
222
+ .kg-video-js-skin .vjs-duration { right: 0; display: none; }
223
+ .kg-video-js-skin .vjs-remaining-time { right: 0; }
224
+
225
+ .vjs-time-divider { display:none; }
226
+
227
+ .kg-video-js-skin .vjs-time-control { font-size: 1em; line-height: 1; font-weight: normal; font-family: Helvetica, Arial, sans-serif; }
228
+ .kg-video-js-skin .vjs-time-control span { line-height: 25px; /* Centering vertically */ }
229
+
230
+ /* Fullscreen
231
+ -------------------------------------------------------------------------------- */
232
+ .vjs-secondary-controls { float: right; }
233
+
234
+ .kg-video-js-skin .vjs-fullscreen-control { width: 3.8em; cursor: pointer !important; float: right; }
235
+ .kg-video-js-skin .vjs-fullscreen-control div { width: 16px; height: 16px; background: url('kg-video-js-skin.png') -50px 0; margin: 0.5em auto 0; }
236
+
237
+ .kg-video-js-skin.vjs-fullscreen .vjs-fullscreen-control div { background: url('kg-video-js-skin.png') -75px 0; }
238
+
239
+
240
+ /* Big Play Button (at start)
241
+ ---------------------------------------------------------*/
242
+ .kg-video-js-skin .vjs-big-play-button {
243
+ display: block; /* Start hidden */ z-index: 2;
244
+ position: absolute; top: 50%; left: 50%; width: 8.0em; height: 8.0em; margin: -42px 0 0 -42px; text-align: center; vertical-align: center; cursor: pointer !important;
245
+ border: 0.8em solid #fff; opacity: 0.7;
246
+ -webkit-border-radius: 50px; -moz-border-radius: 50px; border-radius: 50px;
247
+
248
+ background: #454545;
249
+ background: -moz-linear-gradient(top, #454545 0%, #232323 50%, #161616 50%, #3f3f3f 100%);
250
+ background: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(0%,#454545), color-stop(50%,#232323), color-stop(50%,#161616), color-stop(100%,#3f3f3f));
251
+ background: -webkit-linear-gradient(top, #454545 0%,#232323 50%,#161616 50%,#3f3f3f 100%);
252
+ background: -o-linear-gradient(top, #454545 0%,#232323 50%,#161616 50%,#3f3f3f 100%);
253
+ background: -ms-linear-gradient(top, #454545 0%,#232323 50%,#161616 50%,#3f3f3f 100%);
254
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#454545', endColorstr='#3f3f3f',GradientType=0 );
255
+ background: linear-gradient(top, #454545 0%,#232323 50%,#161616 50%,#3f3f3f 100%);
256
+
257
+ }
258
+
259
+ .kg-video-js-skin div.vjs-big-play-button:hover {
260
+ opacity: 0.95;
261
+ }
262
+
263
+ .kg-video-js-skin div.vjs-big-play-button span {
264
+ position: absolute; top: 50%; left: 50%;
265
+ display: block; width: 35px; height: 42px;
266
+ margin: -20px 0 0 -15px; /* Using negative margin to center image. */
267
+ background: url('kg-video-js-skin.png') -100px 0;
268
+ }
269
+
270
+ /* Loading Spinner
271
+ ---------------------------------------------------------*/
272
+ /* CSS Spinners by Kilian Valkhof - http://kilianvalkhof.com/2010/css-xhtml/css3-loading-spinners-without-images/ */
273
+ .vjs-loading-spinner {
274
+ display: none;
275
+ position: absolute; top: 50%; left: 50%; width: 55px; height: 55px;
276
+ margin: -28px 0 0 -28px;
277
+ -webkit-animation-name: rotatethis;
278
+ -webkit-animation-duration:1s;
279
+ -webkit-animation-iteration-count:infinite;
280
+ -webkit-animation-timing-function:linear;
281
+ -moz-animation-name: rotatethis;
282
+ -moz-animation-duration:1s;
283
+ -moz-animation-iteration-count:infinite;
284
+ -moz-animation-timing-function:linear;
285
+ }
286
+
287
+ @-webkit-keyframes rotatethis {
288
+ 0% {-webkit-transform:scale(0.6) rotate(0deg); }
289
+ 12.5% {-webkit-transform:scale(0.6) rotate(0deg); }
290
+ 12.51% {-webkit-transform:scale(0.6) rotate(45deg); }
291
+ 25% {-webkit-transform:scale(0.6) rotate(45deg); }
292
+ 25.01% {-webkit-transform:scale(0.6) rotate(90deg);}
293
+ 37.5% {-webkit-transform:scale(0.6) rotate(90deg);}
294
+ 37.51% {-webkit-transform:scale(0.6) rotate(135deg);}
295
+ 50% {-webkit-transform:scale(0.6) rotate(135deg);}
296
+ 50.01% {-webkit-transform:scale(0.6) rotate(180deg);}
297
+ 62.5% {-webkit-transform:scale(0.6) rotate(180deg);}
298
+ 62.51% {-webkit-transform:scale(0.6) rotate(225deg);}
299
+ 75% {-webkit-transform:scale(0.6) rotate(225deg);}
300
+ 75.01% {-webkit-transform:scale(0.6) rotate(270deg);}
301
+ 87.5% {-webkit-transform:scale(0.6) rotate(270deg);}
302
+ 87.51% {-webkit-transform:scale(0.6) rotate(315deg);}
303
+ 100% {-webkit-transform:scale(0.6) rotate(315deg);}
304
+ }
305
+
306
+ @-moz-keyframes rotatethis {
307
+ 0% {-moz-transform:scale(0.6) rotate(0deg);}
308
+ 12.5% {-moz-transform:scale(0.6) rotate(0deg);}
309
+ 12.51% {-moz-transform:scale(0.6) rotate(45deg);}
310
+ 25% {-moz-transform:scale(0.6) rotate(45deg);}
311
+ 25.01% {-moz-transform:scale(0.6) rotate(90deg);}
312
+ 37.5% {-moz-transform:scale(0.6) rotate(90deg);}
313
+ 37.51% {-moz-transform:scale(0.6) rotate(135deg);}
314
+ 50% {-moz-transform:scale(0.6) rotate(135deg);}
315
+ 50.01% {-moz-transform:scale(0.6) rotate(180deg);}
316
+ 62.5% {-moz-transform:scale(0.6) rotate(180deg);}
317
+ 62.51% {-moz-transform:scale(0.6) rotate(225deg);}
318
+ 75% {-moz-transform:scale(0.6) rotate(225deg);}
319
+ 75.01% {-moz-transform:scale(0.6) rotate(270deg);}
320
+ 87.5% {-moz-transform:scale(0.6) rotate(270deg);}
321
+ 87.51% {-moz-transform:scale(0.6) rotate(315deg);}
322
+ 100% {-moz-transform:scale(0.6) rotate(315deg);}
323
+ }
324
+ /* Each circle */
325
+ div.vjs-loading-spinner .ball1 { opacity: 0.12; position:absolute; left: 20px; top: 0px; width: 13px; height: 13px; background: #fff;
326
+ border-radius: 13px; -webkit-border-radius: 13px; -moz-border-radius: 13px; border: 1px solid #ccc; }
327
+
328
+ div.vjs-loading-spinner .ball2 { opacity: 0.25; position:absolute; left: 34px; top: 6px; width: 13px; height: 13px; background: #fff;
329
+ border-radius: 13px; -webkit-border-radius: 13px; -moz-border-radius: 13px; border: 1px solid #ccc; }
330
+
331
+ div.vjs-loading-spinner .ball3 { opacity: 0.37; position:absolute; left: 40px; top: 20px; width: 13px; height: 13px; background: #fff;
332
+ border-radius: 13px; -webkit-border-radius: 13px; -moz-border-radius: 13px; border: 1px solid #ccc; }
333
+
334
+ div.vjs-loading-spinner .ball4 { opacity: 0.50; position:absolute; left: 34px; top: 34px; width: 13px; height: 13px; background: #fff;
335
+ border-radius: 10px; -webkit-border-radius: 10px; -moz-border-radius: 15px; border: 1px solid #ccc; }
336
+
337
+ div.vjs-loading-spinner .ball5 { opacity: 0.62; position:absolute; left: 20px; top: 40px; width: 13px; height: 13px; background: #fff;
338
+ border-radius: 13px; -webkit-border-radius: 13px; -moz-border-radius: 13px; border: 1px solid #ccc; }
339
+
340
+ div.vjs-loading-spinner .ball6 { opacity: 0.75; position:absolute; left: 6px; top: 34px; width: 13px; height: 13px; background: #fff;
341
+ border-radius: 13px; -webkit-border-radius: 13px; -moz-border-radius: 13px; border: 1px solid #ccc; }
342
+
343
+ div.vjs-loading-spinner .ball7 { opacity: 0.87; position:absolute; left: 0px; top: 20px; width: 13px; height: 13px; background: #fff;
344
+ border-radius: 13px; -webkit-border-radius: 13px; -moz-border-radius: 13px; border: 1px solid #ccc; }
345
+
346
+ div.vjs-loading-spinner .ball8 { opacity: 1.00; position:absolute; left: 6px; top: 6px; width: 13px; height: 13px; background: #fff;
347
+ border-radius: 13px; -webkit-border-radius: 13px; -moz-border-radius: 13px; border: 1px solid #ccc; }
348
+
349
+ /* Menu Buttons (Captions/Subtitles/etc.)
350
+ -------------------------------------------------------------------------------- */
351
+ .kg-video-js-skin .vjs-menu-button {
352
+ float: right; margin: 0.2em 0.5em 0 0; padding: 0; width: 3em; height: 2em; cursor: pointer !important;
353
+
354
+ border: 1px solid #111; -moz-border-radius: 0.3em; -webkit-border-radius: 0.3em; border-radius: 0.3em;
355
+
356
+ background: #4d4d4d;
357
+ background: -moz-linear-gradient(top, #4d4d4d 0%, #3f3f3f 50%, #333333 50%, #252525 100%);
358
+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#4d4d4d), color-stop(50%,#3f3f3f), color-stop(50%,#333333), color-stop(100%,#252525));
359
+ background: -webkit-linear-gradient(top, #4d4d4d 0%,#3f3f3f 50%,#333333 50%,#252525 100%);
360
+ background: -o-linear-gradient(top, #4d4d4d 0%,#3f3f3f 50%,#333333 50%,#252525 100%);
361
+ background: -ms-linear-gradient(top, #4d4d4d 0%,#3f3f3f 50%,#333333 50%,#252525 100%);
362
+ background: linear-gradient(top, #4d4d4d 0%,#3f3f3f 50%,#333333 50%,#252525 100%);
363
+ }
364
+ /* Button Icon */
365
+ .kg-video-js-skin .vjs-menu-button div { background: url('kg-video-js-skin.png') 0px -75px no-repeat; width: 16px; height: 16px; margin: 0.2em auto 0; padding: 0; }
366
+
367
+ /* Button Pop-up Menu */
368
+ .kg-video-js-skin .vjs-menu-button ul {
369
+ display: none; /* Start hidden. Hover will show. */
370
+ opacity: 0.8;
371
+ padding: 0; margin: 0;
372
+ position: absolute; width: 10em; bottom: 2em; max-height: 15em;
373
+ left: -3.5em; /* Width of menu - width of button / 2 */
374
+ background-color: #111;
375
+ border: 2px solid #333;
376
+ -moz-border-radius: 0.7em; -webkit-border-radius: 1em; border-radius: .5em;
377
+ -webkit-box-shadow: 0 2px 4px 0 #000; -moz-box-shadow: 0 2px 4px 0 #000; box-shadow: 0 2px 4px 0 #000;
378
+ overflow: auto;
379
+ }
380
+
381
+ .kg-video-js-skin .vjs-menu-button:focus ul,
382
+ .kg-video-js-skin .vjs-menu-button:hover ul { display: block; list-style: none; }
383
+ .kg-video-js-skin .vjs-menu-button ul li { list-style: none; margin: 0; padding: 0.3em 0 0.3em 20px; line-height: 1.4em; font-size: 1.2em; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; text-align: left; }
384
+ .kg-video-js-skin .vjs-menu-button ul li.vjs-selected { text-decoration: underline; background: url('kg-video-js-skin.png') -125px -50px no-repeat; }
385
+ .kg-video-js-skin .vjs-menu-button ul li:focus,
386
+ .kg-video-js-skin .vjs-menu-button ul li:hover,
387
+ .kg-video-js-skin .vjs-menu-button ul li.vjs-selected:focus,
388
+ .kg-video-js-skin .vjs-menu-button ul li.vjs-selected:hover { background-color: #ccc; color: #111; outline: 0; }
389
+ .kg-video-js-skin .vjs-menu-button ul li.vjs-menu-title {
390
+ text-align: center; text-transform: uppercase; font-size: 1em; line-height: 2em; padding: 0; margin: 0 0 0.3em 0;
391
+
392
+ color: #fff; font-weight: bold;
393
+
394
+ cursor: default;
395
+
396
+ background: #4d4d4d;
397
+ background: -moz-linear-gradient(top, #4d4d4d 0%, #3f3f3f 50%, #333333 50%, #252525 100%);
398
+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#4d4d4d), color-stop(50%,#3f3f3f), color-stop(50%,#333333), color-stop(100%,#252525));
399
+ background: -webkit-linear-gradient(top, #4d4d4d 0%,#3f3f3f 50%,#333333 50%,#252525 100%);
400
+ background: -o-linear-gradient(top, #4d4d4d 0%,#3f3f3f 50%,#333333 50%,#252525 100%);
401
+ background: -ms-linear-gradient(top, #4d4d4d 0%,#3f3f3f 50%,#333333 50%,#252525 100%);
402
+ background: linear-gradient(top, #4d4d4d 0%,#3f3f3f 50%,#333333 50%,#252525 100%);
403
+ }
404
+
405
+ /* Subtitles Button */
406
+ .kg-video-js-skin .vjs-captions-button div { background-position: -25px -75px; }
407
+ .kg-video-js-skin .vjs-chapters-button div { background-position: -100px -75px; }
408
+ .kg-video-js-skin .vjs-chapters-button ul { width: 20em; left: -8.5em; /* Width of menu - width of button / 2 */ }
video-js/kg-video-js-skin.png ADDED
Binary file
video-js/video-js.css ADDED
@@ -0,0 +1 @@
 
1
+ .video-js{background-color:#000;position:relative;padding:0;font-size:10px;vertical-align:middle}.video-js .vjs-tech{position:absolute;top:0;left:0;width:100%;height:100%}.video-js:-moz-full-screen{position:absolute}body.vjs-full-window{padding:0;margin:0;height:100%;overflow-y:auto}.video-js.vjs-fullscreen{position:fixed;overflow:hidden;z-index:1000;left:0;top:0;bottom:0;right:0;width:100%!important;height:100%!important;_position:absolute}.video-js:-webkit-full-screen{width:100%!important;height:100%!important}.vjs-poster{margin:0 auto;padding:0;cursor:pointer;position:relative;width:100%;max-height:100%}.video-js .vjs-text-track-display{text-align:center;position:absolute;bottom:4em;left:1em;right:1em;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif}.video-js .vjs-text-track{display:none;color:#fff;font-size:1.4em;text-align:center;margin-bottom:.1em;background:#000;background:rgba(0,0,0,0.50)}.video-js .vjs-subtitles{color:#fff}.video-js .vjs-captions{color:#fc6}.vjs-tt-cue{display:block}.vjs-fade-in{visibility:visible!important;opacity:1!important;-webkit-transition:visibility 0s linear 0s,opacity .3s linear;-moz-transition:visibility 0s linear 0s,opacity .3s linear;-ms-transition:visibility 0s linear 0s,opacity .3s linear;-o-transition:visibility 0s linear 0s,opacity .3s linear;transition:visibility 0s linear 0s,opacity .3s linear}.vjs-fade-out{visibility:hidden!important;opacity:0!important;-webkit-transition:visibility 0s linear 1.5s,opacity 1.5s linear;-moz-transition:visibility 0s linear 1.5s,opacity 1.5s linear;-ms-transition:visibility 0s linear 1.5s,opacity 1.5s linear;-o-transition:visibility 0s linear 1.5s,opacity 1.5s linear;transition:visibility 0s linear 1.5s,opacity 1.5s linear}.vjs-default-skin .vjs-controls{position:absolute;bottom:0;left:0;right:0;margin:0;padding:0;height:2.6em;color:#fff;border-top:1px solid #404040;background:#242424;background:-moz-linear-gradient(top,#242424 50%,#1f1f1f 50%,#171717 100%);background:-webkit-gradient(linear,0% 0,0% 100%,color-stop(50%,#242424),color-stop(50%,#1f1f1f),color-stop(100%,#171717));background:-webkit-linear-gradient(top,#242424 50%,#1f1f1f 50%,#171717 100%);background:-o-linear-gradient(top,#242424 50%,#1f1f1f 50%,#171717 100%);background:-ms-linear-gradient(top,#242424 50%,#1f1f1f 50%,#171717 100%);background:linear-gradient(top,#242424 50%,#1f1f1f 50%,#171717 100%);visibility:hidden;opacity:0}.vjs-default-skin .vjs-control{position:relative;float:left;text-align:center;margin:0;padding:0;height:2.6em;width:2.6em}.vjs-default-skin .vjs-control:focus{outline:0}.vjs-default-skin .vjs-control-text{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.vjs-default-skin .vjs-play-control{width:5em;cursor:pointer!important}.vjs-default-skin.vjs-paused .vjs-play-control div{width:15px;height:17px;background:url('video-js.png');margin:.5em auto 0}.vjs-default-skin.vjs-playing .vjs-play-control div{width:15px;height:17px;background:url('video-js.png') -25px 0;margin:.5em auto 0}.vjs-default-skin .vjs-rewind-control{width:5em;cursor:pointer!important}.vjs-default-skin .vjs-rewind-control div{width:19px;height:16px;background:url('video-js.png');margin:.5em auto 0}.vjs-default-skin .vjs-mute-control{width:3.8em;cursor:pointer!important;float:right}.vjs-default-skin .vjs-mute-control div{width:22px;height:16px;background:url('video-js.png') -75px -25px;margin:.5em auto 0}.vjs-default-skin .vjs-mute-control.vjs-vol-0 div{background:url('video-js.png') 0 -25px}.vjs-default-skin .vjs-mute-control.vjs-vol-1 div{background:url('video-js.png') -25px -25px}.vjs-default-skin .vjs-mute-control.vjs-vol-2 div{background:url('video-js.png') -50px -25px}.vjs-default-skin .vjs-volume-control{width:5em;float:right}.vjs-default-skin .vjs-volume-bar{position:relative;width:5em;height:.6em;margin:1em auto 0;cursor:pointer!important;-moz-border-radius:.3em;-webkit-border-radius:.3em;border-radius:.3em;background:#666;background:-moz-linear-gradient(top,#333,#666);background:-webkit-gradient(linear,0% 0,0% 100%,from(#333),to(#666));background:-webkit-linear-gradient(top,#333,#666);background:-o-linear-gradient(top,#333,#666);background:-ms-linear-gradient(top,#333,#666);background:linear-gradient(top,#333,#666)}.vjs-default-skin .vjs-volume-level{position:absolute;top:0;left:0;height:.6em;-moz-border-radius:.3em;-webkit-border-radius:.3em;border-radius:.3em;background:#fff;background:-moz-linear-gradient(top,#fff,#ccc);background:-webkit-gradient(linear,0% 0,0% 100%,from(#fff),to(#ccc));background:-webkit-linear-gradient(top,#fff,#ccc);background:-o-linear-gradient(top,#fff,#ccc);background:-ms-linear-gradient(top,#fff,#ccc);background:linear-gradient(top,#fff,#ccc)}.vjs-default-skin .vjs-volume-handle{position:absolute;top:-0.2em;width:.8em;height:.8em;background:#ccc;left:0;border:1px solid #fff;-moz-border-radius:.6em;-webkit-border-radius:.6em;border-radius:.6em}.vjs-default-skin div.vjs-progress-control{position:absolute;left:4.8em;right:4.8em;height:1.0em;width:auto;top:-1.3em;border-bottom:1px solid #1f1f1f;border-top:1px solid #222;background:#333;background:-moz-linear-gradient(top,#222,#333);background:-webkit-gradient(linear,0% 0,0% 100%,from(#222),to(#333));background:-webkit-linear-gradient(top,#222,#333);background:-o-linear-gradient(top,#333,#222);background:-ms-linear-gradient(top,#333,#222);background:linear-gradient(top,#333,#222)}.vjs-default-skin .vjs-progress-holder{position:relative;cursor:pointer!important;padding:0;margin:0;height:1.0em;-moz-border-radius:.6em;-webkit-border-radius:.6em;border-radius:.6em;background:#111;background:-moz-linear-gradient(top,#111,#262626);background:-webkit-gradient(linear,0% 0,0% 100%,from(#111),to(#262626));background:-webkit-linear-gradient(top,#111,#262626);background:-o-linear-gradient(top,#111,#262626);background:-ms-linear-gradient(top,#111,#262626);background:linear-gradient(top,#111,#262626)}.vjs-default-skin .vjs-progress-holder .vjs-play-progress,.vjs-default-skin .vjs-progress-holder .vjs-load-progress{position:absolute;display:block;height:1.0em;margin:0;padding:0;left:0;top:0;-moz-border-radius:.6em;-webkit-border-radius:.6em;border-radius:.6em}.vjs-default-skin .vjs-play-progress{background:#fff;background:-moz-linear-gradient(top,#fff 0,#d6d6d6 50%,#fff 100%);background:-webkit-gradient(linear,0% 0,0% 100%,color-stop(0%,#fff),color-stop(50%,#d6d6d6),color-stop(100%,#fff));background:-webkit-linear-gradient(top,#fff 0,#d6d6d6 50%,#fff 100%);background:-o-linear-gradient(top,#fff 0,#d6d6d6 50%,#fff 100%);background:-ms-linear-gradient(top,#fff 0,#d6d6d6 50%,#fff 100%);background:linear-gradient(top,#fff 0,#d6d6d6 50%,#fff 100%);background:#efefef;background:-moz-linear-gradient(top,#efefef 0,#f5f5f5 50%,#dbdbdb 50%,#f1f1f1 100%);background:-webkit-gradient(linear,0% 0,0% 100%,color-stop(0%,#efefef),color-stop(50%,#f5f5f5),color-stop(50%,#dbdbdb),color-stop(100%,#f1f1f1));background:-webkit-linear-gradient(top,#efefef 0,#f5f5f5 50%,#dbdbdb 50%,#f1f1f1 100%);background:-o-linear-gradient(top,#efefef 0,#f5f5f5 50%,#dbdbdb 50%,#f1f1f1 100%);background:-ms-linear-gradient(top,#efefef 0,#f5f5f5 50%,#dbdbdb 50%,#f1f1f1 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#efefef',endColorstr='#f1f1f1',GradientType=0);background:linear-gradient(top,#efefef 0,#f5f5f5 50%,#dbdbdb 50%,#f1f1f1 100%)}.vjs-default-skin .vjs-load-progress{opacity:.8;background:#666;background:-moz-linear-gradient(top,#666,#333);background:-webkit-gradient(linear,0% 0,0% 100%,from(#666),to(#333));background:-webkit-linear-gradient(top,#666,#333);background:-o-linear-gradient(top,#666,#333);background:-ms-linear-gradient(top,#666,#333);background:linear-gradient(top,#666,#333)}.vjs-default-skin div.vjs-seek-handle{position:absolute;width:16px;height:16px;margin-top:-0.3em;left:0;top:0;background:url('video-js.png') 0 -50px;-moz-border-radius:.8em;-webkit-border-radius:.8em;border-radius:.8em;-webkit-box-shadow:0 2px 4px 0 #000;-moz-box-shadow:0 2px 4px 0 #000;box-shadow:0 2px 4px 0 #000}.vjs-default-skin .vjs-time-controls{position:absolute;right:0;height:1.0em;width:4.8em;top:-1.3em;border-bottom:1px solid #1f1f1f;border-top:1px solid #222;background-color:#333;font-size:1em;line-height:1.0em;font-weight:normal;font-family:Helvetica,Arial,sans-serif;background:#333;background:-moz-linear-gradient(top,#222,#333);background:-webkit-gradient(linear,0% 0,0% 100%,from(#222),to(#333));background:-webkit-linear-gradient(top,#222,#333);background:-o-linear-gradient(top,#333,#222);background:-ms-linear-gradient(top,#333,#222);background:linear-gradient(top,#333,#222)}.vjs-default-skin .vjs-current-time{left:0}.vjs-default-skin .vjs-duration{right:0;display:none}.vjs-default-skin .vjs-remaining-time{right:0}.vjs-time-divider{display:none}.vjs-default-skin .vjs-time-control{font-size:1em;line-height:1;font-weight:normal;font-family:Helvetica,Arial,sans-serif}.vjs-default-skin .vjs-time-control span{line-height:25px}.vjs-secondary-controls{float:right}.vjs-default-skin .vjs-fullscreen-control{width:3.8em;cursor:pointer!important;float:right}.vjs-default-skin .vjs-fullscreen-control div{width:16px;height:16px;background:url('video-js.png') -50px 0;margin:.5em auto 0}.vjs-default-skin.vjs-fullscreen .vjs-fullscreen-control div{background:url('video-js.png') -75px 0}.vjs-default-skin .vjs-big-play-button{display:block;z-index:2;position:absolute;top:50%;left:50%;width:8.0em;height:8.0em;margin:-42px 0 0 -42px;text-align:center;vertical-align:center;cursor:pointer!important;border:.2em solid #fff;opacity:.95;-webkit-border-radius:25px;-moz-border-radius:25px;border-radius:25px;background:#454545;background:-moz-linear-gradient(top,#454545 0,#232323 50%,#161616 50%,#3f3f3f 100%);background:-webkit-gradient(linear,0% 0,0% 100%,color-stop(0%,#454545),color-stop(50%,#232323),color-stop(50%,#161616),color-stop(100%,#3f3f3f));background:-webkit-linear-gradient(top,#454545 0,#232323 50%,#161616 50%,#3f3f3f 100%);background:-o-linear-gradient(top,#454545 0,#232323 50%,#161616 50%,#3f3f3f 100%);background:-ms-linear-gradient(top,#454545 0,#232323 50%,#161616 50%,#3f3f3f 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#454545',endColorstr='#3f3f3f',GradientType=0);background:linear-gradient(top,#454545 0,#232323 50%,#161616 50%,#3f3f3f 100%);-webkit-box-shadow:4px 4px 8px #000;-moz-box-shadow:4px 4px 8px #000;box-shadow:4px 4px 8px #000}.vjs-default-skin div.vjs-big-play-button:hover{-webkit-box-shadow:0 0 80px #fff;-moz-box-shadow:0 0 80px #fff;box-shadow:0 0 80px #fff}.vjs-default-skin div.vjs-big-play-button span{position:absolute;top:50%;left:50%;display:block;width:35px;height:42px;margin:-20px 0 0 -15px;background:url('video-js.png') -100px 0}.vjs-loading-spinner{display:none;position:absolute;top:50%;left:50%;width:55px;height:55px;margin:-28px 0 0 -28px;-webkit-animation-name:rotatethis;-webkit-animation-duration:1s;-webkit-animation-iteration-count:infinite;-webkit-animation-timing-function:linear;-moz-animation-name:rotatethis;-moz-animation-duration:1s;-moz-animation-iteration-count:infinite;-moz-animation-timing-function:linear}@-webkit-keyframes rotatethis{0%{-webkit-transform:scale(0.6) rotate(0deg)}12.5%{-webkit-transform:scale(0.6) rotate(0deg)}12.51%{-webkit-transform:scale(0.6) rotate(45deg)}25%{-webkit-transform:scale(0.6) rotate(45deg)}25.01%{-webkit-transform:scale(0.6) rotate(90deg)}37.5%{-webkit-transform:scale(0.6) rotate(90deg)}37.51%{-webkit-transform:scale(0.6) rotate(135deg)}50%{-webkit-transform:scale(0.6) rotate(135deg)}50.01%{-webkit-transform:scale(0.6) rotate(180deg)}62.5%{-webkit-transform:scale(0.6) rotate(180deg)}62.51%{-webkit-transform:scale(0.6) rotate(225deg)}75%{-webkit-transform:scale(0.6) rotate(225deg)}75.01%{-webkit-transform:scale(0.6) rotate(270deg)}87.5%{-webkit-transform:scale(0.6) rotate(270deg)}87.51%{-webkit-transform:scale(0.6) rotate(315deg)}100%{-webkit-transform:scale(0.6) rotate(315deg)}}@-moz-keyframes rotatethis{0%{-moz-transform:scale(0.6) rotate(0deg)}12.5%{-moz-transform:scale(0.6) rotate(0deg)}12.51%{-moz-transform:scale(0.6) rotate(45deg)}25%{-moz-transform:scale(0.6) rotate(45deg)}25.01%{-moz-transform:scale(0.6) rotate(90deg)}37.5%{-moz-transform:scale(0.6) rotate(90deg)}37.51%{-moz-transform:scale(0.6) rotate(135deg)}50%{-moz-transform:scale(0.6) rotate(135deg)}50.01%{-moz-transform:scale(0.6) rotate(180deg)}62.5%{-moz-transform:scale(0.6) rotate(180deg)}62.51%{-moz-transform:scale(0.6) rotate(225deg)}75%{-moz-transform:scale(0.6) rotate(225deg)}75.01%{-moz-transform:scale(0.6) rotate(270deg)}87.5%{-moz-transform:scale(0.6) rotate(270deg)}87.51%{-moz-transform:scale(0.6) rotate(315deg)}100%{-moz-transform:scale(0.6) rotate(315deg)}}div.vjs-loading-spinner .ball1{opacity:.12;position:absolute;left:20px;top:0;width:13px;height:13px;background:#fff;border-radius:13px;-webkit-border-radius:13px;-moz-border-radius:13px;border:1px solid #ccc}div.vjs-loading-spinner .ball2{opacity:.25;position:absolute;left:34px;top:6px;width:13px;height:13px;background:#fff;border-radius:13px;-webkit-border-radius:13px;-moz-border-radius:13px;border:1px solid #ccc}div.vjs-loading-spinner .ball3{opacity:.37;position:absolute;left:40px;top:20px;width:13px;height:13px;background:#fff;border-radius:13px;-webkit-border-radius:13px;-moz-border-radius:13px;border:1px solid #ccc}div.vjs-loading-spinner .ball4{opacity:.50;position:absolute;left:34px;top:34px;width:13px;height:13px;background:#fff;border-radius:10px;-webkit-border-radius:10px;-moz-border-radius:15px;border:1px solid #ccc}div.vjs-loading-spinner .ball5{opacity:.62;position:absolute;left:20px;top:40px;width:13px;height:13px;background:#fff;border-radius:13px;-webkit-border-radius:13px;-moz-border-radius:13px;border:1px solid #ccc}div.vjs-loading-spinner .ball6{opacity:.75;position:absolute;left:6px;top:34px;width:13px;height:13px;background:#fff;border-radius:13px;-webkit-border-radius:13px;-moz-border-radius:13px;border:1px solid #ccc}div.vjs-loading-spinner .ball7{opacity:.87;position:absolute;left:0;top:20px;width:13px;height:13px;background:#fff;border-radius:13px;-webkit-border-radius:13px;-moz-border-radius:13px;border:1px solid #ccc}div.vjs-loading-spinner .ball8{opacity:1.00;position:absolute;left:6px;top:6px;width:13px;height:13px;background:#fff;border-radius:13px;-webkit-border-radius:13px;-moz-border-radius:13px;border:1px solid #ccc}.vjs-default-skin .vjs-menu-button{float:right;margin:.2em .5em 0 0;padding:0;width:3em;height:2em;cursor:pointer!important;border:1px solid #111;-moz-border-radius:.3em;-webkit-border-radius:.3em;border-radius:.3em;background:#4d4d4d;background:-moz-linear-gradient(top,#4d4d4d 0,#3f3f3f 50%,#333 50%,#252525 100%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#4d4d4d),color-stop(50%,#3f3f3f),color-stop(50%,#333),color-stop(100%,#252525));background:-webkit-linear-gradient(top,#4d4d4d 0,#3f3f3f 50%,#333 50%,#252525 100%);background:-o-linear-gradient(top,#4d4d4d 0,#3f3f3f 50%,#333 50%,#252525 100%);background:-ms-linear-gradient(top,#4d4d4d 0,#3f3f3f 50%,#333 50%,#252525 100%);background:linear-gradient(top,#4d4d4d 0,#3f3f3f 50%,#333 50%,#252525 100%)}.vjs-default-skin .vjs-menu-button div{background:url('video-js.png') 0 -75px no-repeat;width:16px;height:16px;margin:.2em auto 0;padding:0}.vjs-default-skin .vjs-menu-button ul{display:none;opacity:.8;padding:0;margin:0;position:absolute;width:10em;bottom:2em;max-height:15em;left:-3.5em;background-color:#111;border:2px solid #333;-moz-border-radius:.7em;-webkit-border-radius:1em;border-radius:.5em;-webkit-box-shadow:0 2px 4px 0 #000;-moz-box-shadow:0 2px 4px 0 #000;box-shadow:0 2px 4px 0 #000;overflow:auto}.vjs-default-skin .vjs-menu-button:focus ul,.vjs-default-skin .vjs-menu-button:hover ul{display:block;list-style:none}.vjs-default-skin .vjs-menu-button ul li{list-style:none;margin:0;padding:.3em 0 .3em 20px;line-height:1.4em;font-size:1.2em;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;text-align:left}.vjs-default-skin .vjs-menu-button ul li.vjs-selected{text-decoration:underline;background:url('video-js.png') -125px -50px no-repeat}.vjs-default-skin .vjs-menu-button ul li:focus,.vjs-default-skin .vjs-menu-button ul li:hover,.vjs-default-skin .vjs-menu-button ul li.vjs-selected:focus,.vjs-default-skin .vjs-menu-button ul li.vjs-selected:hover{background-color:#ccc;color:#111;outline:0}.vjs-default-skin .vjs-menu-button ul li.vjs-menu-title{text-align:center;text-transform:uppercase;font-size:1em;line-height:2em;padding:0;margin:0 0 .3em 0;color:#fff;font-weight:bold;cursor:default;background:#4d4d4d;background:-moz-linear-gradient(top,#4d4d4d 0,#3f3f3f 50%,#333 50%,#252525 100%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#4d4d4d),color-stop(50%,#3f3f3f),color-stop(50%,#333),color-stop(100%,#252525));background:-webkit-linear-gradient(top,#4d4d4d 0,#3f3f3f 50%,#333 50%,#252525 100%);background:-o-linear-gradient(top,#4d4d4d 0,#3f3f3f 50%,#333 50%,#252525 100%);background:-ms-linear-gradient(top,#4d4d4d 0,#3f3f3f 50%,#333 50%,#252525 100%);background:linear-gradient(top,#4d4d4d 0,#3f3f3f 50%,#333 50%,#252525 100%)}.vjs-default-skin .vjs-captions-button div{background-position:-25px -75px}.vjs-default-skin .vjs-chapters-button div{background-position:-100px -75px}.vjs-default-skin .vjs-chapters-button ul{width:20em;left:-8.5em}
video-js/video-js.png ADDED
Binary file
video-js/video-js.swf ADDED
Binary file
video-js/video.js ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*!
2
+ Video.js - HTML5 Video Player
3
+ Version 3.2.0
4
+
5
+ LGPL v3 LICENSE INFO
6
+ This file is part of Video.js. Copyright 2011 Zencoder, Inc.
7
+
8
+ Video.js is free software: you can redistribute it and/or modify
9
+ it under the terms of the GNU Lesser General Public License as published by
10
+ the Free Software Foundation, either version 3 of the License, or
11
+ (at your option) any later version.
12
+
13
+ Video.js is distributed in the hope that it will be useful,
14
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ GNU Lesser General Public License for more details.
17
+
18
+ You should have received a copy of the GNU Lesser General Public License
19
+ along with Video.js. If not, see <http://www.gnu.org/licenses/>.
20
+ */
21
+ (function(window,undefined){var document=window.document;document.createElement("video");document.createElement("audio");var VideoJS=function(id,addOptions,ready){var tag;if(typeof id=="string"){if(id.indexOf("#")===0){id=id.slice(1)}if(_V_.players[id]){return _V_.players[id]}else{tag=_V_.el(id)}}else{tag=id}if(!tag||!tag.nodeName){throw new TypeError("The element or ID supplied is not valid. (VideoJS)")}return tag.player||new _V_.Player(tag,addOptions,ready)},_V_=VideoJS,CDN_VERSION="3.2";VideoJS.players={};VideoJS.options={techOrder:["html5","flash"],html5:{},flash:{swf:"http://vjs.zencdn.net/c/video-js.swf"},width:"auto",height:"auto",defaultVolume:0,components:{posterImage:{},textTrackDisplay:{},loadingSpinner:{},bigPlayButton:{},controlBar:{}}};if(CDN_VERSION!="GENERATED_CDN_VSN"){_V_.options.flash.swf="http://vjs.zencdn.net/"+CDN_VERSION+"/video-js.swf"}_V_.merge=function(obj1,obj2,safe){if(!obj2){obj2={}}for(var attrname in obj2){if(obj2.hasOwnProperty(attrname)&&(!safe||!obj1.hasOwnProperty(attrname))){obj1[attrname]=obj2[attrname]}}return obj1};_V_.extend=function(obj){this.merge(this,obj,true)};_V_.extend({tech:{},controlSets:{},isIE:function(){return !+"\v1"},isFF:function(){return !!_V_.ua.match("Firefox")},isIPad:function(){return navigator.userAgent.match(/iPad/i)!==null},isIPhone:function(){return navigator.userAgent.match(/iPhone/i)!==null},isIOS:function(){return VideoJS.isIPhone()||VideoJS.isIPad()},iOSVersion:function(){var match=navigator.userAgent.match(/OS (\d+)_/i);if(match&&match[1]){return match[1]}},isAndroid:function(){return navigator.userAgent.match(/Android.*AppleWebKit/i)!==null},androidVersion:function(){var match=navigator.userAgent.match(/Android (\d+)\./i);if(match&&match[1]){return match[1]}},testVid:document.createElement("video"),ua:navigator.userAgent,support:{},each:function(arr,fn){if(!arr||arr.length===0){return}for(var i=0,j=arr.length;i<j;i++){fn.call(this,arr[i],i)}},eachProp:function(obj,fn){if(!obj){return}for(var name in obj){if(obj.hasOwnProperty(name)){fn.call(this,name,obj[name])}}},el:function(id){return document.getElementById(id)},createElement:function(tagName,attributes){var el=document.createElement(tagName),attrname;for(attrname in attributes){if(attributes.hasOwnProperty(attrname)){if(attrname.indexOf("-")!==-1){el.setAttribute(attrname,attributes[attrname])}else{el[attrname]=attributes[attrname]}}}return el},insertFirst:function(node,parent){if(parent.firstChild){parent.insertBefore(node,parent.firstChild)}else{parent.appendChild(node)}},addClass:function(element,classToAdd){if((" "+element.className+" ").indexOf(" "+classToAdd+" ")==-1){element.className=element.className===""?classToAdd:element.className+" "+classToAdd}},removeClass:function(element,classToRemove){if(element.className.indexOf(classToRemove)==-1){return}var classNames=element.className.split(" ");classNames.splice(classNames.indexOf(classToRemove),1);element.className=classNames.join(" ")},remove:function(item,array){if(!array){return}var i=array.indexOf(item);if(i!=-1){return array.splice(i,1)}},blockTextSelection:function(){document.body.focus();document.onselectstart=function(){return false}},unblockTextSelection:function(){document.onselectstart=function(){return true}},formatTime:function(seconds,guide){guide=guide||seconds;var s=Math.floor(seconds%60),m=Math.floor(seconds/60%60),h=Math.floor(seconds/3600),gm=Math.floor(guide/60%60),gh=Math.floor(guide/3600);h=(h>0||gh>0)?h+":":"";m=(((h||gm>=10)&&m<10)?"0"+m:m)+":";s=(s<10)?"0"+s:s;return h+m+s},uc:function(string){return string.charAt(0).toUpperCase()+string.slice(1)},getRelativePosition:function(x,relativeElement){return Math.max(0,Math.min(1,(x-_V_.findPosX(relativeElement))/relativeElement.offsetWidth))},getComputedStyleValue:function(element,style){return window.getComputedStyle(element,null).getPropertyValue(style)},trim:function(string){return string.toString().replace(/^\s+/,"").replace(/\s+$/,"")},round:function(num,dec){if(!dec){dec=0}return Math.round(num*Math.pow(10,dec))/Math.pow(10,dec)},isEmpty:function(object){for(var prop in object){return false}return true},createTimeRange:function(start,end){return{length:1,start:function(){return start},end:function(){return end}}},cache:{},guid:1,expando:"vdata"+(new Date).getTime(),getData:function(elem){var id=elem[_V_.expando];if(!id){id=elem[_V_.expando]=_V_.guid++;_V_.cache[id]={}}return _V_.cache[id]},removeData:function(elem){var id=elem[_V_.expando];if(!id){return}delete _V_.cache[id];try{delete elem[_V_.expando]}catch(e){if(elem.removeAttribute){elem.removeAttribute(_V_.expando)}else{elem[_V_.expando]=null}}},proxy:function(context,fn,uid){if(!fn.guid){fn.guid=_V_.guid++}var ret=function(){return fn.apply(context,arguments)};ret.guid=(uid)?uid+"_"+fn.guid:fn.guid;return ret},get:function(url,onSuccess,onError){var local=(url.indexOf("file:")==0||(window.location.href.indexOf("file:")==0&&url.indexOf("http:")==-1));if(typeof XMLHttpRequest=="undefined"){XMLHttpRequest=function(){try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(e){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(f){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(g){}throw new Error("This browser does not support XMLHttpRequest.")}}var request=new XMLHttpRequest();try{request.open("GET",url)}catch(e){_V_.log("VideoJS XMLHttpRequest (open)",e);return false}request.onreadystatechange=_V_.proxy(this,function(){if(request.readyState==4){if(request.status==200||local&&request.status==0){onSuccess(request.responseText)}else{if(onError){onError()}}}});try{request.send()}catch(e){_V_.log("VideoJS XMLHttpRequest (send)",e);if(onError){onError(e)}}},setLocalStorage:function(key,value){var localStorage=window.localStorage||false;if(!localStorage){return}try{localStorage[key]=value}catch(e){if(e.code==22||e.code==1014){_V_.log("LocalStorage Full (VideoJS)",e)}else{_V_.log("LocalStorage Error (VideoJS)",e)}}},getAbsoluteURL:function(url){if(!url.match(/^https?:\/\//)){url=_V_.createElement("div",{innerHTML:'<a href="'+url+'">x</a>'}).firstChild.href}return url}});_V_.log=function(){_V_.log.history=_V_.log.history||[];_V_.log.history.push(arguments);if(window.console){arguments.callee=arguments.callee.caller;var newarr=[].slice.call(arguments);(typeof console.log==="object"?_V_.log.apply.call(console.log,console,newarr):console.log.apply(console,newarr))}};(function(b){function c(){}for(var d="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,timeStamp,profile,profileEnd,time,timeEnd,trace,warn".split(","),a;a=d.pop();){b[a]=b[a]||c}})((function(){try{console.log();return window.console}catch(err){return window.console={}}})());if("getBoundingClientRect" in document.documentElement){_V_.findPosX=function(el){var box;try{box=el.getBoundingClientRect()}catch(e){}if(!box){return 0}var docEl=document.documentElement,body=document.body,clientLeft=docEl.clientLeft||body.clientLeft||0,scrollLeft=window.pageXOffset||body.scrollLeft,left=box.left+scrollLeft-clientLeft;return left}}else{_V_.findPosX=function(el){var curleft=el.offsetLeft;while(el=obj.offsetParent){if(el.className.indexOf("video-js")==-1){}else{}curleft+=el.offsetLeft}return curleft}}(function(){var initializing=false,fnTest=/xyz/.test(function(){xyz})?/\b_super\b/:/.*/;_V_.Class=function(){};_V_.Class.extend=function(prop){var _super=this.prototype;initializing=true;var prototype=new this();initializing=false;for(var name in prop){prototype[name]=typeof prop[name]=="function"&&typeof _super[name]=="function"&&fnTest.test(prop[name])?(function(name,fn){return function(){var tmp=this._super;this._super=_super[name];var ret=fn.apply(this,arguments);this._super=tmp;return ret}})(name,prop[name]):prop[name]}function Class(){if(!initializing&&this.init){return this.init.apply(this,arguments)}else{if(!initializing){return arguments.callee.prototype.init()}}}Class.prototype=prototype;Class.constructor=Class;Class.extend=arguments.callee;return Class}})();_V_.Component=_V_.Class.extend({init:function(player,options){this.player=player;options=this.options=_V_.merge(this.options||{},options);if(options.el){this.el=options.el}else{this.el=this.createElement()}this.initComponents()},destroy:function(){},createElement:function(type,attrs){return _V_.createElement(type||"div",attrs)},buildCSSClass:function(){return""},initComponents:function(){var options=this.options;if(options&&options.components){this.eachProp(options.components,function(name,opts){var tempAdd=this.proxy(function(){this[name]=this.addComponent(name,opts)});if(opts.loadEvent){this.one(opts.loadEvent,tempAdd)}else{tempAdd()}})}},addComponent:function(name,options){var component,componentClass;if(typeof name=="string"){options=options||{};componentClass=options.componentClass||_V_.uc(name);component=new _V_[componentClass](this.player||this,options)}else{component=name}this.el.appendChild(component.el);return component},removeComponent:function(component){this.el.removeChild(component.el)},show:function(){this.el.style.display="block"},hide:function(){this.el.style.display="none"},fadeIn:function(){this.removeClass("vjs-fade-out");this.addClass("vjs-fade-in")},fadeOut:function(){this.removeClass("vjs-fade-in");this.addClass("vjs-fade-out")},lockShowing:function(){var style=this.el.style;style.display="block";style.opacity=1;style.visiblity="visible"},unlockShowing:function(){var style=this.el.style;style.display="";style.opacity="";style.visiblity=""},addClass:function(classToAdd){_V_.addClass(this.el,classToAdd)},removeClass:function(classToRemove){_V_.removeClass(this.el,classToRemove)},addEvent:function(type,fn,uid){return _V_.addEvent(this.el,type,_V_.proxy(this,fn))},removeEvent:function(type,fn){return _V_.removeEvent(this.el,type,fn)},triggerEvent:function(type,e){return _V_.triggerEvent(this.el,type,e)},one:function(type,fn){_V_.one(this.el,type,_V_.proxy(this,fn))},ready:function(fn){if(!fn){return this}if(this.isReady){fn.call(this)}else{if(this.readyQueue===undefined){this.readyQueue=[]}this.readyQueue.push(fn)}return this},triggerReady:function(){this.isReady=true;if(this.readyQueue&&this.readyQueue.length>0){this.each(this.readyQueue,function(fn){fn.call(this)});this.readyQueue=[];this.triggerEvent("ready")}},each:function(arr,fn){_V_.each.call(this,arr,fn)},eachProp:function(obj,fn){_V_.eachProp.call(this,obj,fn)},extend:function(obj){_V_.merge(this,obj)},proxy:function(fn,uid){return _V_.proxy(this,fn,uid)}});_V_.Control=_V_.Component.extend({buildCSSClass:function(){return"vjs-control "+this._super()}});_V_.ControlBar=_V_.Component.extend({options:{loadEvent:"play",components:{playToggle:{},fullscreenToggle:{},currentTimeDisplay:{},timeDivider:{},durationDisplay:{},remainingTimeDisplay:{},progressControl:{},volumeControl:{},muteToggle:{}}},init:function(player,options){this._super(player,options);player.addEvent("play",this.proxy(function(){this.fadeIn();this.player.addEvent("mouseover",this.proxy(this.fadeIn));this.player.addEvent("mouseout",this.proxy(this.fadeOut))}))},createElement:function(){return _V_.createElement("div",{className:"vjs-controls"})},fadeIn:function(){this._super();this.player.triggerEvent("controlsvisible")},fadeOut:function(){this._super();this.player.triggerEvent("controlshidden")},lockShowing:function(){this.el.style.opacity="1"}});_V_.Button=_V_.Control.extend({init:function(player,options){this._super(player,options);this.addEvent("click",this.onClick);this.addEvent("focus",this.onFocus);this.addEvent("blur",this.onBlur)},createElement:function(type,attrs){attrs=_V_.merge({className:this.buildCSSClass(),innerHTML:'<div><span class="vjs-control-text">'+(this.buttonText||"Need Text")+"</span></div>",role:"button",tabIndex:0},attrs);return this._super(type,attrs)},onClick:function(){},onFocus:function(){_V_.addEvent(document,"keyup",_V_.proxy(this,this.onKeyPress))},onKeyPress:function(event){if(event.which==32||event.which==13){event.preventDefault();this.onClick()}},onBlur:function(){_V_.removeEvent(document,"keyup",_V_.proxy(this,this.onKeyPress))}});_V_.PlayButton=_V_.Button.extend({buttonText:"Play",buildCSSClass:function(){return"vjs-play-button "+this._super()},onClick:function(){this.player.play()}});_V_.PauseButton=_V_.Button.extend({buttonText:"Pause",buildCSSClass:function(){return"vjs-pause-button "+this._super()},onClick:function(){this.player.pause()}});_V_.PlayToggle=_V_.Button.extend({buttonText:"Play",init:function(player,options){this._super(player,options);player.addEvent("play",_V_.proxy(this,this.onPlay));player.addEvent("pause",_V_.proxy(this,this.onPause))},buildCSSClass:function(){return"vjs-play-control "+this._super()},onClick:function(){if(this.player.paused()){this.player.play()}else{this.player.pause()}},onPlay:function(){_V_.removeClass(this.el,"vjs-paused");_V_.addClass(this.el,"vjs-playing")},onPause:function(){_V_.removeClass(this.el,"vjs-playing");_V_.addClass(this.el,"vjs-paused")}});_V_.FullscreenToggle=_V_.Button.extend({buttonText:"Fullscreen",buildCSSClass:function(){return"vjs-fullscreen-control "+this._super()},onClick:function(){if(!this.player.isFullScreen){this.player.requestFullScreen()}else{this.player.cancelFullScreen()}}});_V_.BigPlayButton=_V_.Button.extend({init:function(player,options){this._super(player,options);player.addEvent("play",_V_.proxy(this,this.hide));player.addEvent("ended",_V_.proxy(this,this.show))},createElement:function(){return this._super("div",{className:"vjs-big-play-button",innerHTML:"<span></span>"})},onClick:function(){if(this.player.currentTime()){this.player.currentTime(0)}this.player.play()}});_V_.LoadingSpinner=_V_.Component.extend({init:function(player,options){this._super(player,options);player.addEvent("canplay",_V_.proxy(this,this.hide));player.addEvent("canplaythrough",_V_.proxy(this,this.hide));player.addEvent("playing",_V_.proxy(this,this.hide));player.addEvent("seeking",_V_.proxy(this,this.show));player.addEvent("error",_V_.proxy(this,this.show));player.addEvent("waiting",_V_.proxy(this,this.show))},createElement:function(){var classNameSpinner,innerHtmlSpinner;if(typeof this.player.el.style.WebkitBorderRadius=="string"||typeof this.player.el.style.MozBorderRadius=="string"||typeof this.player.el.style.KhtmlBorderRadius=="string"||typeof this.player.el.style.borderRadius=="string"){classNameSpinner="vjs-loading-spinner";innerHtmlSpinner="<div class='ball1'></div><div class='ball2'></div><div class='ball3'></div><div class='ball4'></div><div class='ball5'></div><div class='ball6'></div><div class='ball7'></div><div class='ball8'></div>"}else{classNameSpinner="vjs-loading-spinner-fallback";innerHtmlSpinner=""}return this._super("div",{className:classNameSpinner,innerHTML:innerHtmlSpinner})}});_V_.CurrentTimeDisplay=_V_.Component.extend({init:function(player,options){this._super(player,options);player.addEvent("timeupdate",_V_.proxy(this,this.updateContent))},createElement:function(){var el=this._super("div",{className:"vjs-current-time vjs-time-controls vjs-control"});this.content=_V_.createElement("div",{className:"vjs-current-time-display",innerHTML:"0:00"});el.appendChild(_V_.createElement("div").appendChild(this.content));return el},updateContent:function(){var time=(this.player.scrubbing)?this.player.values.currentTime:this.player.currentTime();this.content.innerHTML=_V_.formatTime(time,this.player.duration())}});_V_.DurationDisplay=_V_.Component.extend({init:function(player,options){this._super(player,options);player.addEvent("timeupdate",_V_.proxy(this,this.updateContent))},createElement:function(){var el=this._super("div",{className:"vjs-duration vjs-time-controls vjs-control"});this.content=_V_.createElement("div",{className:"vjs-duration-display",innerHTML:"0:00"});el.appendChild(_V_.createElement("div").appendChild(this.content));return el},updateContent:function(){if(this.player.duration()){this.content.innerHTML=_V_.formatTime(this.player.duration())}}});_V_.TimeDivider=_V_.Component.extend({createElement:function(){return this._super("div",{className:"vjs-time-divider",innerHTML:"<div><span>/</span></div>"})}});_V_.RemainingTimeDisplay=_V_.Component.extend({init:function(player,options){this._super(player,options);player.addEvent("timeupdate",_V_.proxy(this,this.updateContent))},createElement:function(){var el=this._super("div",{className:"vjs-remaining-time vjs-time-controls vjs-control"});this.content=_V_.createElement("div",{className:"vjs-remaining-time-display",innerHTML:"-0:00"});el.appendChild(_V_.createElement("div").appendChild(this.content));return el},updateContent:function(){if(this.player.duration()){this.content.innerHTML="-"+_V_.formatTime(this.player.remainingTime())}}});_V_.Slider=_V_.Component.extend({init:function(player,options){this._super(player,options);player.addEvent(this.playerEvent,_V_.proxy(this,this.update));this.addEvent("mousedown",this.onMouseDown);this.addEvent("focus",this.onFocus);this.addEvent("blur",this.onBlur);this.player.addEvent("controlsvisible",this.proxy(this.update));this.update()},createElement:function(type,attrs){attrs=_V_.merge({role:"slider","aria-valuenow":0,"aria-valuemin":0,"aria-valuemax":100,tabIndex:0},attrs);return this._super(type,attrs)},onMouseDown:function(event){event.preventDefault();_V_.blockTextSelection();_V_.addEvent(document,"mousemove",_V_.proxy(this,this.onMouseMove));_V_.addEvent(document,"mouseup",_V_.proxy(this,this.onMouseUp));this.onMouseMove(event)},onMouseUp:function(event){_V_.unblockTextSelection();_V_.removeEvent(document,"mousemove",this.onMouseMove,false);_V_.removeEvent(document,"mouseup",this.onMouseUp,false);this.update()},update:function(){var barProgress,progress=this.getPercent();handle=this.handle,bar=this.bar;if(isNaN(progress)){progress=0}barProgress=progress;if(handle){var box=this.el,boxWidth=box.offsetWidth,handleWidth=handle.el.offsetWidth,handlePercent=(handleWidth)?handleWidth/boxWidth:0,boxAdjustedPercent=1-handlePercent;adjustedProgress=progress*boxAdjustedPercent,barProgress=adjustedProgress+(handlePercent/2);handle.el.style.left=_V_.round(adjustedProgress*100,2)+"%"}bar.el.style.width=_V_.round(barProgress*100,2)+"%"},calculateDistance:function(event){var box=this.el,boxX=_V_.findPosX(box),boxW=box.offsetWidth,handle=this.handle;if(handle){var handleW=handle.el.offsetWidth;boxX=boxX+(handleW/2);boxW=boxW-handleW}return Math.max(0,Math.min(1,(event.pageX-boxX)/boxW))},onFocus:function(event){_V_.addEvent(document,"keyup",_V_.proxy(this,this.onKeyPress))},onKeyPress:function(event){if(event.which==37){event.preventDefault();this.stepBack()}else{if(event.which==39){event.preventDefault();this.stepForward()}}},onBlur:function(event){_V_.removeEvent(document,"keyup",_V_.proxy(this,this.onKeyPress))}});_V_.ProgressControl=_V_.Component.extend({options:{components:{seekBar:{}}},createElement:function(){return this._super("div",{className:"vjs-progress-control vjs-control"})}});_V_.SeekBar=_V_.Slider.extend({options:{components:{loadProgressBar:{},bar:{componentClass:"PlayProgressBar"},handle:{componentClass:"SeekHandle"}}},playerEvent:"timeupdate",init:function(player,options){this._super(player,options)},createElement:function(){return this._super("div",{className:"vjs-progress-holder"})},getPercent:function(){return this.player.currentTime()/this.player.duration()},onMouseDown:function(event){this._super(event);this.player.scrubbing=true;this.videoWasPlaying=!this.player.paused();this.player.pause()},onMouseMove:function(event){var newTime=this.calculateDistance(event)*this.player.duration();if(newTime==this.player.duration()){newTime=newTime-0.1}this.player.currentTime(newTime)},onMouseUp:function(event){this._super(event);this.player.scrubbing=false;if(this.videoWasPlaying){this.player.play()}},stepForward:function(){this.player.currentTime(this.player.currentTime()+1)},stepBack:function(){this.player.currentTime(this.player.currentTime()-1)}});_V_.LoadProgressBar=_V_.Component.extend({init:function(player,options){this._super(player,options);player.addEvent("progress",_V_.proxy(this,this.update))},createElement:function(){return this._super("div",{className:"vjs-load-progress",innerHTML:'<span class="vjs-control-text">Loaded: 0%</span>'})},update:function(){if(this.el.style){this.el.style.width=_V_.round(this.player.bufferedPercent()*100,2)+"%"}}});_V_.PlayProgressBar=_V_.Component.extend({createElement:function(){return this._super("div",{className:"vjs-play-progress",innerHTML:'<span class="vjs-control-text">Progress: 0%</span>'})}});_V_.SeekHandle=_V_.Component.extend({createElement:function(){return this._super("div",{className:"vjs-seek-handle",innerHTML:'<span class="vjs-control-text">00:00</span>'})}});_V_.VolumeControl=_V_.Component.extend({options:{components:{volumeBar:{}}},createElement:function(){return this._super("div",{className:"vjs-volume-control vjs-control"})}});_V_.VolumeBar=_V_.Slider.extend({options:{components:{bar:{componentClass:"VolumeLevel"},handle:{componentClass:"VolumeHandle"}}},playerEvent:"volumechange",createElement:function(){return this._super("div",{className:"vjs-volume-bar"})},onMouseMove:function(event){this.player.volume(this.calculateDistance(event))},getPercent:function(){return this.player.volume()},stepForward:function(){this.player.volume(this.player.volume()+0.1)},stepBack:function(){this.player.volume(this.player.volume()-0.1)}});_V_.VolumeLevel=_V_.Component.extend({createElement:function(){return this._super("div",{className:"vjs-volume-level",innerHTML:'<span class="vjs-control-text"></span>'})}});_V_.VolumeHandle=_V_.Component.extend({createElement:function(){return this._super("div",{className:"vjs-volume-handle",innerHTML:'<span class="vjs-control-text"></span>'})}});_V_.MuteToggle=_V_.Button.extend({init:function(player,options){this._super(player,options);player.addEvent("volumechange",_V_.proxy(this,this.update))},createElement:function(){return this._super("div",{className:"vjs-mute-control vjs-control",innerHTML:'<div><span class="vjs-control-text">Mute</span></div>'})},onClick:function(event){this.player.muted(this.player.muted()?false:true)},update:function(event){var vol=this.player.volume(),level=3;if(vol==0||this.player.muted()){level=0}else{if(vol<0.33){level=1}else{if(vol<0.67){level=2}}}_V_.each.call(this,[0,1,2,3],function(i){_V_.removeClass(this.el,"vjs-vol-"+i)});_V_.addClass(this.el,"vjs-vol-"+level)}});_V_.PosterImage=_V_.Button.extend({init:function(player,options){this._super(player,options);if(!this.player.options.poster){this.hide()}player.addEvent("play",_V_.proxy(this,this.hide))},createElement:function(){return _V_.createElement("img",{className:"vjs-poster",src:this.player.options.poster,tabIndex:-1})},onClick:function(){this.player.play()}});_V_.Menu=_V_.Component.extend({init:function(player,options){this._super(player,options)},addItem:function(component){this.addComponent(component);component.addEvent("click",this.proxy(function(){this.unlockShowing()}))},createElement:function(){return this._super("ul",{className:"vjs-menu"})}});_V_.MenuItem=_V_.Button.extend({init:function(player,options){this._super(player,options);if(options.selected){this.addClass("vjs-selected")}},createElement:function(type,attrs){return this._super("li",_V_.merge({className:"vjs-menu-item",innerHTML:this.options.label},attrs))},onClick:function(){this.selected(true)},selected:function(selected){if(selected){this.addClass("vjs-selected")}else{this.removeClass("vjs-selected")}}});if(!Array.prototype.indexOf){Array.prototype.indexOf=function(searchElement){if(this===void 0||this===null){throw new TypeError()}var t=Object(this);var len=t.length>>>0;if(len===0){return -1}var n=0;if(arguments.length>0){n=Number(arguments[1]);if(n!==n){n=0}else{if(n!==0&&n!==(1/0)&&n!==-(1/0)){n=(n>0||-1)*Math.floor(Math.abs(n))}}}if(n>=len){return -1}var k=n>=0?n:Math.max(len-Math.abs(n),0);for(;k<len;k++){if(k in t&&t[k]===searchElement){return k}}return -1}}_V_.extend({addEvent:function(elem,type,fn){var data=_V_.getData(elem),handlers;if(data&&!data.handler){data.handler=function(event){event=_V_.fixEvent(event);var handlers=_V_.getData(elem).events[event.type];if(handlers){var handlersCopy=[];_V_.each(handlers,function(handler,i){handlersCopy[i]=handler});for(var i=0,l=handlersCopy.length;i<l;i++){handlersCopy[i].call(elem,event)}}}}if(!data.events){data.events={}}handlers=data.events[type];if(!handlers){handlers=data.events[type]=[];if(document.addEventListener){elem.addEventListener(type,data.handler,false)}else{if(document.attachEvent){elem.attachEvent("on"+type,data.handler)}}}if(!fn.guid){fn.guid=_V_.guid++}handlers.push(fn)},removeEvent:function(elem,type,fn){var data=_V_.getData(elem),handlers;if(!data.events){return}if(!type){for(type in data.events){_V_.cleanUpEvents(elem,type)}return}handlers=data.events[type];if(!handlers){return}if(fn&&fn.guid){for(var i=0;i<handlers.length;i++){if(handlers[i].guid===fn.guid){handlers.splice(i--,1)}}}_V_.cleanUpEvents(elem,type)},cleanUpEvents:function(elem,type){var data=_V_.getData(elem);if(data.events[type].length===0){delete data.events[type];if(document.removeEventListener){elem.removeEventListener(type,data.handler,false)}else{if(document.detachEvent){elem.detachEvent("on"+type,data.handler)}}}if(_V_.isEmpty(data.events)){delete data.events;delete data.handler}if(_V_.isEmpty(data)){_V_.removeData(elem)}},fixEvent:function(event){if(event[_V_.expando]){return event}var originalEvent=event;event=new _V_.Event(originalEvent);for(var i=_V_.Event.props.length,prop;i;){prop=_V_.Event.props[--i];event[prop]=originalEvent[prop]}if(!event.target){event.target=event.srcElement||document}if(event.target.nodeType===3){event.target=event.target.parentNode}if(!event.relatedTarget&&event.fromElement){event.relatedTarget=event.fromElement===event.target?event.toElement:event.fromElement}if(event.pageX==null&&event.clientX!=null){var eventDocument=event.target.ownerDocument||document,doc=eventDocument.documentElement,body=eventDocument.body;event.pageX=event.clientX+(doc&&doc.scrollLeft||body&&body.scrollLeft||0)-(doc&&doc.clientLeft||body&&body.clientLeft||0);event.pageY=event.clientY+(doc&&doc.scrollTop||body&&body.scrollTop||0)-(doc&&doc.clientTop||body&&body.clientTop||0)}if(event.which==null&&(event.charCode!=null||event.keyCode!=null)){event.which=event.charCode!=null?event.charCode:event.keyCode}if(!event.metaKey&&event.ctrlKey){event.metaKey=event.ctrlKey}if(!event.which&&event.button!==undefined){event.which=(event.button&1?1:(event.button&2?3:(event.button&4?2:0)))}return event},triggerEvent:function(elem,event){var data=_V_.getData(elem),parent=elem.parentNode||elem.ownerDocument,type=event.type||event,handler;if(data){handler=data.handler}event=typeof event==="object"?event[_V_.expando]?event:new _V_.Event(type,event):new _V_.Event(type);event.type=type;if(handler){handler.call(elem,event)}event.result=undefined;event.target=elem},one:function(elem,type,fn){_V_.addEvent(elem,type,function(){_V_.removeEvent(elem,type,arguments.callee);fn.apply(this,arguments)})}});_V_.Event=function(src,props){if(src&&src.type){this.originalEvent=src;this.type=src.type;this.isDefaultPrevented=(src.defaultPrevented||src.returnValue===false||src.getPreventDefault&&src.getPreventDefault())?returnTrue:returnFalse}else{this.type=src}if(props){_V_.merge(this,props)}this.timeStamp=(new Date).getTime();this[_V_.expando]=true};_V_.Event.prototype={preventDefault:function(){this.isDefaultPrevented=returnTrue;var e=this.originalEvent;if(!e){return}if(e.preventDefault){e.preventDefault()}else{e.returnValue=false}},stopPropagation:function(){this.isPropagationStopped=returnTrue;var e=this.originalEvent;if(!e){return}if(e.stopPropagation){e.stopPropagation()}e.cancelBubble=true},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=returnTrue;this.stopPropagation()},isDefaultPrevented:returnFalse,isPropagationStopped:returnFalse,isImmediatePropagationStopped:returnFalse};_V_.Event.props="altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue offsetX offsetY pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" ");function returnTrue(){return true}function returnFalse(){return false}var JSON;if(!JSON){JSON={}}(function(){var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;if(typeof JSON.parse!=="function"){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==="object"){for(k in value){if(Object.prototype.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v}else{delete value[k]}}}}return reviver.call(holder,key,value)}text=String(text);cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})}if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){j=eval("("+text+")");return typeof reviver==="function"?walk({"":j},""):j}throw new SyntaxError("JSON.parse")}}}());_V_.Player=_V_.Component.extend({init:function(tag,addOptions,ready){this.tag=tag;var el=this.el=_V_.createElement("div"),options=this.options={},width=options.width=tag.getAttribute("width"),height=options.height=tag.getAttribute("height"),initWidth=width||300,initHeight=height||150;tag.player=el.player=this;this.ready(ready);tag.parentNode.insertBefore(el,tag);el.appendChild(tag);el.id=this.id=tag.id;el.className=tag.className;tag.id+="_html5_api";tag.className="vjs-tech";_V_.players[el.id]=this;el.setAttribute("width",initWidth);el.setAttribute("height",initHeight);el.style.width=initWidth+"px";el.style.height=initHeight+"px";tag.removeAttribute("width");tag.removeAttribute("height");_V_.merge(options,_V_.options);_V_.merge(options,this.getVideoTagSettings());_V_.merge(options,addOptions);tag.removeAttribute("controls");tag.removeAttribute("poster");if(tag.hasChildNodes()){for(var i=0,j=tag.childNodes;i<j.length;i++){if(j[i].nodeName=="SOURCE"||j[i].nodeName=="TRACK"){tag.removeChild(j[i])}}}this.values={};this.addClass("vjs-paused");this.addEvent("ended",this.onEnded);this.addEvent("play",this.onPlay);this.addEvent("pause",this.onPause);this.addEvent("progress",this.onProgress);this.addEvent("error",this.onError);if(options.controls){this.ready(function(){this.initComponents()})}this.textTracks=[];if(options.tracks&&options.tracks.length>0){this.addTextTracks(options.tracks)}if(!options.sources||options.sources.length==0){for(var i=0,j=options.techOrder;i<j.length;i++){var techName=j[i],tech=_V_[techName];if(tech.isSupported()){this.loadTech(techName);break}}}else{this.src(options.sources)}},values:{},destroy:function(){this.stopTrackingProgress();this.stopTrackingCurrentTime();_V_.players[this.id]=null;delete _V_.players[this.id];this.tech.destroy();this.el.parentNode.removeChild(this.el)},createElement:function(type,options){},getVideoTagSettings:function(){var options={sources:[],tracks:[]};options.src=this.tag.getAttribute("src");options.controls=this.tag.getAttribute("controls")!==null;options.poster=this.tag.getAttribute("poster");options.preload=this.tag.getAttribute("preload");options.autoplay=this.tag.getAttribute("autoplay")!==null;options.loop=this.tag.getAttribute("loop")!==null;options.muted=this.tag.getAttribute("muted")!==null;if(this.tag.hasChildNodes()){for(var c,i=0,j=this.tag.childNodes;i<j.length;i++){c=j[i];if(c.nodeName=="SOURCE"){options.sources.push({src:c.getAttribute("src"),type:c.getAttribute("type"),media:c.getAttribute("media"),title:c.getAttribute("title")})}if(c.nodeName=="TRACK"){options.tracks.push({src:c.getAttribute("src"),kind:c.getAttribute("kind"),srclang:c.getAttribute("srclang"),label:c.getAttribute("label"),"default":c.getAttribute("default")!==null,title:c.getAttribute("title")})}}}return options},loadTech:function(techName,source){if(this.tech){this.unloadTech()}else{if(techName!="html5"&&this.tag){this.el.removeChild(this.tag);this.tag=false}}this.techName=techName;this.isReady=false;var techReady=function(){this.player.triggerReady();if(!this.support.progressEvent){this.player.manualProgressOn()}if(!this.support.timeupdateEvent){this.player.manualTimeUpdatesOn()}};var techOptions=_V_.merge({source:source,parentEl:this.el},this.options[techName]);if(source){if(source.src==this.values.src&&this.values.currentTime>0){techOptions.startTime=this.values.currentTime}this.values.src=source.src}this.tech=new _V_[techName](this,techOptions);this.tech.ready(techReady)},unloadTech:function(){this.tech.destroy();if(this.manualProgress){this.manualProgressOff()}if(this.manualTimeUpdates){this.manualTimeUpdatesOff()}this.tech=false},manualProgressOn:function(){this.manualProgress=true;this.trackProgress();this.tech.addEvent("progress",function(){this.removeEvent("progress",arguments.callee);this.support.progressEvent=true;this.player.manualProgressOff()})},manualProgressOff:function(){this.manualProgress=false;this.stopTrackingProgress()},trackProgress:function(){this.progressInterval=setInterval(_V_.proxy(this,function(){if(this.values.bufferEnd<this.buffered().end(0)){this.triggerEvent("progress")}else{if(this.bufferedPercent()==1){this.stopTrackingProgress();this.triggerEvent("progress")}}}),500)},stopTrackingProgress:function(){clearInterval(this.progressInterval)},manualTimeUpdatesOn:function(){this.manualTimeUpdates=true;this.addEvent("play",this.trackCurrentTime);this.addEvent("pause",this.stopTrackingCurrentTime);this.tech.addEvent("timeupdate",function(){this.removeEvent("timeupdate",arguments.callee);this.support.timeupdateEvent=true;this.player.manualTimeUpdatesOff()})},manualTimeUpdatesOff:function(){this.manualTimeUpdates=false;this.stopTrackingCurrentTime();this.removeEvent("play",this.trackCurrentTime);this.removeEvent("pause",this.stopTrackingCurrentTime)},trackCurrentTime:function(){if(this.currentTimeInterval){this.stopTrackingCurrentTime()}this.currentTimeInterval=setInterval(_V_.proxy(this,function(){this.triggerEvent("timeupdate")}),250)},stopTrackingCurrentTime:function(){clearInterval(this.currentTimeInterval)},onEnded:function(){if(this.options.loop){this.currentTime(0);this.play()}else{this.pause();this.currentTime(0);this.pause()}},onPlay:function(){_V_.removeClass(this.el,"vjs-paused");_V_.addClass(this.el,"vjs-playing")},onPause:function(){_V_.removeClass(this.el,"vjs-playing");_V_.addClass(this.el,"vjs-paused")},onProgress:function(){if(this.bufferedPercent()==1){this.triggerEvent("loadedalldata")}},onError:function(e){_V_.log("Video Error",e)},techCall:function(method,arg){if(!this.tech.isReady){this.tech.ready(function(){this[method](arg)})}else{try{this.tech[method](arg)}catch(e){_V_.log(e)}}},techGet:function(method){if(this.tech.isReady){try{return this.tech[method]()}catch(e){if(this.tech[method]===undefined){_V_.log("Video.js: "+method+" method not defined for "+this.techName+" playback technology.",e)}else{if(e.name=="TypeError"){_V_.log("Video.js: "+method+" unavailable on "+this.techName+" playback technology element.",e);this.tech.isReady=false}else{_V_.log(e)}}}}return},play:function(){this.techCall("play");return this},pause:function(){this.techCall("pause");return this},paused:function(){return(this.techGet("paused")===false)?false:true},currentTime:function(seconds){if(seconds!==undefined){this.values.lastSetCurrentTime=seconds;this.techCall("setCurrentTime",seconds);if(this.manualTimeUpdates){this.triggerEvent("timeupdate")}return this}return this.values.currentTime=(this.techGet("currentTime")||0)},duration:function(){return parseFloat(this.techGet("duration"))},remainingTime:function(){return this.duration()-this.currentTime()},buffered:function(){var buffered=this.techGet("buffered"),start=0,end=this.values.bufferEnd=this.values.bufferEnd||0,timeRange;if(buffered&&buffered.length>0&&buffered.end(0)!==end){end=buffered.end(0);this.values.bufferEnd=end}return _V_.createTimeRange(start,end)},bufferedPercent:function(){return(this.duration())?this.buffered().end(0)/this.duration():0},volume:function(percentAsDecimal){var vol;if(percentAsDecimal!==undefined){vol=Math.max(0,Math.min(1,parseFloat(percentAsDecimal)));this.values.volume=vol;this.techCall("setVolume",vol);_V_.setLocalStorage("volume",vol);return this}vol=parseFloat(this.techGet("volume"));return(isNaN(vol))?1:vol},muted:function(muted){if(muted!==undefined){this.techCall("setMuted",muted);return this}return this.techGet("muted")||false},width:function(width,skipListeners){if(width!==undefined){this.el.width=width;this.el.style.width=width+"px";if(!skipListeners){this.triggerEvent("resize")}return this}return parseInt(this.el.getAttribute("width"))},height:function(height){if(height!==undefined){this.el.height=height;this.el.style.height=height+"px";this.triggerEvent("resize");return this}return parseInt(this.el.getAttribute("height"))},size:function(width,height){return this.width(width,true).height(height)},supportsFullScreen:function(){return this.techGet("supportsFullScreen")||false},requestFullScreen:function(){var requestFullScreen=_V_.support.requestFullScreen;this.isFullScreen=true;if(requestFullScreen){_V_.addEvent(document,requestFullScreen.eventName,this.proxy(function(){this.isFullScreen=document[requestFullScreen.isFullScreen];if(this.isFullScreen==false){_V_.removeEvent(document,requestFullScreen.eventName,arguments.callee)}this.triggerEvent("fullscreenchange")}));if(this.tech.support.fullscreenResize===false&&this.options.flash.iFrameMode!=true){this.pause();this.unloadTech();_V_.addEvent(document,requestFullScreen.eventName,this.proxy(function(){_V_.removeEvent(document,requestFullScreen.eventName,arguments.callee);this.loadTech(this.techName,{src:this.values.src})}));this.el[requestFullScreen.requestFn]()}else{this.el[requestFullScreen.requestFn]()}}else{if(this.tech.supportsFullScreen()){this.triggerEvent("fullscreenchange");this.techCall("enterFullScreen")}else{this.triggerEvent("fullscreenchange");this.enterFullWindow()}}return this},cancelFullScreen:function(){var requestFullScreen=_V_.support.requestFullScreen;this.isFullScreen=false;if(requestFullScreen){if(this.tech.support.fullscreenResize===false&&this.options.flash.iFrameMode!=true){this.pause();this.unloadTech();_V_.addEvent(document,requestFullScreen.eventName,this.proxy(function(){_V_.removeEvent(document,requestFullScreen.eventName,arguments.callee);this.loadTech(this.techName,{src:this.values.src})}));document[requestFullScreen.cancelFn]()}else{document[requestFullScreen.cancelFn]()}}else{if(this.tech.supportsFullScreen()){this.techCall("exitFullScreen");this.triggerEvent("fullscreenchange")}else{this.exitFullWindow();this.triggerEvent("fullscreenchange")}}return this},enterFullWindow:function(){this.isFullWindow=true;this.docOrigOverflow=document.documentElement.style.overflow;_V_.addEvent(document,"keydown",_V_.proxy(this,this.fullWindowOnEscKey));document.documentElement.style.overflow="hidden";_V_.addClass(document.body,"vjs-full-window");_V_.addClass(this.el,"vjs-fullscreen");this.triggerEvent("enterFullWindow")},fullWindowOnEscKey:function(event){if(event.keyCode==27){if(this.isFullScreen==true){this.cancelFullScreen()}else{this.exitFullWindow()}}},exitFullWindow:function(){this.isFullWindow=false;_V_.removeEvent(document,"keydown",this.fullWindowOnEscKey);document.documentElement.style.overflow=this.docOrigOverflow;_V_.removeClass(document.body,"vjs-full-window");_V_.removeClass(this.el,"vjs-fullscreen");this.triggerEvent("exitFullWindow")},selectSource:function(sources){for(var i=0,j=this.options.techOrder;i<j.length;i++){var techName=j[i],tech=_V_[techName];if(tech.isSupported()){for(var a=0,b=sources;a<b.length;a++){var source=b[a];if(tech.canPlaySource.call(this,source)){return{source:source,tech:techName}}}}}return false},src:function(source){if(source instanceof Array){var sourceTech=this.selectSource(source),source,techName;if(sourceTech){source=sourceTech.source;techName=sourceTech.tech;if(techName==this.techName){this.src(source)}else{this.loadTech(techName,source)}}else{_V_.log("No compatible source and playback technology were found.")}}else{if(source instanceof Object){if(_V_[this.techName].canPlaySource(source)){this.src(source.src)}else{this.src([source])}}else{this.values.src=source;if(!this.isReady){this.ready(function(){this.src(source)})}else{this.techCall("src",source);if(this.options.preload=="auto"){this.load()}if(this.options.autoplay){this.play()}}}}return this},load:function(){this.techCall("load");return this},currentSrc:function(){return this.techGet("currentSrc")||this.values.src||""},preload:function(value){if(value!==undefined){this.techCall("setPreload",value);this.options.preload=value;return this}return this.techGet("preload")},autoplay:function(value){if(value!==undefined){this.techCall("setAutoplay",value);this.options.autoplay=value;return this}return this.techGet("autoplay",value)},loop:function(value){if(value!==undefined){this.techCall("setLoop",value);this.options.loop=value;return this}return this.techGet("loop")},controls:function(){return this.options.controls},poster:function(){return this.techGet("poster")},error:function(){return this.techGet("error")},ended:function(){return this.techGet("ended")}});(function(){var requestFn,cancelFn,eventName,isFullScreen,playerProto=_V_.Player.prototype;if(document.cancelFullscreen!==undefined){requestFn="requestFullscreen";cancelFn="exitFullscreen";eventName="fullscreenchange";isFullScreen="fullScreen"}else{_V_.each(["moz","webkit"],function(prefix){if((prefix!="moz"||document.mozFullScreenEnabled)&&document[prefix+"CancelFullScreen"]!==undefined){requestFn=prefix+"RequestFullScreen";cancelFn=prefix+"CancelFullScreen";eventName=prefix+"fullscreenchange";if(prefix=="webkit"){isFullScreen=prefix+"IsFullScreen"}else{isFullScreen=prefix+"FullScreen"}}})}if(requestFn){_V_.support.requestFullScreen={requestFn:requestFn,cancelFn:cancelFn,eventName:eventName,isFullScreen:isFullScreen}}})();_V_.PlaybackTech=_V_.Component.extend({init:function(player,options){},onClick:function(){if(this.player.options.controls){_V_.PlayToggle.prototype.onClick.call(this)}}});_V_.apiMethods="play,pause,paused,currentTime,setCurrentTime,duration,buffered,volume,setVolume,muted,setMuted,width,height,supportsFullScreen,enterFullScreen,src,load,currentSrc,preload,setPreload,autoplay,setAutoplay,loop,setLoop,error,networkState,readyState,seeking,initialTime,startOffsetTime,played,seekable,ended,videoTracks,audioTracks,videoWidth,videoHeight,textTracks,defaultPlaybackRate,playbackRate,mediaGroup,controller,controls,defaultMuted".split(",");_V_.each(_V_.apiMethods,function(methodName){_V_.PlaybackTech.prototype[methodName]=function(){throw new Error("The '"+methodName+"' method is not available on the playback technology's API")}});_V_.html5=_V_.PlaybackTech.extend({init:function(player,options,ready){this.player=player;this.el=this.createElement();this.ready(ready);this.addEvent("click",this.proxy(this.onClick));var source=options.source;if(source&&this.el.currentSrc==source.src){player.triggerEvent("loadstart")}else{if(source){this.el.src=source.src}}player.ready(function(){if(this.options.autoplay&&this.paused()){this.tag.poster=null;this.play()}});this.setupTriggers();this.triggerReady()},destroy:function(){this.player.tag=false;this.removeTriggers();this.el.parentNode.removeChild(this.el)},createElement:function(){var html5=_V_.html5,player=this.player,el=player.tag,newEl;if(!el||this.support.movingElementInDOM===false){if(el){player.el.removeChild(el)}newEl=_V_.createElement("video",{id:el.id||player.el.id+"_html5_api",className:el.className||"vjs-tech"});el=newEl;_V_.insertFirst(el,player.el)}_V_.each(["autoplay","preload","loop","muted"],function(attr){if(player.options[attr]!==null){el[attr]=player.options[attr]}},this);return el},setupTriggers:function(){_V_.each.call(this,_V_.html5.events,function(type){_V_.addEvent(this.el,type,_V_.proxy(this.player,this.eventHandler))})},removeTriggers:function(){_V_.each.call(this,_V_.html5.events,function(type){_V_.removeEvent(this.el,type,_V_.proxy(this.player,this.eventHandler))})},eventHandler:function(e){e.stopPropagation();this.triggerEvent(e)},play:function(){this.el.play()},pause:function(){this.el.pause()},paused:function(){return this.el.paused},currentTime:function(){return this.el.currentTime},setCurrentTime:function(seconds){try{this.el.currentTime=seconds}catch(e){_V_.log(e,"Video isn't ready. (VideoJS)")}},duration:function(){return this.el.duration||0},buffered:function(){return this.el.buffered},volume:function(){return this.el.volume},setVolume:function(percentAsDecimal){this.el.volume=percentAsDecimal},muted:function(){return this.el.muted},setMuted:function(muted){this.el.muted=muted},width:function(){return this.el.offsetWidth},height:function(){return this.el.offsetHeight},supportsFullScreen:function(){if(typeof this.el.webkitEnterFullScreen=="function"){if(!navigator.userAgent.match("Chrome")&&!navigator.userAgent.match("Mac OS X 10.5")){return true}}return false},enterFullScreen:function(){try{this.el.webkitEnterFullScreen()}catch(e){if(e.code==11){_V_.log("VideoJS: Video not ready.")}}},src:function(src){this.el.src=src},load:function(){this.el.load()},currentSrc:function(){return this.el.currentSrc},preload:function(){return this.el.preload},setPreload:function(val){this.el.preload=val},autoplay:function(){return this.el.autoplay},setAutoplay:function(val){this.el.autoplay=val},loop:function(){return this.el.loop},setLoop:function(val){this.el.loop=val},error:function(){return this.el.error},seeking:function(){return this.el.seeking},ended:function(){return this.el.ended},controls:function(){return this.player.options.controls},defaultMuted:function(){return this.el.defaultMuted}});_V_.html5.isSupported=function(){return !!document.createElement("video").canPlayType};_V_.html5.canPlaySource=function(srcObj){return !!document.createElement("video").canPlayType(srcObj.type)};_V_.html5.events="loadstart,suspend,abort,error,emptied,stalled,loadedmetadata,loadeddata,canplay,canplaythrough,playing,waiting,seeking,seeked,ended,durationchange,timeupdate,progress,play,pause,ratechange,volumechange".split(",");_V_.html5.prototype.support={fullscreen:(typeof _V_.testVid.webkitEnterFullScreen!==undefined)?(!_V_.ua.match("Chrome")&&!_V_.ua.match("Mac OS X 10.5")?true:false):false,movingElementInDOM:!_V_.isIOS()};if(_V_.isAndroid()){if(_V_.androidVersion()<3){document.createElement("video").constructor.prototype.canPlayType=function(type){return(type&&type.toLowerCase().indexOf("video/mp4")!=-1)?"maybe":""}}}_V_.flash=_V_.PlaybackTech.extend({init:function(player,options){this.player=player;var source=options.source,parentEl=options.parentEl,placeHolder=this.el=_V_.createElement("div",{id:parentEl.id+"_temp_flash"}),objId=player.el.id+"_flash_api",playerOptions=player.options,flashVars=_V_.merge({readyFunction:"_V_.flash.onReady",eventProxyFunction:"_V_.flash.onEvent",errorEventProxyFunction:"_V_.flash.onError",autoplay:playerOptions.autoplay,preload:playerOptions.preload,loop:playerOptions.loop,muted:playerOptions.muted},options.flashVars),params=_V_.merge({wmode:"opaque",bgcolor:"#000000"},options.params),attributes=_V_.merge({id:objId,name:objId,"class":"vjs-tech"},options.attributes);if(source){flashVars.src=encodeURIComponent(_V_.getAbsoluteURL(source.src))}_V_.insertFirst(placeHolder,parentEl);if(options.startTime){this.ready(function(){this.load();this.play();this.currentTime(options.startTime)})}if(options.iFrameMode==true&&!_V_.isFF){var iFrm=_V_.createElement("iframe",{id:objId+"_iframe",name:objId+"_iframe",className:"vjs-tech",scrolling:"no",marginWidth:0,marginHeight:0,frameBorder:0});flashVars.readyFunction="ready";flashVars.eventProxyFunction="events";flashVars.errorEventProxyFunction="errors";_V_.addEvent(iFrm,"load",_V_.proxy(this,function(){var iDoc,objTag,swfLoc,iWin=iFrm.contentWindow,varString="";iDoc=iFrm.contentDocument?iFrm.contentDocument:iFrm.contentWindow.document;iDoc.write(_V_.flash.getEmbedCode(options.swf,flashVars,params,attributes));iWin.player=this.player;iWin.ready=_V_.proxy(this.player,function(currSwf){var el=iDoc.getElementById(currSwf),player=this,tech=player.tech;tech.el=el;_V_.addEvent(el,"click",tech.proxy(tech.onClick));_V_.flash.checkReady(tech)});iWin.events=_V_.proxy(this.player,function(swfID,eventName,other){var player=this;if(player&&player.techName=="flash"){player.triggerEvent(eventName)}});iWin.errors=_V_.proxy(this.player,function(swfID,eventName){_V_.log("Flash Error",eventName)})}));placeHolder.parentNode.replaceChild(iFrm,placeHolder)}else{_V_.flash.embed(options.swf,placeHolder,flashVars,params,attributes)}},destroy:function(){this.el.parentNode.removeChild(this.el)},play:function(){this.el.vjs_play()},pause:function(){this.el.vjs_pause()},src:function(src){src=_V_.getAbsoluteURL(src);this.el.vjs_src(src);if(this.player.autoplay()){var tech=this;setTimeout(function(){tech.play()},0)}},load:function(){this.el.vjs_load()},poster:function(){this.el.vjs_getProperty("poster")},buffered:function(){return _V_.createTimeRange(0,this.el.vjs_getProperty("buffered"))},supportsFullScreen:function(){return false},enterFullScreen:function(){return false}});(function(){var api=_V_.flash.prototype,readWrite="preload,currentTime,defaultPlaybackRate,playbackRate,autoplay,loop,mediaGroup,controller,controls,volume,muted,defaultMuted".split(","),readOnly="error,currentSrc,networkState,readyState,seeking,initialTime,duration,startOffsetTime,paused,played,seekable,ended,videoTracks,audioTracks,videoWidth,videoHeight,textTracks".split(","),callOnly="load,play,pause".split(",");createSetter=function(attr){var attrUpper=attr.charAt(0).toUpperCase()+attr.slice(1);api["set"+attrUpper]=function(val){return this.el.vjs_setProperty(attr,val)}},createGetter=function(attr){api[attr]=function(){return this.el.vjs_getProperty(attr)}};_V_.each(readWrite,function(attr){createGetter(attr);createSetter(attr)});_V_.each(readOnly,function(attr){createGetter(attr)})})();_V_.flash.isSupported=function(){return _V_.flash.version()[0]>=10};_V_.flash.canPlaySource=function(srcObj){if(srcObj.type in _V_.flash.prototype.support.formats){return"maybe"}};_V_.flash.prototype.support={formats:{"video/flv":"FLV","video/x-flv":"FLV","video/mp4":"MP4","video/m4v":"MP4"},progressEvent:false,timeupdateEvent:false,fullscreenResize:false,parentResize:!(_V_.ua.match("Firefox"))};_V_.flash.onReady=function(currSwf){var el=_V_.el(currSwf);var player=el.player||el.parentNode.player,tech=player.tech;el.player=player;tech.el=el;tech.addEvent("click",tech.onClick);_V_.flash.checkReady(tech)};_V_.flash.checkReady=function(tech){if(tech.el.vjs_getProperty){tech.triggerReady()}else{setTimeout(function(){_V_.flash.checkReady(tech)},50)}};_V_.flash.onEvent=function(swfID,eventName){var player=_V_.el(swfID).player;player.triggerEvent(eventName)};_V_.flash.onError=function(swfID,err){var player=_V_.el(swfID).player;player.triggerEvent("error");_V_.log("Flash Error",err,swfID)};_V_.flash.version=function(){var version="0,0,0";try{version=new ActiveXObject("ShockwaveFlash.ShockwaveFlash").GetVariable("$version").replace(/\D+/g,",").match(/^,?(.+),?$/)[1]}catch(e){try{if(navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){version=(navigator.plugins["Shockwave Flash 2.0"]||navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g,",").match(/^,?(.+),?$/)[1]}}catch(e){}}return version.split(",")};_V_.flash.embed=function(swf,placeHolder,flashVars,params,attributes){var code=_V_.flash.getEmbedCode(swf,flashVars,params,attributes),obj=_V_.createElement("div",{innerHTML:code}).childNodes[0],par=placeHolder.parentNode;placeHolder.parentNode.replaceChild(obj,placeHolder);if(_V_.isIE()){var newObj=par.childNodes[0];setTimeout(function(){newObj.style.display="block"},1000)}return obj};_V_.flash.getEmbedCode=function(swf,flashVars,params,attributes){var objTag='<object type="application/x-shockwave-flash"',flashVarsString="",paramsString="";attrsString="";if(flashVars){_V_.eachProp(flashVars,function(key,val){flashVarsString+=(key+"="+val+"&amp;")})}params=_V_.merge({movie:swf,flashvars:flashVarsString,allowScriptAccess:"always",allowNetworking:"all"},params);_V_.eachProp(params,function(key,val){paramsString+='<param name="'+key+'" value="'+val+'" />'});attributes=_V_.merge({data:swf,width:"100%",height:"100%"},attributes);_V_.eachProp(attributes,function(key,val){attrsString+=(key+'="'+val+'" ')});return objTag+attrsString+">"+paramsString+"</object>"};_V_.merge(_V_.Player.prototype,{addTextTracks:function(trackObjects){var tracks=this.textTracks=(this.textTracks)?this.textTracks:[],i=0,j=trackObjects.length,track,Kind;for(;i<j;i++){Kind=_V_.uc(trackObjects[i].kind||"subtitles");track=new _V_[Kind+"Track"](this,trackObjects[i]);tracks.push(track);if(track["default"]){this.ready(_V_.proxy(track,track.show))}}return this},showTextTrack:function(id,disableSameKind){var tracks=this.textTracks,i=0,j=tracks.length,track,showTrack,kind;for(;i<j;i++){track=tracks[i];if(track.id===id){track.show();showTrack=track}else{if(disableSameKind&&track.kind==disableSameKind&&track.mode>0){track.disable()}}}kind=(showTrack)?showTrack.kind:((disableSameKind)?disableSameKind:false);if(kind){this.triggerEvent(kind+"trackchange")}return this}});_V_.Track=_V_.Component.extend({init:function(player,options){this._super(player,options);_V_.merge(this,{id:options.id||("vjs_"+options.kind+"_"+options.language+"_"+_V_.guid++),src:options.src,"default":options["default"],title:options.title,language:options.srclang,label:options.label,cues:[],activeCues:[],readyState:0,mode:0})},createElement:function(){return this._super("div",{className:"vjs-"+this.kind+" vjs-text-track"})},show:function(){this.activate();this.mode=2;this._super()},hide:function(){this.activate();this.mode=1;this._super()},disable:function(){if(this.mode==2){this.hide()}this.deactivate();this.mode=0},activate:function(){if(this.readyState==0){this.load()}if(this.mode==0){this.player.addEvent("timeupdate",this.proxy(this.update,this.id));this.player.addEvent("ended",this.proxy(this.reset,this.id));if(this.kind=="captions"||this.kind=="subtitles"){this.player.textTrackDisplay.addComponent(this)}}},deactivate:function(){this.player.removeEvent("timeupdate",this.proxy(this.update,this.id));this.player.removeEvent("ended",this.proxy(this.reset,this.id));this.reset();this.player.textTrackDisplay.removeComponent(this)},load:function(){if(this.readyState==0){this.readyState=1;_V_.get(this.src,this.proxy(this.parseCues),this.proxy(this.onError))}},onError:function(err){this.error=err;this.readyState=3;this.triggerEvent("error")},parseCues:function(srcContent){var cue,time,text,lines=srcContent.split("\n"),line="",id;for(var i=1,j=lines.length;i<j;i++){line=_V_.trim(lines[i]);if(line){if(line.indexOf("-->")==-1){id=line;line=_V_.trim(lines[++i])}else{id=this.cues.length}cue={id:id,index:this.cues.length};time=line.split(" --> ");cue.startTime=this.parseCueTime(time[0]);cue.endTime=this.parseCueTime(time[1]);text=[];while(lines[++i]&&(line=_V_.trim(lines[i]))){text.push(line)}cue.text=text.join("<br/>");this.cues.push(cue)}}this.readyState=2;this.triggerEvent("loaded")},parseCueTime:function(timeText){var parts=timeText.split(":"),time=0,hours,minutes,other,seconds,ms,flags;if(parts.length==3){hours=parts[0];minutes=parts[1];other=parts[2]}else{hours=0;minutes=parts[0];other=parts[1]}other=other.split(/\s+/);seconds=other.splice(0,1)[0];seconds=seconds.split(/\.|,/);ms=parseFloat(seconds[1]);seconds=seconds[0];time+=parseFloat(hours)*3600;time+=parseFloat(minutes)*60;time+=parseFloat(seconds);if(ms){time+=ms/1000}return time},update:function(){if(this.cues.length>0){var time=this.player.currentTime();if(this.prevChange===undefined||time<this.prevChange||this.nextChange<=time){var cues=this.cues,newNextChange=this.player.duration(),newPrevChange=0,reverse=false,newCues=[],firstActiveIndex,lastActiveIndex,html="",cue,i,j;if(time>=this.nextChange||this.nextChange===undefined){i=(this.firstActiveIndex!==undefined)?this.firstActiveIndex:0}else{reverse=true;i=(this.lastActiveIndex!==undefined)?this.lastActiveIndex:cues.length-1}while(true){cue=cues[i];if(cue.endTime<=time){newPrevChange=Math.max(newPrevChange,cue.endTime);if(cue.active){cue.active=false}}else{if(time<cue.startTime){newNextChange=Math.min(newNextChange,cue.startTime);if(cue.active){cue.active=false}if(!reverse){break}}else{if(reverse){newCues.splice(0,0,cue);if(lastActiveIndex===undefined){lastActiveIndex=i}firstActiveIndex=i}else{newCues.push(cue);if(firstActiveIndex===undefined){firstActiveIndex=i}lastActiveIndex=i}newNextChange=Math.min(newNextChange,cue.endTime);newPrevChange=Math.max(newPrevChange,cue.startTime);cue.active=true}}if(reverse){if(i===0){break}else{i--}}else{if(i===cues.length-1){break}else{i++}}}this.activeCues=newCues;this.nextChange=newNextChange;this.prevChange=newPrevChange;this.firstActiveIndex=firstActiveIndex;this.lastActiveIndex=lastActiveIndex;this.updateDisplay();this.triggerEvent("cuechange")}}},updateDisplay:function(){var cues=this.activeCues,html="",i=0,j=cues.length;for(;i<j;i++){html+="<span class='vjs-tt-cue'>"+cues[i].text+"</span>"}this.el.innerHTML=html},reset:function(){this.nextChange=0;this.prevChange=this.player.duration();this.firstActiveIndex=0;this.lastActiveIndex=0}});_V_.CaptionsTrack=_V_.Track.extend({kind:"captions"});_V_.SubtitlesTrack=_V_.Track.extend({kind:"subtitles"});_V_.ChaptersTrack=_V_.Track.extend({kind:"chapters"});_V_.TextTrackDisplay=_V_.Component.extend({createElement:function(){return this._super("div",{className:"vjs-text-track-display"})}});_V_.TextTrackMenuItem=_V_.MenuItem.extend({init:function(player,options){var track=this.track=options.track;options.label=track.label;options.selected=track["default"];this._super(player,options);this.player.addEvent(track.kind+"trackchange",_V_.proxy(this,this.update))},onClick:function(){this._super();this.player.showTextTrack(this.track.id,this.track.kind)},update:function(){if(this.track.mode==2){this.selected(true)}else{this.selected(false)}}});_V_.OffTextTrackMenuItem=_V_.TextTrackMenuItem.extend({init:function(player,options){options.track={kind:options.kind,player:player,label:"Off"};this._super(player,options)},onClick:function(){this._super();this.player.showTextTrack(this.track.id,this.track.kind)},update:function(){var tracks=this.player.textTracks,i=0,j=tracks.length,track,off=true;for(;i<j;i++){track=tracks[i];if(track.kind==this.track.kind&&track.mode==2){off=false}}if(off){this.selected(true)}else{this.selected(false)}}});_V_.TextTrackButton=_V_.Button.extend({init:function(player,options){this._super(player,options);this.menu=this.createMenu();if(this.items.length===0){this.hide()}},createMenu:function(){var menu=new _V_.Menu(this.player);menu.el.appendChild(_V_.createElement("li",{className:"vjs-menu-title",innerHTML:_V_.uc(this.kind)}));menu.addItem(new _V_.OffTextTrackMenuItem(this.player,{kind:this.kind}));this.items=this.createItems();this.each(this.items,function(item){menu.addItem(item)});this.addComponent(menu);return menu},createItems:function(){var items=[];this.each(this.player.textTracks,function(track){if(track.kind===this.kind){items.push(new _V_.TextTrackMenuItem(this.player,{track:track}))}});return items},buildCSSClass:function(){return this.className+" vjs-menu-button "+this._super()},onFocus:function(){this.menu.lockShowing();_V_.one(this.menu.el.childNodes[this.menu.el.childNodes.length-1],"blur",this.proxy(function(){this.menu.unlockShowing()}))},onBlur:function(){},onClick:function(){this.one("mouseout",this.proxy(function(){this.menu.unlockShowing();this.el.blur()}))}});_V_.CaptionsButton=_V_.TextTrackButton.extend({kind:"captions",buttonText:"Captions",className:"vjs-captions-button"});_V_.SubtitlesButton=_V_.TextTrackButton.extend({kind:"subtitles",buttonText:"Subtitles",className:"vjs-subtitles-button"});_V_.ChaptersButton=_V_.TextTrackButton.extend({kind:"chapters",buttonText:"Chapters",className:"vjs-chapters-button",createItems:function(chaptersTrack){var items=[];this.each(this.player.textTracks,function(track){if(track.kind===this.kind){items.push(new _V_.TextTrackMenuItem(this.player,{track:track}))}});return items},createMenu:function(){var tracks=this.player.textTracks,i=0,j=tracks.length,track,chaptersTrack,items=this.items=[];for(;i<j;i++){track=tracks[i];if(track.kind==this.kind&&track["default"]){if(track.readyState<2){this.chaptersTrack=track;track.addEvent("loaded",this.proxy(this.createMenu));return}else{chaptersTrack=track;break}}}var menu=this.menu=new _V_.Menu(this.player);menu.el.appendChild(_V_.createElement("li",{className:"vjs-menu-title",innerHTML:_V_.uc(this.kind)}));if(chaptersTrack){var cues=chaptersTrack.cues,i=0,j=cues.length,cue,mi;for(;i<j;i++){cue=cues[i];mi=new _V_.ChaptersTrackMenuItem(this.player,{track:chaptersTrack,cue:cue});items.push(mi);menu.addComponent(mi)}}this.addComponent(menu);if(this.items.length>0){this.show()}return menu}});_V_.ChaptersTrackMenuItem=_V_.MenuItem.extend({init:function(player,options){var track=this.track=options.track,cue=this.cue=options.cue,currentTime=player.currentTime();options.label=cue.text;options.selected=(cue.startTime<=currentTime&&currentTime<cue.endTime);this._super(player,options);track.addEvent("cuechange",_V_.proxy(this,this.update))},onClick:function(){this._super();this.player.currentTime(this.cue.startTime);this.update(this.cue.startTime)},update:function(time){var cue=this.cue,currentTime=this.player.currentTime();if(cue.startTime<=currentTime&&currentTime<cue.endTime){this.selected(true)}else{this.selected(false)}}});_V_.merge(_V_.ControlBar.prototype.options.components,{subtitlesButton:{},captionsButton:{},chaptersButton:{}});_V_.autoSetup=function(){var options,vid,player,vids=document.getElementsByTagName("video");if(vids&&vids.length>0){for(var i=0,j=vids.length;i<j;i++){vid=vids[i];if(vid&&vid.getAttribute){if(vid.player===undefined){options=vid.getAttribute("data-setup");if(options!==null){options=JSON.parse(options||"{}");player=_V_(vid,options)}}}else{_V_.autoSetupTimeout(1);break}}}else{if(!_V_.windowLoaded){_V_.autoSetupTimeout(1)}}};_V_.autoSetupTimeout=function(wait){setTimeout(_V_.autoSetup,wait)};_V_.addEvent(window,"load",function(){_V_.windowLoaded=true});_V_.autoSetup();window.VideoJS=window._V_=VideoJS})(window);