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: 514: 515: 516: 517: 518: 519: 520: 521: 522: 523: 524: 525: 526: 527: 528: 529: 530: 531: 532: 533: 534: 535: 536: 537: 538: 539: 540: 541: 542: 543: 544: 545: 546: 547: 548: 549: 550: 551: 552: 553: 554: 555: 556: 557: 558: 559: 560: 561: 562: 563: 564: 565: 566: 567: 568: 569: 570: 571: 572: 573: 574: 575: 576: 577: 578: 579: 580: 581: 582: 583: 584: 585: 586: 587: 588: 589: 590: 591: 592: 593: 594: 595: 596: 597: 598: 599: 600: 601: 602: 603: 604: 605: 606: 607: 608: 609: 610: 611: 612: 613: 614: 615: 616: 617: 618: 619: 620: 621: 622: 623: 624: 625: 626: 627: 628: 629: 630: 631: 632: 633: 634: 635: 636: 637: 638: 639: 640: 641: 642: 643: 644: 645: 646: 647: 648: 649: 650: 651: 652: 653: 654: 655: 656: 657: 658: 659: 660: 661: 662: 663: 664: 665: 666: 667: 668: 669: 670: 671: 672: 673: 674: 675: 676: 677: 678: 679: 680: 681: 682: 683: 684: 685: 686: 687: 688: 689: 690: 691: 692: 693: 694: 695: 696: 697: 698: 699: 700: 701: 702: 703: 704: 705: 706: 707: 708: 709: 710: 711: 712: 713: 714: 715: 716: 717: 718: 719: 720: 721: 722: 723: 724: 725: 726: 727: 728: 729: 730: 731: 732: 733: 734: 735: 736: 737: 738: 739: 740: 741: 742: 743: 744: 745: 746: 747: 748: 749: 750: 751: 752: 753: 754: 755: 756: 757: 758: 759: 760: 761: 762: 763: 764: 765: 766: 767: 768: 769: 770: 771: 772: 773: 774: 775: 776: 777: 778: 779: 780: 781: 782: 783: 784: 785: 786: 787: 788: 789: 790: 791: 792: 793: 794: 795: 796: 797: 798: 799: 800: 801: 802: 803: 804: 805: 806: 807: 808: 809: 810: 811: 812: 813: 814: 815: 816: 817: 818: 819: 820: 821: 822: 823: 824: 825: 826: 827: 828: 829: 830: 831: 832: 833: 834: 835: 836: 837: 838: 839: 840: 841: 842: 843: 844: 845: 846: 847: 848:
<?php
$plugin_is_filter = 5 | CLASS_PLUGIN;
$plugin_description = gettext("Enable <strong>jPlayer</strong> to handle multimedia files.");
$plugin_notice = gettext("<strong>IMPORTANT</strong>: Only one multimedia extension plugin can be enabled at the time and the class-video plugin must be enabled, too.") . '<br /><br />' . gettext("Please see <a href='http://jplayer.org'>jplayer.org</a> for more info about the player and its license.");
$plugin_author = "Malte Müller (acrylian)";
$plugin_disable = ((getOption('album_folder_class') === 'external') ? gettext('This player does not support <em>External Albums</em>.') : extensionEnabled('class-video')) ? false : gettext('The class-video plugin must be enabled for video support.');
$plugin_category = gettext('Media');
$option_interface = 'jplayer_options';
if (!empty($_zp_multimedia_extension->name) || $plugin_disable) {
enableExtension('jplayer', 0);
if (isset($_zp_multimedia_extension)) {
trigger_error(sprintf(gettext('jPlayer not enabled, %s is already instantiated.'), get_class($_zp_multimedia_extension)), E_USER_NOTICE);
}
} else {
Gallery::addImageHandler('flv', 'Video');
Gallery::addImageHandler('fla', 'Video');
Gallery::addImageHandler('mp3', 'Video');
Gallery::addImageHandler('mp4', 'Video');
Gallery::addImageHandler('m4v', 'Video');
Gallery::addImageHandler('m4a', 'Video');
zp_register_filter('content_macro', 'jPlayer::macro');
}
class jplayer_options {
public $name = 'jPlayer';
function __construct() {
if (OFFSET_PATH == 2) {
setOptionDefault('jplayer_autoplay', '');
setOptionDefault('jplayer_poster', 1);
setOptionDefault('jplayer_postercrop', 1);
setOptionDefault('jplayer_showtitle', '');
setOptionDefault('jplayer_playlist', '');
setOptionDefault('jplayer_playlist_numbered', 1);
setOptionDefault('jplayer_playlist_playtime', 0);
setOptionDefault('jplayer_download', '');
setOptionDefault('jplayer_size', 'jp-video-270p');
setOptionDefault('jplayer_skin', 'zenphotolight');
setOptionDefault('jplayer_counterparts', 0);
}
}
function getOptionsSupported() {
$skins = getjPlayerSkins();
return array(gettext('Autoplay') => array(
'key' => 'jplayer_autoplay',
'type' => OPTION_TYPE_CHECKBOX,
'desc' => gettext("Disabled automatically if several players on one page")),
gettext('Poster (Videothumb)') => array(
'key' => 'jplayer_poster',
'type' => OPTION_TYPE_CHECKBOX,
'desc' => gettext("If the videothumb should be shown (jplayer calls it poster).")),
gettext('Audio poster (Videothumb)') => array(
'key' => 'jplayer_audioposter',
'type' => OPTION_TYPE_CHECKBOX,
'desc' => gettext("If the poster should be shown for audio files (mp3,m4a,fla) (does not apply for playlists which are all or none).")),
gettext('Show title') => array(
'key' => 'jplayer_showtitle',
'type' => OPTION_TYPE_CHECKBOX,
'desc' => gettext("If the title should be shown below the player in single player mode (not needed on normal themes) (ignored in playlists naturally).")),
gettext('Playlist support') => array(
'key' => 'jplayer_playlist',
'type' => OPTION_TYPE_CHECKBOX,
'desc' => gettext("Enable this if you wish to use the playlist mode this loads the scripts needed. NOTE: You have to add the function printjPlayerPlaylist() to your theme yourself. See the documentation for info.")),
gettext('Playlist numbered') => array(
'key' => 'jplayer_playlist_numbered',
'type' => OPTION_TYPE_CHECKBOX,
'desc' => gettext("Enable this if you wish the playlist to be numbered.")),
gettext('Playlist playtime') => array(
'key' => 'jplayer_playlist_playtime',
'type' => OPTION_TYPE_CHECKBOX,
'desc' => gettext("Enable if you want to show the playtime of playlist entries.")),
gettext('Enable download') => array(
'key' => 'jplayer_download',
'type' => OPTION_TYPE_CHECKBOX,
'desc' => gettext("Enables direct file downloads (playlists only).")),
gettext('Player size') => array(
'key' => 'jplayer_size',
'type' => OPTION_TYPE_SELECTOR,
'selections' => array(
gettext('jp-video-270p (480x270px)') => "jp-video-270p",
gettext('jp-video-360p (640x360px)') => "jp-video-360p",
gettext('jp-video-480p (720x405px)*') => "jp-video-480p",
gettext('jp-video-720p (1280x720px)*') => "jp-video-720p",
gettext('jp-video-1080p (1920x1080px)*') => "jp-video-1080p"),
'desc' => gettext("jPlayer is dependent on their HTML and CSS based skin. Sizes marked with a <strong>*</strong> are supported by the two Zenphoto custom skins only (these two skins are also responsive in width). If you need different sizes you need to modify a skin or make your own and also need to change values in the plugin class method getPlayerSize().")),
gettext('Player skin') => array(
'key' => 'jplayer_skin',
'type' => OPTION_TYPE_SELECTOR,
'selections' => $skins,
'desc' => gettext("Select the skin (theme) to use. <br />NOTE: Since the skin is pure HTML/CSS only there may be display issues with certain themes that require manual adjustments. The two Zenphoto custom skins are responsive regarding the player width. Place custom skin within the root plugins folder. See plugin documentation for more info."))
);
}
}
function getjPlayerSkins() {
$default_skins_dir = SERVERPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/jplayer/skin/';
$user_skins_dir = SERVERPATH . '/' . USER_PLUGIN_FOLDER . '/jplayer/skin/';
$filestoignore = array('.', '..', '.DS_Store', 'Thumbs.db', '.htaccess', '.svn');
$skins = array_diff(scandir($default_skins_dir), array_merge($filestoignore));
$default_skins = getjPlayerSkinCSS($skins, $default_skins_dir);
$skins2 = @array_diff(scandir($user_skins_dir), array_merge($filestoignore));
if (is_array($skins2)) {
$user_skins = getjPlayerSkinCSS($skins2, $user_skins_dir);
$default_skins = array_merge($default_skins, $user_skins);
}
return $default_skins;
}
function getjPlayerSkinCSS($skins, $dir) {
$skin_css = array();
foreach ($skins as $skin) {
$css = safe_glob($dir . $skin . '/*.css');
if ($css) {
$skin_css = array_merge($skin_css, array($skin => $skin));
}
}
return $skin_css;
}
class jPlayer {
public $width = '';
public $height = '';
public $playersize = '';
public $mode = '';
public $supplied = '';
public $supplied_counterparts = '';
function __construct() {
$this->playersize = getOption('jplayer_size');
switch ($this->playersize) {
case 'jp-video-270p':
$this->width = 480;
$this->height = 270;
break;
case 'jp-video-360p':
$this->width = 640;
$this->height = 360;
break;
case 'jp-video-480p':
$this->width = 720;
$this->height = 405;
break;
case 'jp-video-720p':
$this->width = 1280;
$this->height = 720;
break;
case 'jp-video-1080p':
$this->width = 1920;
$this->height = 1080;
break;
}
}
static function getMacrojplayer($albumname, $imagename, $count = 1) {
global $_zp_multimedia_extension;
$movie = newImage(NULL, array('folder' => $albumname, 'filename' => $imagename), true);
if ($movie->exists) {
return $_zp_multimedia_extension->getPlayerConfig($movie, NULL, (int) $count);
} else {
return '<span class = "error">' . sprintf(gettext('%1$s::%2$s not found.'), $albumname, $imagename) . '</span>';
}
}
static function macro($macros) {
$macros['MEDIAPLAYER'] = array(
'class' => 'function',
'params' => array('string', 'string', 'int*'),
'value' => 'jplayer::getMacrojplayer',
'owner' => 'jplayer',
'desc' => gettext('provide the album name (%1), media file name (%2) and a unique number (%3). (If there is only player instance on the page the parameter may be omitted.)')
);
return $macros;
}
static function headJS() {
$skin = @array_shift(getPluginFiles('*.css', 'jplayer/skin/' . getOption('jplayer_skin')));
if (file_exists($skin)) {
$skin = str_replace(SERVERPATH, WEBPATH, $skin);
} else {
$skin = WEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/jplayer/skin/zenphotolight/jplayer.zenphotolight.css';
}
?>
<link href="<?php echo $skin; ?>" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<?php echo WEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER; ?>/jplayer/js/jquery.jplayer.min.js"></script>
<?php
}
static function playlistJS() {
?>
<script type="text/javascript" src="<?php echo WEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER; ?>/jplayer/js/jplayer.playlist.min.js"></script>
<?php
}
function getPlayerConfig($movie, $movietitle = NULL, $count = NULL) {
$moviepath = $movie->getFullImage(FULLWEBPATH);
if (is_null($movietitle)) {
$movietitle = $movie->getTitle();
}
$ext = getSuffix($moviepath);
if (!in_array($ext, array('m4a', 'm4v', 'mp3', 'mp4', 'flv', 'fla'))) {
return '<span class="error">' . gettext('This multimedia format is not supported by jPlayer') . '</span>';
}
$this->setModeAndSuppliedFormat($ext);
if (empty($count)) {
$multiplayer = false;
$count = '1';
} else {
$multiplayer = true;
$count = $count;
}
$autoplay = '';
if (getOption('jplayer_autoplay') && !$multiplayer) {
$autoplay = '.jPlayer("play")';
}
$videoThumb = '';
if (getOption('jplayer_poster') && ($this->mode == 'video' || ($this->mode == 'audio' && getOption('jplayer_audioposter')))) {
$videoThumb = ',poster:"' . $movie->getCustomImage(null, $this->width, $this->height, $this->width, $this->height, null, null, true) . '"';
}
$playerconfig = '
<script type="text/javascript">
//<![CDATA[
$(document).ready(function(){
$("#jquery_jplayer_' . $count . '").jPlayer({
ready: function (event) {
$(this).jPlayer("setMedia", {
' . $this->supplied . ':"' . pathurlencode($moviepath) . '"
' . $this->getCounterpartFiles($moviepath, $ext) . '
' . $videoThumb . '
})' . $autoplay . ';
},
swfPath: "' . WEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/jplayer/js",
supplied: "' . $this->supplied . $this->supplied_counterparts . '",
cssSelectorAncestor: "#jp_container_' . $count . '"';
if ($multiplayer) {
$playerconfig .= ',
play: function() { // To avoid both jPlayers playing together.
$(this).jPlayer("pauseOthers");
}
';
}
if ($this->mode == 'video' || ($this->mode == 'audio' && getOption('jplayer_poster') && getOption('jplayer_audioposter'))) {
$playerconfig .= '
, size: {
width: "100%",
height: "' . $this->height . 'px",
cssClass: "' . $this->playersize . '"
},';
} else {
$playerconfig .= ',';
}
$playerconfig .= '
useStateClassSkin: true,
remainingDuration: true,
toggleDuration: true
});
});
//]]>
</script>';
if ($this->mode == 'video' || !empty($videoThumb)) {
$playerconfig .= '
<div id="jp_container_' . $count . '" class="jp-video ' . $this->playersize . '" role="application" aria-label="media player">
<div class="jp-type-single">
<div id="jquery_jplayer_' . $count . '" class="jp-jplayer"></div>
<div class="jp-gui">
<div class="jp-video-play">
<button class="jp-video-play-icon" role="button" tabindex="0">' . gettext('play') . '</button>
</div>
<div class="jp-interface">
<div class="jp-progress">
<div class="jp-seek-bar">
<div class="jp-play-bar"></div>
</div>
</div>
<div class="jp-current-time" role="timer" aria-label="time"> </div>
<div class="jp-duration" role="timer" aria-label="duration"> </div>
<div class="jp-controls-holder">';
$playerconfig .= $this->getPlayerHTMLparts($this->mode, 'controls');
$playerconfig .= '
<div class="jp-volume-controls">
<button class="jp-mute" role="button" tabindex="0">' . gettext('mute') . '</button>
<button class="jp-volume-max" role="button" tabindex="0">' . gettext('max volume') . '</button>
<div class="jp-volume-bar">
<div class="jp-volume-bar-value"></div>
</div>
</div>';
$playerconfig .= $this->getPlayerHTMLparts($this->mode, 'toggles');
$playerconfig .= '
</div>';
$playerconfig .= '
</div>
</div>';
if (getOption('jplayer_showtitle')) {
$playerconfig .= '
<div class="jp-details">
<div class="jp-title" aria-label="title">' . html_encode($movietitle) . '</div>
</div>';
}
$playerconfig .= $this->getPlayerHTMLparts($this->mode, 'no-solution');
$playerconfig .= '
</div>
</div>
';
} else {
$playerconfig .= '
<div id="jquery_jplayer_' . $count . '" class="jp-jplayer"></div>
<div id="jp_container_' . $count . '" class="jp-audio" role="application" aria-label="media player">
<div class="jp-type-single">
<div class="jp-gui jp-interface">';
$playerconfig .= $this->getPlayerHTMLparts($this->mode, 'controls');
$playerconfig .= '
<div class="jp-progress">
<div class="jp-seek-bar">
<div class="jp-play-bar"></div>
</div>
</div>
<div class="jp-volume-controls">
<button class="jp-mute" role="button" tabindex="0">' . gettext('mute') . '</button>
<button class="jp-volume-max" role="button" tabindex="0">' . gettext('max volume') . '</button>
<div class="jp-volume-bar">
<div class="jp-volume-bar-value"></div>
</div>
</div>
<div class="jp-time-holder">
<div class="jp-current-time" role="timer" aria-label="time"> </div>
<div class="jp-duration" role="timer" aria-label="duration"> </div>';
$playerconfig .= $this->getPlayerHTMLparts($this->mode, 'toggles');
$playerconfig .= '
</div>
</div>';
if (getOption('jplayer_showtitle')) {
$playerconfig .= '
<div class="jp-details">
<div class="jp-title" aria-label="title">' . html_encode($movietitle) . '</div>
</div>';
}
$playerconfig .= $this->getPlayerHTMLparts($this->mode, 'no-solution');
$playerconfig .= '
</div>
</div>
';
}
return $playerconfig;
}
function printPlayerConfig($movie = NULL, $movietitle = NULL, $count = NULL) {
global $_zp_current_image;
if (empty($movie)) {
$movie = $_zp_current_image;
}
echo $this->getPlayerConfig($movie, $movietitle, $count, NULL, NULL);
}
function getPlayerHTMLparts($mode = '', $part = '') {
$htmlpart = '';
switch ($part) {
case 'controls':
case 'controls-playlist':
$htmlpart = '<div class="jp-controls">';
if ($part == 'controls-playlist') {
$htmlpart .= '<button class="jp-previous" role="button" tabindex="0">' . gettext('previous') . '</button>';
}
$htmlpart .= '<button class="jp-play" role="button" tabindex="0">' . gettext('play') . '</button>';
if ($part == 'controls-playlist') {
$htmlpart .= '<button class="jp-next" role="button" tabindex="0">' . gettext('next') . '</button> ';
}
$htmlpart .= '<button class="jp-stop" role="button" tabindex="0">' . gettext('stop') . '</button>';
$htmlpart .= '</div>';
break;
case 'toggles':
case 'toggles-playlist':
$htmlpart = '<div class="jp-toggles">';
$htmlpart .= '<button class="jp-repeat" role="button" tabindex="0">' . gettext('repeat') . '</button>';
if ($part == 'toggles-playlist') {
$htmlpart .= '<button class="jp-shuffle" role="button" tabindex="0">' . gettext('shuffle') . '</button>';
}
if ($mode == 'video') {
$htmlpart .= '<button class="jp-full-screen" role="button" tabindex="0">' . gettext('full screen') . '</button>';
}
$htmlpart .= '</div>';
break;
case 'no-solution':
$htmlpart = '
<div class="jp-no-solution">
<span>' . gettext('Update Required') . '</span>
' . gettext('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>';
break;
}
return $htmlpart;
}
function getWidth($image = NULL) {
if (!is_null($image) && $this->mode == 'audio' && !getOption('jplayer_poster') && !getOption('jplayer_audioposter')) {
return 420;
}
return $this->width;
}
function getHeight($image = NULL) {
if (!is_null($image) && $this->mode == 'audio' && !getOption('jplayer_poster') && !getOption('jplayer_audioposter')) {
return 0;
}
return $this->height;
}
function setModeAndSuppliedFormat($ext) {
switch ($ext) {
case 'm4a':
case 'mp3':
case 'fla':
$this->mode = 'audio';
switch ($ext) {
case 'm4a':
$this->supplied = 'm4a';
break;
case 'mp3':
$this->supplied = 'mp3';
break;
case 'fla':
$this->supplied = 'fla';
break;
}
break;
case 'mp4':
case 'm4v':
case 'flv':
$this->mode = 'video';
switch ($ext) {
case 'm4v':
case 'mp4':
$this->supplied = 'm4v';
break;
case 'flv':
$this->supplied = 'flv';
break;
}
break;
}
}
function getCounterpartFiles($moviepath, $ext) {
$counterparts = '';
switch ($ext) {
case 'mp3':
case 'm4a':
case 'fla':
$suffixes = array('oga', 'webma');
break;
case 'mp4':
case 'm4v':
case 'flv':
$suffixes = array('ogv', 'webmv');
break;
default:
$suffixes = array();
break;
}
foreach ($suffixes as $suffix) {
$filesuffix = $suffix;
$counterpart = str_replace($ext, $filesuffix, $moviepath);
if (file_exists(str_replace(FULLWEBPATH, SERVERPATH, $counterpart))) {
$this->supplied_counterparts .= ',' . $suffix;
$counterparts .= ',' . $suffix . ':"' . pathurlencode($counterpart) . '"';
}
}
return $counterparts;
}
function printjPlayerPlaylist($option = "playlist", $albumfolder = "") {
global $_zp_current_album, $_zp_current_search;
if (empty($albumfolder)) {
if (in_context(ZP_SEARCH)) {
$albumobj = $_zp_current_search;
} else {
$albumobj = $_zp_current_album;
}
} else {
$albumobj = newAlbum($albumfolder);
}
$entries = $albumobj->getImages(0);
if (($numimages = count($entries)) != 0) {
switch ($option) {
case 'playlist':
$suffixes = array('m4a', 'm4v', 'mp3', 'mp4', 'flv', 'fla');
break;
case 'playlist-audio':
$suffixes = array('m4a', 'mp3', 'fla');
break;
default:
return;
}
if (in_context(ZP_SEARCH)) {
$id = '1';
} else {
$id = $albumobj->getID();
}
?>
<script type="text/javascript">
$(document).ready(function(){
new jPlayerPlaylist({
jPlayer: "#jquery_jplayer_<?php echo $id; ?>",
cssSelectorAncestor: "#jp_container_<?php echo $id; ?>"
}, [
<?php
$count = '';
$number = '';
foreach ($entries as $entry) {
$count++;
if (is_array($entry)) {
$ext = getSuffix($entry['filename']);
} else {
$ext = getSuffix($entry);
}
$numbering = '';
if (in_array($ext, $suffixes)) {
$number++;
if (getOption('jplayer_playlist_numbered')) {
$numbering = '<span>' . $number . '</span>';
}
if (is_array($entry)) {
$albumobj = newAlbum($entry['folder']);
$video = newImage($albumobj, $entry['filename']);
} else {
$video = newImage($albumobj, $entry);
}
$videoThumb = '';
$this->setModeAndSuppliedFormat($ext);
if ($option == 'playlist' && getOption('jplayer_poster')) {
$videoThumb = ',poster:"' . $video->getCustomImage(null, $this->width, $this->height, $this->width, $this->height, null, null, true) . '"';
}
$playtime = '';
if (getOption('jplayer_playlist_playtime')) {
$playtime = ' (' . $video->get('VideoPlaytime') . ')';
}
?>
{
title:"<?php echo $numbering . html_encode($video->getTitle()) . $playtime; ?>",
<?php if (getOption('jplayer_download')) { ?>
free:true,
<?php } ?>
<?php echo $this->supplied; ?>:"<?php echo html_encode(pathurlencode($url = $video->getFullImage(FULLWEBPATH))); ?>"
<?php echo $this->getCounterpartFiles($url, $ext); ?>
<?php echo $videoThumb; ?>
}
<?php
if ($numimages != $count) {
echo ',';
}
}
}
?>
], {
swfPath: "<?php echo WEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER; ?>/jplayer/js",
solution: "flash,html",
<?php if ($option == 'playlist') { ?>
supplied: "m4v, mp4, m4a, mp3, fla, flv<?php echo $this->supplied_counterparts; ?>",
<?php } else { ?>
supplied: "m4a, mp3, fla<?php echo $this->supplied_counterparts; ?>",
<?php
}
if ($option != 'playlist-audio') {
?>
size: {
width: "<?php echo $this->width; ?>px",
height: "<?php echo $this->height; ?>px",
cssClass: "<?php echo $this->playersize; ?>"
},
<?php } ?>
useStateClassSkin: true,
autoBlur: false,
smoothPlayBar: true,
keyEnabled: true,
remainingDuration: true,
toggleDuration: true
});
});
</script>
<?php
if ($option == 'playlist') {
?>
<div id="jp_container_<?php echo $id; ?>" class="jp-video <?php echo $this->playersize; ?>" role="application" aria-label="media player">
<div class="jp-type-playlist">
<div id="jquery_jplayer_<?php echo $id; ?>" class="jp-jplayer"></div>
<div class="jp-gui">
<div class="jp-video-play">
<button class="jp-video-play-icon" role="button" tabindex="0"><?php echo gettext('play'); ?></button>
</div>
<div class="jp-interface">
<div class="jp-progress">
<div class="jp-seek-bar">
<div class="jp-play-bar"></div>
</div>
</div>
<div class="jp-current-time" role="timer" aria-label="time"> </div>
<div class="jp-duration" role="timer" aria-label="duration"> </div>
<div class="jp-controls-holder">
<?php echo $this->getPlayerHTMLparts('video', 'controls-playlist'); ?>
<div class="jp-volume-controls">
<button class="jp-mute" role="button" tabindex="0"><?php echo gettext('mute'); ?></button>
<button class="jp-volume-max" role="button" tabindex="0"><?php echo gettext('max volume'); ?></button>
<div class="jp-volume-bar">
<div class="jp-volume-bar-value"></div>
</div>
</div>
<?php echo $this->getPlayerHTMLparts('video', 'toggles-playlist'); ?>
</div>
<div class="jp-details">
<div class="jp-title" aria-label="title"> </div>
</div>
</div>
</div>
<div class="jp-playlist">
<ul>
<!-- The method Playlist.displayPlaylist() uses this unordered list -->
<li> </li>
</ul>
</div>
<?php echo $this->getPlayerHTMLparts('video', 'no-solution'); ?>
</div>
</div>
<?php
} else {
?>
<div id="jquery_jplayer_<?php echo $id; ?>" class="jp-jplayer"></div>
<div id="jp_container_<?php echo $id; ?>" class="jp-audio" role="application" aria-label="media player">
<div class="jp-type-playlist">
<div class="jp-gui jp-interface">
<?php echo $this->getPlayerHTMLparts('audio', 'controls-playlist'); ?>
<div class="jp-progress">
<div class="jp-seek-bar">
<div class="jp-play-bar"></div>
</div>
</div>
<div class="jp-volume-controls">
<button class="jp-mute" role="button" tabindex="0"><?php echo gettext('mute'); ?></button>
<button class="jp-volume-max" role="button" tabindex="0"><?php echo gettext('max volume'); ?></button>
<div class="jp-volume-bar">
<div class="jp-volume-bar-value"></div>
</div>
</div>
<div class="jp-time-holder">
<div class="jp-current-time" role="timer" aria-label="time"> </div>
<div class="jp-duration" role="timer" aria-label="duration"> </div>
</div>
<?php echo $this->getPlayerHTMLparts('audio', 'toggles-playlist'); ?>
</div>
<div class="jp-playlist">
<ul>
<li> </li>
</ul>
</div>
<?php echo $this->getPlayerHTMLparts('audio', 'no-solution'); ?>
</div>
</div>
<?php
}
}
}
}
function printjPlayerPlaylist($option = "playlist", $albumfolder = "") {
global $_zp_multimedia_extension;
$_zp_multimedia_extension->printjPlayerPlaylist($option, $albumfolder);
}
$_zp_multimedia_extension = new jPlayer();
zp_register_filter('theme_head', 'jplayer::headJS');
if (getOption('jplayer_playlist')) {
zp_register_filter('theme_head', 'jplayer::playlistJS');
}