-
Notifications
You must be signed in to change notification settings - Fork 0
/
jm_jplayer.class.php
513 lines (440 loc) · 16 KB
/
jm_jplayer.class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
<?php
// loading css and js common just for menu and one page, not for all site in e_header.php
$skin = (e107::pref('jm_jplayer', 'skin')) ? e107::pref('jm_jplayer', 'skin') : 0;
if (0 == $skin)
{
$css_filename = 'default';
}
elseif (1 == $skin)
{
$css_filename = 'popestar';
}
if (!empty($_GET['playlist_id']) && $_GET['iframe'] == 'true')
{
$embed = true;
}
e107::css('jm_jplayer', '/assets/css/min/jplayer-popestar.css');
e107::css('jm_jplayer', '/assets/css/min/jplayer-' . $css_filename . '.min.css');
e107::css('jm_jplayer', '/assets/wp/dashicons.min.css');
e107::css('jm_jplayer', '/assets/wp/dashicons.min.css');
require_once (e_PLUGIN . 'jm_jplayer/includes/functions.php');
$bg_color_hex = e107::pref('jm_jplayer', 'bg_color') ? e107::pref('jm_jplayer', 'bg_color') : '#353535';
$bg_color_hex = e107::getParser()->toHtml($bg_color_hex);
$bg_color_rgba = e107::pref('jm_jplayer', 'bg_color') ? wolf_jplayer_hex_to_rgb(e107::pref('jm_jplayer', 'bg_color')) : wolf_jplayer_hex_to_rgb('#353535');
$bg_color_rgba = e107::getParser()->toHtml($bg_color_rgba);
$opacity = e107::pref('jm_jplayer', 'bg_opacity') ? intval(e107::pref('jm_jplayer', 'bg_opacity')) / 100 : 1;
$opacity = e107::getParser()->toHtml($opacity);
$font_color = e107::pref('jm_jplayer', 'font_color') ? e107::pref('jm_jplayer', 'font_color') : '#ffffff';
$font_color = e107::getParser()->toHtml($font_color);
$song_height = 37; // default
// ???JM $skin = absint( wolf_get_jplayer_option( 'font_color' ) );
// if ( 1 == wolf_get_jplayer_option( 'font_color' ) ) {
// $song_height = 40;
// }
$max_song_count = e107::pref('jm_jplayer', 'song_count_before_scroll');
$song_height = 37; // default
// $skin = absint( wolf_get_jplayer_option( 'font_color' ) ); ???? CHECK
$playlist_height = (e107::pref('jm_jplayer', 'scrollbar') && $max_song_count) ? $max_song_count * $song_height : '';
$inline_css = '';
if ($embed):
$inline_css.= ' body {background:none}
#wolf-jp-popup { display:none!important } ';
endif;
if ($in_popup && 0 == $skin):
$inline_css.= ' html { background: ' . $bg_color_hex . '}
body{
background: ' . $bg_color_hex . ';
height:auto!important;
overflow-x:hidden!important;overflow-y:hidden!important;
}
.jp-repeat, .jp-repeat-off{
right:34px!important;
}
.jp-shuffle, .jp-shuffle-off{
right:10px!important;
} ';
endif;
$inline_css.= '
.wolf-jplayer-playlist-container, .wolf-jplayer-playlist a{
color: ' . $font_color . '!important;
}
.wolf-jplayer-playlist .jp-play-bar, .wolf-jplayer-playlist .jp-volume-bar-value{
background-color: ' . $font_color . '
}
.wolf-jplayer-loader-overlay{
background-color: ' . $bg_color_hex . '
}
.wolf-jplayer-playlist-container{
background-color:rgba(' . $bg_color_rgba . ',' . $opacity . ');
}
.wolf-jplayer-playlist-container .mCSB_scrollTools .mCSB_dragger_bar{
background-color: ' . $font_color . ';
}
}
';
if ($playlist_height)
{
$inline_css.= '.wolf-jplayer-playlist-container.wolf-jplayer-scrollbar .jp-playlist{
max-height : ' . $playlist_height . 'px; }';
}
$inline_css.= '
.wolf-music-logo-link{ border:none!important; }
.wolf-music-logo {
border:none!important;
box-shadow:none!important; -moz-box-shadow:none!important;
-webkit-box-shadow:none!important;
-o-box-shadow:none!important; }';
e107::css('inline', $inline_css);
if (e107::pref('jm_jplayer', 'scrollbar'))
{
e107::css('jm_jplayer', '/assets/css/min/mCustomScrollbar.min.css');
e107::js('footer', '{e_PLUGIN}/jm_jplayer/assets/js/min/jquery.mCustomScrollbar.concat.min.js', 'jquery', 3);
}
$inline_script = '
var WolfjPlayerParams = {
"iTunesText": "' .LAN_FRONT_01 . '",
"amazonText": "' . LAN_FRONT_02 . '",
"buyNowText": "' . LAN_FRONT_03 . '",
"downloadText": "' .LAN_FRONT_04. '",
"byText": "' .LAN_FRONT_05. '",
"scrollBar": "",
"skin": "' .$skin. '",
};
';
e107::js('inline', $inline_script, 'jquery', 4);
e107::js('footer', '{e_PLUGIN}/jm_jplayer/assets/js/min/jquery.jplayer.concat.min.js', 'jquery', 5);
// THIS CLASS IS FOR FUTURE USING
class jm_jplayer_plugin_shortcodes extends e_shortcode
{
protected $jmpref = array();
public
function __construct()
{
$this->jmpref = e107::pref('jm_jplayer');
}
function sc_playlist_name($parm = null)
{
return e107::getParser()->toHtml($this->var['name'], true, 'TITLE');
}
}
// THIS CLASS IS FOR FUTURE USING
class jm_jplayer
{
protected $jmpref = array();
public
function __construct()
{
$this->sc = new jm_jplayer_plugin_shortcodes();
$this->get = $_GET;
$this->post = $_POST;
}
private
function renderForm()
{
$frm = e107::getForm();
if (!USER)
{
}
return $text;
}
public
function render()
{
$ns = e107::getRender();
}
public
function head_css($id, $playlist_id, $songs, $in_popup, $autoplay = false)
{
}
}
if (!class_exists('Wolf_Jplayer_Show'))
{
/**
* WolfJplayer output class
*
* @package WolfJplayer
* @since WolfJplayer 1.0.0
*/
class Wolf_Jplayer_Show
{
/**
* Output popup JS in wp_head
*
* @return string
*/
public
function popup()
{
$popup = 'jQuery(".wolf-jp-popup").click(function() {
Player = $(this).parent().prev();
Player.jPlayer("stop");
var url = jQuery(this).attr("href");
var popupHeight = jQuery(this).parents(".wolf-jplayer-playlist-container").height();
var popup = window.open(url,"null", "height=" + popupHeight + ",width=570, top=150, left=150");
if (window.focus) {
popup.focus();
}
return false;
});';
return $popup;
}
/**
* Check if a default playlist poster is set
*
* Otherwise, return the default image from the images folder : default_poster.png
*
* @param int $playlist_id
* @return string
*/
public
function get_default_playlist_poster($playlist_id)
{
$sql = e107::getDb();
$tp = e107::getParser();
$where = 'id=' . $playlist_id;
$poster = $sql->retrieve('jm_jplayer_playlists', 'poster', $where);
return $poster ? $tp->replaceConstants($poster, 'full') : e_PLUGIN . 'jm_jplayer/assets/images/default_poster.png';
}
/**
* Output inline jplayer javascript
*
* @param int $id
* @param int $playlist_id
* @param array $songs
* @param bool $popup
* @param bool $autoplay
* @return string
*/
public
function head_script($id, $playlist_id, $songs, $in_popup, $autoplay = false)
{
$output = '';
$playlist = '';
$artist = '';
$free = null;
$external = 0;
$tp = e107::getParser();
if ($songs)
{
foreach($songs as $song)
{
$free = $song['free'];
if ($song['poster'])
{
$poster = $tp->replaceConstants($song['poster'], 'full');
}
else
{
$poster = $this->get_default_playlist_poster($playlist_id);
}
$playlist.= '{ title : "' . $song['name'] . '", mp3:"' . $tp->replaceConstants($song['mp3'], 'full') . '"';
if ($song['artist']) $playlist.= ', artist : "' . $song['artist'] . '" ';
if ($free != '1')
{
if ($song['itunes']) $playlist.= ', itunes : "' . $tp->toText($song['itunes']) . '" ';
if ($song['amazon']) $playlist.= ', amazon : "' . $tp->toText($song['amazon']) . '" ';
if ($song['buy']) $playlist.= ', buy : "' . $tp->toText($song['buy']) . '" ';
}
else
{
$playlist.= ',download : "' . $tp->replaceConstants($song['mp3'], 'full') . '" '; // is free
}
$playlist.= ',poster : "' . $poster . '" ';
$playlist.= ' },';
}
$playlist = substr($playlist, 0, -1);
$output.= '<script type="text/javascript">//<![CDATA[';
$output.= "\n";
$output.= 'jQuery(document).ready(function($) {
new jPlayerPlaylist( {
jPlayer: "#jquery_jplayer_' . $id . '",
cssSelectorAncestor: "#jp_container_' . $id . '" },
[' . $playlist . '], {
swfPath: "' . e_PLUGIN . 'jm_jplayer/assets/js/src",
wmode: "window"';
// $output .= ', solution:"html, flash"';
if ($autoplay && $autoplay == 'on')
{
$output.= ',
playlistOptions: { autoPlay : true }';
}
$output.= '});'; // end playlist
if (!$in_popup) $output.= $this->popup();
$output.= '});'; // end document ready playlist
$output.= '//]]></script>';
}
echo $output;
}
/**
* Output jplayer HTML
*
* @param int $playlist_id
* @param bool $in_popup
* @param bool $embed
* @return string
*/
public
function jplayer_show_playlist($playlist_id, $in_popup, $embed = false)
{
$sql = e107::getDb();
$tp = e107::getParser();
$wolf_jplayer_playlists_table = '#jm_jplayer_playlists';
$wolf_jplayer_table = '#jm_jplayer';
$playlist = $sql->retrieve("SELECT * FROM $wolf_jplayer_playlists_table WHERE id = '$playlist_id'", TRUE);
$songs = $sql->retrieve("SELECT * FROM $wolf_jplayer_table WHERE playlist_id = '$playlist_id' ORDER BY position", TRUE);
$autoplay = null;
$playlist = $playlist[0];
if ($playlist) $share_title = $playlist['name'] . ' | ' . SITENAME;
else $share_title = SITENAME;
$id = $playlist_id . rand(1, 999);
if ($playlist && $songs):
$autoplay = $playlist['autoplay'];
$max_song_count = e107::pref('jm_jplayer', 'song_count_before_scroll');
$count_songs = (e107::pref('jm_jplayer', 'scrollbar') && $max_song_count) ? $max_song_count : count($songs);
$player_height = 170 + 35 * $count_songs;
$logo = null;
$html = $this->head_script($id, $playlist_id, $songs, $in_popup, $autoplay);
$poster = $this->get_default_playlist_poster($playlist_id);
$playlisturl = e_PLUGIN_ABS . 'jm_jplayer/jplayer.php?playlist_id=' . $playlist_id;
if ($playlist['logo'])
{
$logo = "background-image : url( '" . $tp->replaceConstants($playlist['logo'], 'full') . "' );";
}
// $mobile_class = wp_is_mobile() ?' wolf-jplayer-is-mobile' : '';
$scrollbar_class = e107::pref('jm_jplayer', 'scrollbar') ? ' wolf-jplayer-scrollbar' : '';
$html.= '<!-- jPlayer -->
<div class="wolf-jplayer-playlist-container' . $mobile_class . $scrollbar_class . '">
<div class="wolf-jp-blur-bg" style="background-image:url( ' . $poster . ' );"></div>
<div class="wolf-jplayer-loader-overlay"><div class="wolf-jplayer-loader"></div></div>
<div class="wolf-jplayer-playlist">
<div class="wolf-jp-share-overlay">
<div class="wolf-jp-share-container">
<div class="wolf-jp-share">
<div>
<p><strong>Share</strong></p>
</div>
<!--<div class="wolf-share-input">
<label>url : </label>
<div>
<input onclick="this.focus();this.select()" type="text" value="' . $playlisturl . '">
</div>
</div>-->
<div class="wolf-share-input">
<label>embed : </label>
<div>
<input onclick="this.focus();this.select()" type="text" value="<iframe width="100%" height="' . $player_height . '" scrolling="no" frameborder="no" src="' . $playlisturl . '&iframe=true&wmode=transparent"></iframe>">
</div>
</div>
<div class="clear"></div>
<div class="wolf-jp-share-socials">
<a class="wolf-share-jp-popup" href="http://www.facebook.com/sharer.php?u=' . $playlisturl . '&t=' . urlencode($share_title) . '" title="' . LAN_FRONT_06 . '" target="_blank">
<span id="wolf-jplayer-facebook-button"></span>
</a>
<a class="wolf-share-jp-popup" href="http://twitter.com/home?status=' . urlencode($share_title . ' - ') . $playlisturl . '" title="' . LAN_FRONT_07 . '" target="_blank">
<span id="wolf-jplayer-twitter-button"></span>
</a>
</div>
<span class="close-wolf-jp-share" title="' . LAN_FRONT_08 . '">×</span>
</div>
</div>
</div>
<div id="jplayer_container_' . $id . '" class="jplayer_container">
<div id="jquery_jplayer_' . $id . '" class="jp-jplayer"></div>
<div id="jp_container_' . $id . '" class="jp-audio">
<div class="jp-logo" style="' . $logo . '"></div>
<span title="' . LAN_FRONT_09 . '" class="wolf-jp-menu-icon"></span>';
if (!$in_popup) $html.= '';
$html.= '<div class="jp-type-playlist">
<div class="jp-gui jp-interface">
<ul class="jp-controls">
<li><a href="javascript:;" class="jp-previous" tabindex="1"></a></li>
<li><a href="javascript:;" class="jp-play" tabindex="1"></a></li>
<li><a href="javascript:;" class="jp-pause" tabindex="1"></a></li>
<li><a href="javascript:;" class="jp-next" tabindex="1"></a></li>
<li><a href="javascript:;" class="jp-stop" tabindex="1"></a></li>
<li class="wolf-volume">
<a href="javascript:;" class="jp-mute" tabindex="1" title="mute"></a>
<a href="javascript:;" class="jp-unmute" tabindex="1" title="unmute"></a>
</li>
<li><a href="javascript:;" class="jp-volume-max wolf-volume" tabindex="1" title="max volume"></a></li>
</ul>
<div class="jp-progress">
<div class="jp-seek-bar">
<div class="jp-play-bar"></div>
</div>
</div>
<div class="jp-volume-bar wolf-volume">
<div class="jp-volume-bar-value"></div>
</div>
<div class="jp-current-time"></div>
<div class="jp-duration"></div>
<ul class="jp-toggles">
<li id="wolf-jp-shuffle">
<a href="javascript:;" class="jp-shuffle" tabindex="1" title="' . LAN_FRONT_10 . '">
<a href="javascript:;" class="jp-shuffle-off" tabindex="1" title="' . LAN_FRONT_11 . '"></a></a>
</li>
<li id="wolf-jp-repeat">
<a href="javascript:;" class="jp-repeat" tabindex="1" title="' . LAN_FRONT_12 . '"></a>
<a href="javascript:;" class="jp-repeat-off" tabindex="1" title="' . LAN_FRONT_13 . '"></a>
</li>
<li id="wolf-jp-share"><span title="' . LAN_FRONT_14 . '" class="wolf-jp-share-icon"></span></li>
<li id="wolf-jp-popup"><a href="' . $playlisturl . '&iframe=false" class="wolf-jp-popup" title="popup window"></a></li>
</ul>
</div>
<div class="jp-playlist">
<ul>
<li></li>
</ul>
</div>
<div class="jp-no-solution">
<span>Update Required</span>
To play the media you will need to either update your browser to a recent version or update your <a href="http://get.adobe.com/flashplayer/" target="_blank">Flash plugin</a>.
</div>
</div>
</div>
</div>
</div>
</div>
<!-- End jPlayer -->';
else:
if (USER) $html = '<p style="text-shadow:none!important"><em>' . LAN_FRONT_15 . '</em></p>';
else $html = '<p style="text-shadow:none!important"><em>' . LAN_FRONT_16 . '</em></p>';
endif;
return $html;
}
/**
* Output jplayer HTML
*
* @param int $playlist_id
* @param bool $in_popup
* @param bool $embed
* @return string
*/
public
function jplayer_show_single($playlist_id, $in_popup, $embed = false)
{
$html = '<div id="wolf-jplayer-single-page">';
$html.= $this->jplayer_show_playlist($playlist_id, $in_popup, $embed, true);
$html.= '</div>';
return $html;
}
/**
* Output jplayer HTML
*
* @param int $playlist_id
* @param bool $in_popup
* @param bool $embed
* @return string
*/
public
function jplayer_show_iframe($playlist_id, $in_popup, $embed = false)
{
$embed = true;
$in_popup = false;
define('e_IFRAME', true);
require_once (HEADERF);
$html = $this->jplayer_show_playlist($playlist_id, $in_popup, $embed, true);
return $html;
}
}
}