PowerPress Podcasting plugin by Blubrry - Version 5.0.10

Version Description

  • Released on 12/16/2014
  • Update your copy of PowerPress to version 5.0.10 immediately
  • Due to concerns of possible security exploits, the FlowPlayer flash based player has been removed from PowerPress as of version 5.0.10. PowerPress users are strongly encouraged to update their copy of PowerPress immediately.
  • FlowPlayer will be replaced with the default WordPress MediaElement.js player.
Download this release

Release Info

Developer amandato
Plugin Icon 128x128 PowerPress Podcasting plugin by Blubrry
Version 5.0.10
Comparing to
See all releases

Code changes from version 5.0.9 to 5.0.10

FlowPlayerClassic.swf DELETED
Binary file
player.js CHANGED
@@ -151,19 +151,12 @@ function powerpress_embed_html5v(id,media_url,width,height,webm_media_url)
151
  document.getElementById('powerpress_player_'+id).innerHTML = '';
152
  document.getElementById('powerpress_player_'+id).appendChild(v);
153
  v.play();
154
- } else {
155
- delete(v);
156
- pp_flashembed(
157
- 'powerpress_player_'+id,
158
- {src: powerpress_url +'FlowPlayerClassic.swf', width: width, height: height, wmode: 'transparent' },
159
- {config: { autoPlay: true, autoBuffering: true, showFullScreenButton: true, showMenu: false, videoFile: media_url, loop: false, autoRewind: true, splashImageFile: poster } }
160
- );
161
  }
162
-
163
- if( window.powerpress_resize_player )
164
- powerpress_resize_player();
165
-
166
- return false; // stop the default link from proceeding
167
  }
168
 
169
  return true; // let the default link to the media open...
@@ -213,18 +206,8 @@ function powerpress_embed_html5a(id,media_url)
213
  document.getElementById('powerpress_player_'+id).innerHTML = '';
214
  document.getElementById('powerpress_player_'+id).appendChild(a);
215
  a.play();
216
- } else {
217
- delete(a);
218
- if( contentType != 'audio/ogg') {
219
- pp_flashembed(
220
- 'powerpress_player_'+id,
221
- {src: powerpress_url +'FlowPlayerClassic.swf', width: 320, height: 24, wmode: 'transparent' },
222
- {config: { autoPlay: true, autoBuffering: true, showFullScreenButton: false, showMenu: false, videoFile: media_url, loop: false, autoRewind: true } }
223
- );
224
- } else { return true; }
225
  }
226
-
227
- return false; // stop the default link from proceeding
228
  }
229
 
230
  return true; // let the default link to the media open...
151
  document.getElementById('powerpress_player_'+id).innerHTML = '';
152
  document.getElementById('powerpress_player_'+id).appendChild(v);
153
  v.play();
154
+
155
+ if( window.powerpress_resize_player )
156
+ powerpress_resize_player();
157
+
158
+ return false; // stop the default link from proceeding
 
 
159
  }
 
 
 
 
 
160
  }
161
 
162
  return true; // let the default link to the media open...
206
  document.getElementById('powerpress_player_'+id).innerHTML = '';
207
  document.getElementById('powerpress_player_'+id).appendChild(a);
208
  a.play();
209
+ return false; // stop the default link from proceeding
 
 
 
 
 
 
 
 
210
  }
 
 
211
  }
212
 
213
  return true; // let the default link to the media open...
powerpress-player.php CHANGED
@@ -58,17 +58,17 @@ function powerpressplayer_init($GeneralSettings)
58
 
59
 
60
  $enqueue_mejs = false;
61
- if( !isset($GeneralSettings['player']) || !isset($GeneralSettings['video_player']) )
62
- {
63
  if( version_compare($GLOBALS['wp_version'], '3.6-alpha', '>') )
64
  $enqueue_mejs = true;
65
- }
66
 
67
- if( !empty($GeneralSettings['player']) && $GeneralSettings['player'] == 'mediaelement-audio' )
68
  {
69
  $enqueue_mejs = true;
70
  }
71
- else if( !empty($GeneralSettings['video_player']) && $GeneralSettings['video_player'] == 'mediaelement-video' )
72
  {
73
  $enqueue_mejs = true;
74
  }
@@ -412,23 +412,7 @@ function powerpressplayer_build_embed($player, $media_url, $EpisodeData = array(
412
  function do_powerpressplayer_embed($player, $media_url, $EpisodeData = array())
413
  {
414
  // Includde the stuff we need...
415
- switch( $player )
416
- {
417
- case 'mejs-a':
418
- case 'mejs-v':
419
- case 'mediaelement-audio':
420
- case 'mediaelement-video': {
421
- // Enqueue stuff for mediaelements
422
-
423
- wp_enqueue_style('mediaelement');
424
- wp_enqueue_style('wp-mediaelement');
425
- wp_enqueue_script('mediaelement');
426
- //wp_enqueue_script( 'powerpress-mejs', powerpress_get_root_url() .'powerpress-mejs.js');
427
- }; break;
428
- default: {
429
- //wp_enqueue_script('jquery');
430
- }; break;
431
- }
432
  wp_enqueue_script('jquery');
433
 
434
  $content = '';
@@ -523,7 +507,7 @@ function do_powerpressplayer_embed($player, $media_url, $EpisodeData = array())
523
  if( !is_array($EpisodeData) )
524
  $EpisodeData = array();
525
 
526
- $content .= powerpressplayer_build_flowplayerclassic($media_url, $EpisodeData + array('jquery_autowidth'=>true) );
527
 
528
  // $content .= 'Video Flow Player Classic coming soon!';
529
  }; break;
@@ -1551,88 +1535,11 @@ function powerpressplayer_build_html5mobile($media_url, $EpisodeData)
1551
  /*
1552
  Flow Player Classic
1553
  */
1554
- function powerpressplayer_build_flowplayerclassic($media_url, $EpisodeData = array())
1555
  {
1556
- // Very important setting, we need to know if the media should auto play or not...
1557
- $autoplay = false; // (default)
1558
- if( !empty($EpisodeData['autoplay']) )
1559
- $autoplay = true;
1560
- $cover_image = '';
1561
- $player_width = 400;
1562
- $player_height = 225;
1563
- $Settings = get_option('powerpress_general');
1564
- // Global Settings
1565
- if( !empty($Settings['player_width']) )
1566
- $player_width = $Settings['player_width'];
1567
- if( !empty($Settings['player_height']) )
1568
- $player_height = $Settings['player_height'];
1569
- if( !empty($Settings['poster_image']) )
1570
- $cover_image = $Settings['poster_image'];
1571
- // Episode Settings
1572
- if( !empty($EpisodeData['width']) )
1573
- $player_width = $EpisodeData['width'];
1574
- if( !empty($EpisodeData['height']) )
1575
- $player_height = $EpisodeData['height'];
1576
- if( !empty($EpisodeData['image']) )
1577
- $cover_image = $EpisodeData['image'];
1578
-
1579
- $extension = powerpressplayer_get_extension($media_url, $EpisodeData);
1580
- if( ($extension == 'mp3' || $extension == 'm4a') && empty($Settings['poster_image_audio']) )
1581
- {
1582
- // FlowPlayer has differeent sizes for audio than for video
1583
- $player_width = 320;
1584
- if( !empty($Settings['player_width_audio']) )
1585
- $player_width = $Settings['player_width_audio'];
1586
-
1587
- if( !empty($EpisodeData['width']) && !empty($Settings['player_width_audio']) )
1588
- $player_width = $EpisodeData['width'];
1589
-
1590
- $cover_image = ''; // Audio should not have a cover image
1591
- $player_height = 24;
1592
- if(stristr($_SERVER['HTTP_USER_AGENT'], 'firefox') !== false )
1593
- $player_height = 22; // Firefox only
1594
- }
1595
-
1596
- // Build player...
1597
- $player_id = powerpressplayer_get_next_id();
1598
- $content = '';
1599
- $content .= '<div class="powerpress_player" id="powerpress_player_'. $player_id .'"></div>'.PHP_EOL;
1600
- $content .= '<script type="text/javascript"><!--'.PHP_EOL;
1601
- if( !empty($EpisodeData['jquery_autowidth']) )
1602
- {
1603
- $player_width = 'jQuery(window).width()';
1604
- if( preg_match('/(mp4|m4v|ogg|ogv|webm)/i', $extension) )
1605
- {
1606
- $player_height = 'jQuery(window).height()';
1607
- }
1608
- }
1609
-
1610
- if( empty($EpisodeData['type']) )
1611
- {
1612
- $EpisodeData['type'] = powerpress_get_contenttype('test.'.$extension);
1613
- }
1614
-
1615
- $content .= "pp_flashembed(\n";
1616
- $content .= " 'powerpress_player_{$player_id}',\n";
1617
-
1618
- $content .= " {src: '". powerpress_get_root_url() ."FlowPlayerClassic.swf', ";
1619
- if( preg_match('/^jQuery\(/', $player_width) ) // Only add single quotes if jQuery( ... is not in the value
1620
- $content .= "width: {$player_width}, ";
1621
- else
1622
- $content .= "width: '{$player_width}', ";
1623
- if( preg_match('/^jQuery\(/', $player_height) ) // Only add single quotes if jQuery( ... is not in the value
1624
- $content .= "height: {$player_height}, ";
1625
- else
1626
- $content .= "height: '{$player_height}', ";
1627
- $content .= "wmode: 'transparent' },\n";
1628
- if( $cover_image )
1629
- $content .= " {config: { autoPlay: ". ($autoplay?'true':'false') .", autoBuffering: false, showFullScreenButton: ". (preg_match('/audio\//', $EpisodeData['type'])?'false':'true' ) .", showMenu: false, videoFile: '{$media_url}', splashImageFile: '{$cover_image}', scaleSplash: true, loop: false, autoRewind: true } }\n";
1630
- else
1631
- $content .= " {config: { autoPlay: ". ($autoplay?'true':'false') .", autoBuffering: false, showFullScreenButton: ". (preg_match('/audio\//', $EpisodeData['type'])?'false':'true' ) .", showMenu: false, videoFile: '{$media_url}', loop: false, autoRewind: true } }\n";
1632
- $content .= ");\n";
1633
- $content .= "//-->\n";
1634
- $content .= "</script>\n";
1635
- return $content;
1636
  }
1637
 
1638
 
58
 
59
 
60
  $enqueue_mejs = false;
61
+ //if( !isset($GeneralSettings['player']) || !isset($GeneralSettings['video_player']) )
62
+ //{
63
  if( version_compare($GLOBALS['wp_version'], '3.6-alpha', '>') )
64
  $enqueue_mejs = true;
65
+ //}
66
 
67
+ if( !empty($GeneralSettings['player']) && ($GeneralSettings['player'] == 'mediaelement-audio' || $GeneralSettings['player'] == 'default') )
68
  {
69
  $enqueue_mejs = true;
70
  }
71
+ else if( !empty($GeneralSettings['video_player']) && ($GeneralSettings['video_player'] == 'mediaelement-video'|| $GeneralSettings['video_player'] == 'default') )
72
  {
73
  $enqueue_mejs = true;
74
  }
412
  function do_powerpressplayer_embed($player, $media_url, $EpisodeData = array())
413
  {
414
  // Includde the stuff we need...
415
+ wp_enqueue_style('mediaelement');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
416
  wp_enqueue_script('jquery');
417
 
418
  $content = '';
507
  if( !is_array($EpisodeData) )
508
  $EpisodeData = array();
509
 
510
+ $content .= powerpressplayer_build_flowplayerclassic($media_url, $EpisodeData + array('jquery_autowidth'=>true), true );
511
 
512
  // $content .= 'Video Flow Player Classic coming soon!';
513
  }; break;
1535
  /*
1536
  Flow Player Classic
1537
  */
1538
+ function powerpressplayer_build_flowplayerclassic($media_url, $EpisodeData = array(), $embed = false)
1539
  {
1540
+ if( preg_match('/\.(mp3|m4a|oga)/i', $media_url ) )
1541
+ return powerpressplayer_build_mediaelementaudio($media_url, $EpisodeData, $embed );
1542
+ return powerpressplayer_build_mediaelementvideo($media_url, $EpisodeData, $embed );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1543
  }
1544
 
1545
 
powerpress-player.php.bak ADDED
@@ -0,0 +1,2043 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ PowerPress player options
4
+ */
5
+
6
+
7
+ function powerpressplayer_get_next_id()
8
+ {
9
+ if( !isset($GLOBALS['g_powerpress_player_id']) ) // Use the global unique player id variable for the surrounding div
10
+ $GLOBALS['g_powerpress_player_id'] = rand(0, 10000);
11
+ else
12
+ $GLOBALS['g_powerpress_player_id']++; // increment the player id for the next div so it is unique
13
+ return $GLOBALS['g_powerpress_player_id'];
14
+ }
15
+
16
+ function powerpressplayer_get_extension($media_url, $EpisodeData = array() )
17
+ {
18
+ $extension = 'unknown';
19
+ $parts = pathinfo($media_url);
20
+ if( !empty($parts['extension']) )
21
+ $extension = strtolower($parts['extension']);
22
+
23
+ // Hack to use the audio/mp3 content type to set extension to mp3, some folks use tinyurl.com to mp3 files which remove the file extension...
24
+ if( isset($EpisodeData['type']) && $EpisodeData['type'] == 'audio/mpeg' && $extension != 'mp3' )
25
+ $extension = 'mp3';
26
+
27
+ return $extension;
28
+ }
29
+
30
+ /*
31
+ Initialize powerpress player handling
32
+ */
33
+ function powerpressplayer_init($GeneralSettings)
34
+ {
35
+ if( isset($_GET['powerpress_pinw']) )
36
+ powerpress_do_pinw($_GET['powerpress_pinw'], !empty($GeneralSettings['process_podpress']) );
37
+
38
+ if( isset($_GET['powerpress_embed']) )
39
+ {
40
+ $player = ( !empty($_GET['powerpress_player']) ? $_GET['powerpress_player'] : 'default' );
41
+ if( empty($_GET['powerpress_player']) && version_compare($GLOBALS['wp_version'], '3.6-alpha', '>') )
42
+ $player = 'mediaelement-audio';
43
+ powerpress_do_embed($player, $_GET['powerpress_embed'], !empty($GeneralSettings['process_podpress']) );
44
+ }
45
+
46
+ // If we are to process podpress data..
47
+ if( !empty($GeneralSettings['process_podpress']) )
48
+ {
49
+ add_shortcode('display_podcast', 'powerpress_shortcode_handler');
50
+ }
51
+
52
+
53
+ // include what's needed for each plaer
54
+ if( defined('POWERPRESS_JS_DEBUG') )
55
+ wp_enqueue_script( 'powerpress-player', powerpress_get_root_url() .'player.js');
56
+ else
57
+ wp_enqueue_script( 'powerpress-player', powerpress_get_root_url() .'player.min.js');
58
+
59
+
60
+ $enqueue_mejs = false;
61
+ if( !isset($GeneralSettings['player']) || !isset($GeneralSettings['video_player']) )
62
+ {
63
+ if( version_compare($GLOBALS['wp_version'], '3.6-alpha', '>') )
64
+ $enqueue_mejs = true;
65
+ }
66
+
67
+ if( !empty($GeneralSettings['player']) && ($GeneralSettings['player'] == 'mediaelement-audio'||$GeneralSettings['player'] == 'default') )
68
+ {
69
+ $enqueue_mejs = true;
70
+ }
71
+ else if( !empty($GeneralSettings['video_player']) && ($GeneralSettings['video_player'] == 'mediaelement-video'|| ) )
72
+ {
73
+ $enqueue_mejs = true;
74
+ }
75
+
76
+ if( $enqueue_mejs )
77
+ {
78
+ wp_enqueue_style('mediaelement');
79
+ wp_enqueue_style('wp-mediaelement');
80
+ wp_enqueue_script('mediaelement');
81
+ wp_enqueue_script( 'powerpress-mejs', powerpress_get_root_url() .'powerpress-mejs.js');
82
+ }
83
+ }
84
+
85
+
86
+ function powerpress_shortcode_handler( $attributes, $content = null )
87
+ {
88
+ global $post, $g_powerpress_player_added;
89
+
90
+ // We can't add flash players to feeds
91
+ if( is_feed() )
92
+ return '';
93
+
94
+ $return = '';
95
+ $feed = '';
96
+ $channel = '';
97
+ $slug = ''; // latest and preferred way to specify the feed slug
98
+ $url = '';
99
+ $image = '';
100
+ $width = '';
101
+ $height = '';
102
+
103
+ extract( shortcode_atts( array(
104
+ 'url' => '',
105
+ 'feed' => '',
106
+ 'channel' => '',
107
+ 'slug' => '',
108
+ 'image' => '',
109
+ 'width' => '',
110
+ 'height' => ''
111
+ ), $attributes ) );
112
+
113
+ if( empty($channel) && !empty($feed) ) // Feed for backward compat.
114
+ $channel = $feed;
115
+ if( !empty($slug) ) // Foward compatibility
116
+ $channel = $slug;
117
+
118
+ if( !$url && $content )
119
+ {
120
+ $content_url = trim($content);
121
+ if( @parse_url($content_url) )
122
+ $url = $content_url;
123
+ }
124
+
125
+ if( $url )
126
+ {
127
+ $url = powerpress_add_redirect_url($url);
128
+ $content_type = '';
129
+ // Handle the URL differently...
130
+ $return = apply_filters('powerpress_player', '', powerpress_add_flag_to_redirect_url($url, 'p'), array('image'=>$image, 'type'=>$content_type,'width'=>$width, 'height'=>$height) );
131
+ }
132
+ else if( $channel )
133
+ {
134
+ $EpisodeData = powerpress_get_enclosure_data($post->ID, $channel);
135
+ if( !empty($EpisodeData['embed']) )
136
+ $return = $EpisodeData['embed'];
137
+
138
+ // Shortcode over-ride settings:
139
+ if( !empty($image) )
140
+ $EpisodeData['image'] = $image;
141
+ if( !empty($width) )
142
+ $EpisodeData['width'] = $width;
143
+ if( !empty($height) )
144
+ $EpisodeData['height'] = $height;
145
+
146
+
147
+ if( isset($GeneralSettings['premium_caps']) && $GeneralSettings['premium_caps'] && !powerpress_premium_content_authorized($channel) )
148
+ {
149
+ $return .= powerpress_premium_content_message($post->ID, $channel, $EpisodeData);
150
+ }
151
+ else
152
+ {
153
+ // If the shortcode speciies a channel, than we definnitely wnat to include the player even if $EpisodeData['no_player'] is true...
154
+ if( !isset($EpisodeData['no_player']) )
155
+ $return = apply_filters('powerpress_player', '', powerpress_add_flag_to_redirect_url($EpisodeData['url'], 'p'), array('id'=>$post->ID,'feed'=>$channel, 'channel'=>$channel, 'image'=>$image, 'type'=>$EpisodeData['type'],'width'=>$width, 'height'=>$height) );
156
+ if( empty($EpisodeData['no_links']) )
157
+ $return .= apply_filters('powerpress_player_links', '', powerpress_add_flag_to_redirect_url($EpisodeData['url'], 'p'), $EpisodeData );
158
+ }
159
+ }
160
+ else
161
+ {
162
+ $GeneralSettings = get_option('powerpress_general');
163
+ if( !isset($GeneralSettings['custom_feeds']['podcast']) )
164
+ $GeneralSettings['custom_feeds']['podcast'] = 'Podcast Feed'; // Fixes scenario where the user never configured the custom default podcast feed.
165
+
166
+ // If we have post type podcasting enabled, then we need to use the podcast post type feeds instead here...
167
+ if( !empty($GeneralSettings['posttype_podcasting']) )
168
+ {
169
+ $post_type = get_query_var('post_type');
170
+ // Get the feed slugs and titles for this post type
171
+ $PostTypeSettingsArray = get_option('powerpress_posttype_'.$post_type);
172
+ // Loop through this array...
173
+ if( !empty($PostTypeSettingsArray) )
174
+ {
175
+ switch($post_type)
176
+ {
177
+ case 'post':
178
+ case 'page': {
179
+ // Do nothing!, we want the default podcast and channels to appear in these post types
180
+ }; break;
181
+ default: {
182
+ $GeneralSettings['custom_feeds'] = array(); // reset this array since we're working with a custom post type
183
+ };
184
+ }
185
+
186
+ while( list($feed_slug, $postTypeSettings) = each($PostTypeSettingsArray) )
187
+ {
188
+ if( !empty( $postTypeSettings['title']) )
189
+ $GeneralSettings['custom_feeds'][ $feed_slug ] = $postTypeSettings['title'];
190
+ else
191
+ $GeneralSettings['custom_feeds'][ $feed_slug ] = $feed_slug;
192
+ }
193
+ }
194
+ }
195
+
196
+ while( list($feed_slug,$feed_title) = each($GeneralSettings['custom_feeds']) )
197
+ {
198
+ if( isset($GeneralSettings['disable_player']) && isset($GeneralSettings['disable_player'][$feed_slug]) )
199
+ continue;
200
+
201
+ $EpisodeData = powerpress_get_enclosure_data($post->ID, $feed_slug);
202
+ if( !$EpisodeData && !empty($GeneralSettings['process_podpress']) && $feed_slug == 'podcast' )
203
+ $EpisodeData = powerpress_get_enclosure_data_podpress($post->ID);
204
+
205
+ if( !$EpisodeData )
206
+ continue;
207
+
208
+ if( !empty($EpisodeData['embed']) )
209
+ $return .= $EpisodeData['embed'];
210
+
211
+ // Shortcode over-ride settings:
212
+ if( !empty($image) )
213
+ $EpisodeData['image'] = $image;
214
+ if( !empty($width) )
215
+ $EpisodeData['width'] = $width;
216
+ if( !empty($height) )
217
+ $EpisodeData['height'] = $height;
218
+
219
+ if( isset($GeneralSettings['premium_caps']) && $GeneralSettings['premium_caps'] && !powerpress_premium_content_authorized($feed_slug) )
220
+ {
221
+ $return .= powerpress_premium_content_message($post->ID, $feed_slug, $EpisodeData);
222
+ continue;
223
+ }
224
+
225
+ if( !isset($EpisodeData['no_player']) )
226
+ {
227
+ $return .= apply_filters('powerpress_player', '', powerpress_add_flag_to_redirect_url($EpisodeData['url'], 'p'), $EpisodeData );
228
+ }
229
+ if( !isset($EpisodeData['no_links']) )
230
+ {
231
+ $return .= apply_filters('powerpress_player_links', '', powerpress_add_flag_to_redirect_url($EpisodeData['url'], 'p'), $EpisodeData );
232
+ }
233
+ }
234
+ }
235
+
236
+ return $return;
237
+ }
238
+
239
+ add_shortcode('powerpress', 'powerpress_shortcode_handler');
240
+ if( !defined('PODCASTING_VERSION') )
241
+ {
242
+ add_shortcode('podcast', 'powerpress_shortcode_handler');
243
+ }
244
+
245
+ /*
246
+ // Everything in $ExtraData except post_id
247
+ */
248
+ function powerpress_generate_embed($player, $EpisodeData) // $post_id, $feed_slug, $width=false, $height=false, $media_url = false, $autoplay = false)
249
+ {
250
+ if( empty($EpisodeData['id']) && empty($EpisodeData['feed']) )
251
+ return '';
252
+
253
+ $width = 0;
254
+ $height = 0;
255
+ if( !empty($EpisodeData['width']) && is_numeric($EpisodeData['width']) )
256
+ $width = $EpisodeData['width'];
257
+ if( !empty($EpisodeData['height']) && is_numeric($EpisodeData['height']) )
258
+ $height = $EpisodeData['height'];
259
+
260
+ // More efficient, only pull the general settings if necessary
261
+ if( $height == 0 || $width == 0 )
262
+ {
263
+ $GeneralSettings = get_option('powerpress_general');
264
+ if( $width == 0 )
265
+ {
266
+ $width = 400;
267
+ if( !empty($GeneralSettings['player_width']) )
268
+ $width = $GeneralSettings['player_width'];
269
+ }
270
+
271
+ if( $height == 0 )
272
+ {
273
+ $height = 400;
274
+ if( !empty($GeneralSettings['player_height']) )
275
+ $height = $GeneralSettings['player_height'];
276
+ }
277
+
278
+ $extension = powerpressplayer_get_extension($EpisodeData['url']);
279
+ if( $player == 'mediaelement-audio' )
280
+ {
281
+ if( $extension == 'mp3' || $extension == 'm4a' || $extension == 'oga')
282
+ {
283
+ $height = 30; // Hack for audio to only include the player without the poster art
284
+ $width = 320;
285
+ if( !empty($GeneralSettings['player_width_audio']) )
286
+ $width = $GeneralSettings['player_width_audio'];
287
+ }
288
+ }
289
+ else if ( $player == 'default' )
290
+ {
291
+ if( ($extension == 'mp3' || $extension == 'm4a' ) && empty($Settings['poster_image_audio']) )
292
+ {
293
+ $height = 24; // Hack for audio to only include the player without the poster art
294
+ $width = 320;
295
+ if( !empty($GeneralSettings['player_width_audio']) )
296
+ $width = $GeneralSettings['player_width_audio'];
297
+ }
298
+ }
299
+ }
300
+
301
+ $embed = '';
302
+ $url = get_bloginfo('url') .'/?powerpress_embed=' . $EpisodeData['id'] .'-'. $EpisodeData['feed'];
303
+ if( isset($EpisodeData['autoplay']) && $EpisodeData['autoplay'] )
304
+ $url .= '&amp;autoplay=true';
305
+
306
+ $url .= '&amp;powerpress_player='.$player;
307
+ $embed .= '<iframe';
308
+ //$embed .= ' class="powerpress-player-embed"';
309
+ $embed .= ' width="'. $width .'"';
310
+ $embed .= ' height="'. $height .'"';
311
+ $embed .= ' src="'. $url .'"';
312
+ $embed .= ' frameborder="0" scrolling="no"';
313
+ if($extension != 'mp3' && $extension != 'm4a' && $extension != 'oga')
314
+ $embed .= ' webkitAllowFullScreen mozallowfullscreen allowFullScreen';
315
+ $embed .= '></iframe>';
316
+ return $embed;
317
+ }
318
+
319
+ function powerpressplayer_build_embed($player, $media_url, $EpisodeData = array() )
320
+ {
321
+ return ''; // This function does not do anything at this time.
322
+ if( !$player )
323
+ return '';
324
+
325
+ if( empty($EpisodeData['id']) )
326
+ {
327
+ if( get_the_ID() )
328
+ $EpisodeData['id'] = get_the_ID();
329
+ }
330
+
331
+ // We don't have enough info to build an embed for this post or page
332
+ if( empty($EpisodeData['id']) && empty($EpisodeData['feed']) )
333
+ return '';
334
+
335
+ $extension = powerpressplayer_get_extension($media_url, $ExtraData);
336
+ $width = 400;
337
+ $height = 225;
338
+
339
+ // Configure width/height based on player
340
+ switch( $player )
341
+ {
342
+ case 'audio-player': {
343
+
344
+ $height = 25;
345
+ $width = 290;
346
+ if( !empty($EpisodeData['width']) && is_numeric($EpisodeData['width']) )
347
+ {
348
+ $width = $EpisodeData['width'];
349
+ }
350
+ else
351
+ {
352
+ $PlayerSettings = get_option('powerpress_audio-player');
353
+ if( !empty($EpisodeData['width']) && is_numeric($EpisodeData['width']) )
354
+ $width = $EpisodeData['width'];
355
+ }
356
+
357
+ }; break;
358
+ case 'flashmp3-maxi': {
359
+
360
+ $PlayerSettings = get_option('powerpress_flashmp3-maxi');
361
+ $height = 20;
362
+ $width = 200;
363
+ if( !empty($PlayerSettings['width']) && is_numeric($PlayerSettings['width']) )
364
+ $width = $PlayerSettings['width'];
365
+ if( !empty($PlayerSettings['height']) && is_numeric($PlayerSettings['height']) )
366
+ $height = $PlayerSettings['height'];
367
+ if( !empty($EpisodeData['width']) && is_numeric($EpisodeData['width']) )
368
+ $width = $EpisodeData['width'];
369
+ if( !empty($EpisodeData['height']) && is_numeric($EpisodeData['height']) )
370
+ $height = $EpisodeData['height'];
371
+
372
+ }; break;
373
+ case 'mediaelement-audio': {
374
+
375
+ $PlayerSettings = get_option('powerpress_mediaelement');
376
+ $height = 20;
377
+ $width = 200;
378
+ if( !empty($PlayerSettings['width']) && is_numeric($PlayerSettings['width']) )
379
+ $width = $PlayerSettings['width'];
380
+ if( !empty($PlayerSettings['height']) && is_numeric($PlayerSettings['height']) )
381
+ $height = $PlayerSettings['height'];
382
+ if( !empty($EpisodeData['width']) && is_numeric($EpisodeData['width']) )
383
+ $width = $EpisodeData['width'];
384
+ if( !empty($EpisodeData['height']) && is_numeric($EpisodeData['height']) )
385
+ $height = $EpisodeData['height'];
386
+
387
+ }; break;
388
+ default: { // Other players are currently not supported
389
+ return '';
390
+ };
391
+ }
392
+
393
+ $embed = '';
394
+ $url = get_bloginfo('url') .'/?powerpress_embed=' . $EpisodeData['id'] .'-'. $EpisodeData['feed'];
395
+ if( isset($EpisodeData['autoplay']) && $EpisodeData['autoplay'] )
396
+ $url .= '&amp;autoplay=true';
397
+
398
+ $url .= '&amp;powerpress_player='.$player;
399
+ $embed .= '<iframe';
400
+ if( 1 )
401
+ $embed .= ' webkitAllowFullScreen mozallowfullscreen allowFullScreen';
402
+ $embed .= ' class="powerpress-player-embed"';
403
+ $embed .= ' width="'. $width .'"';
404
+ $embed .= ' height="'. $height .'"';
405
+ $embed .= ' src="'. $url .'"';
406
+ $embed .= ' frameborder="0"';
407
+ $embed .= '></iframe>';
408
+ return $embed;
409
+ }
410
+
411
+
412
+ function do_powerpressplayer_embed($player, $media_url, $EpisodeData = array())
413
+ {
414
+ // Includde the stuff we need...
415
+ switch( $player )
416
+ {
417
+ case 'mejs-a':
418
+ case 'mejs-v':
419
+ case 'mediaelement-audio':
420
+ case 'mediaelement-video': {
421
+ // Enqueue stuff for mediaelements
422
+
423
+ wp_enqueue_style('mediaelement');
424
+ wp_enqueue_style('wp-mediaelement');
425
+ wp_enqueue_script('mediaelement');
426
+ //wp_enqueue_script( 'powerpress-mejs', powerpress_get_root_url() .'powerpress-mejs.js');
427
+ }; break;
428
+ default: {
429
+ //wp_enqueue_script('jquery');
430
+ }; break;
431
+ }
432
+ wp_enqueue_script('jquery');
433
+
434
+ $content = '';
435
+ $content .= '<!DOCTYPE html>'. PHP_EOL;
436
+ $content .= '<html xmlns="http://www.w3.org/1999/xhtml">'. PHP_EOL;
437
+ $content .= '<head>'. PHP_EOL;
438
+ $content .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'. PHP_EOL;
439
+ $content .= '<title>'. __('Blubrry PowerPress Player', 'powerpress') .'</title>'. PHP_EOL;
440
+ $content .= '<meta name="robots" content="noindex" />'. PHP_EOL;
441
+ // $content .= '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>'. PHP_EOL;
442
+ echo $content;
443
+ // Include jQuery for convenience
444
+
445
+ wp_print_styles();
446
+ wp_print_scripts();
447
+
448
+ $content = '';
449
+ if( defined('POWERPRESS_JS_DEBUG') )
450
+ $content .= '<script type="text/javascript" src="'. powerpress_get_root_url() .'player.js"></script>'. PHP_EOL;
451
+ else
452
+ $content .= '<script type="text/javascript" src="'. powerpress_get_root_url() .'player.min.js"></script>'. PHP_EOL;
453
+
454
+ $content .= '<script language="javascript" type="text/javascript"><!--'. PHP_EOL;
455
+ $content .= 'powerpress_url = \''. powerpress_get_root_url() .'\''. PHP_EOL;
456
+ $content .= 'jQuery(document).ready(function($) {'. PHP_EOL;
457
+ $content .= ' powerpress_load_player();'. PHP_EOL;
458
+ $content .= ' $(window).resize(function() {'. PHP_EOL;
459
+ $content .= ' powerpress_resize_player();'. PHP_EOL;
460
+ $content .= ' });'. PHP_EOL;
461
+
462
+ $content .= '});'. PHP_EOL;
463
+
464
+ $content .= 'function powerpress_load_player() {'. PHP_EOL;
465
+ $content .= ' jQuery(\'.powerpress-mejs-audio, .powerpress-mejs-video\').css(\'width\', jQuery(window).width() );'. PHP_EOL;
466
+ $content .= ' jQuery(\'.powerpress-mejs-audio, .powerpress-mejs-video\').css(\'height\', jQuery(window).height() );'. PHP_EOL;
467
+ $content .= ' jQuery(\'.powerpress-mejs-audio, .powerpress-mejs-video\').mediaelementplayer();'.PHP_EOL;
468
+ $content .= '}'. PHP_EOL;
469
+
470
+ $content .= 'function powerpress_resize_player() {'. PHP_EOL;
471
+ //$content .= ' var width = jQuery(window).width(); var height = jQuery(window).height();'.PHP_EOL;
472
+ //$content .= ' if( (height * 0.5625) > width ) { alert(\'need to adjust height!\'); }'.PHP_EOL;
473
+ //$content .= ' if( (height * 0.5625) < width ) { width = Math.floor((height * 16)/9); }'.PHP_EOL;
474
+ //$content .= ' $(\'player\')[0].player.media.setPlayerSize( width, height )'.PHP_EOL;
475
+ $content .= ' jQuery(\'.powerpress_player\').css(\'width\', jQuery(window).width() );'. PHP_EOL;
476
+ $content .= ' jQuery(\'.powerpress_player\').css(\'height\', jQuery(window).height() );'. PHP_EOL;
477
+ $content .= ' jQuery(\'.powerpress-mejs-video, .powerpress-mejs-audio\').css(\'width\', jQuery(window).width() );'. PHP_EOL;
478
+ $content .= ' jQuery(\'.powerpress-mejs-video, .powerpress-mejs-audio\').css(\'height\', jQuery(window).height() );'. PHP_EOL;
479
+ //$content .= ' alert(\'Height: \'+ jQuery(window).height() );'. PHP_EOL;
480
+
481
+ $content .= ' jQuery(\'.powerpress_player .powerpress-player-poster\').css(\'width\', jQuery(window).width() );'. PHP_EOL;
482
+ $content .= ' jQuery(\'.powerpress_player .powerpress-player-poster\').css(\'height\', jQuery(window).height() );'. PHP_EOL;
483
+ $content .= ' jQuery(\'.powerpress_player .powerpress-player-play-image\').css(\'bottom\', Math.floor( (jQuery(window).height()/2)-30)+\'px\');'. PHP_EOL;
484
+ $content .= ' jQuery(\'.powerpress_player .powerpress-player-play-image\').css(\'left\', Math.floor( (jQuery(window).width()/2)-30)+\'px\');'. PHP_EOL;
485
+ $content .= ' jQuery(\'embed\').css(\'width\', jQuery(window).width() );'. PHP_EOL;
486
+ $content .= ' jQuery(\'embed\').css(\'height\', jQuery(window).height() );'. PHP_EOL;
487
+ $content .= '}'. PHP_EOL;
488
+ $content .= "//-->\n";
489
+ $content .= '</script>'. PHP_EOL;
490
+
491
+ // Head specific settings for player
492
+ switch( $player )
493
+ {
494
+ case 'html5video': {
495
+ //$Settings = get_option('powerpress_general');
496
+ // TODO: Need to include javascript to insert HTML5 player (with FlowPlayer Classic fallback for mp4)
497
+
498
+ }; break;
499
+ case 'flow-player-classic': {
500
+ //$Settings = get_option('powerpress_general');
501
+ // TODO: Need to include javascript to insert HTML5 player (with FlowPlayer Classic fallback for mp4)
502
+
503
+ }; break;
504
+ case 'default': {
505
+ //$Settings = get_option('powerpress_general');
506
+ // TODO: Need to include javascript to insert HTML5 player (with FlowPlayer Classic fallback for mp4)
507
+
508
+ }; break;
509
+ }
510
+
511
+ $content .= '<style type="text/css" media="screen">' . PHP_EOL;
512
+ $content .= ' body { font-size: 13px; font-family: Arial, Helvetica, sans-serif; margin: 0; padding: 0; } img { border: 0; } ' . PHP_EOL;
513
+ $content .= '</style>' . PHP_EOL;
514
+ $content .= '</head>'. PHP_EOL;
515
+ $content .= '<body>'. PHP_EOL;
516
+
517
+ // Body specific content for player
518
+ switch( $player )
519
+ {
520
+ case 'default':
521
+ case 'flow-player-classic': {
522
+
523
+ if( !is_array($EpisodeData) )
524
+ $EpisodeData = array();
525
+
526
+ $content .= powerpressplayer_build_flowplayerclassic($media_url, $EpisodeData + array('jquery_autowidth'=>true), true );
527
+
528
+ // $content .= 'Video Flow Player Classic coming soon!';
529
+ }; break;
530
+ case 'html5video': {
531
+ $content .= powerpressplayer_build_html5video($media_url, $EpisodeData);
532
+ }; break;
533
+ case 'mediaelement-audio':
534
+ case 'mejs-a': {
535
+ $content .= powerpressplayer_build_mediaelementaudio($media_url, $EpisodeData, true);
536
+ }; break;
537
+ case 'mediaelement-video':
538
+ case 'mejs-v': {
539
+ $content .= powerpressplayer_build_mediaelementvideo($media_url, $EpisodeData, true);
540
+ }; break;
541
+ default: {
542
+ $content .= '<strong>'. __('Player Not Available', 'powerpress') .'</strong>';
543
+ };
544
+ }
545
+
546
+ $content .= '</body>'. PHP_EOL;
547
+ $content .= '</html>'. PHP_EOL;
548
+ echo $content;
549
+ }
550
+
551
+
552
+ /*
553
+ Audio Players - Flash/HTML5 compliant mp3 audio
554
+
555
+ @since 2.0
556
+ @content -
557
+ @param string $content Content of post or page to add player to
558
+ @param string $media_url Media URL to add player for
559
+ @param array $EpisodeData Array of key/value settings that optionally can contribute to player being added
560
+ @return string $content The content, possibly modified wih player added
561
+ */
562
+ function powerpressplayer_player_audio($content, $media_url, $EpisodeData = array() )
563
+ {
564
+ if( powerpress_is_mobile_client() ) // Mobile clients are handled in powerpressplayer_player_other
565
+ return $content;
566
+
567
+ $extension = powerpressplayer_get_extension($media_url);
568
+ switch( $extension )
569
+ {
570
+ // MP3
571
+ case 'mp3':
572
+ {
573
+ $Settings = get_option('powerpress_general');
574
+ if( !isset($Settings['player']) && version_compare($GLOBALS['wp_version'], '3.6-alpha', '>') )
575
+ $Settings['player'] = 'mediaelement-audio';
576
+ else if( !isset($Settings['player']) )
577
+ $Settings['player'] = 'default';
578
+
579
+ switch( $Settings['player'] )
580
+ {
581
+ case 'default':
582
+ case 'flow-player-classic': {
583
+ $content .= powerpressplayer_build_flowplayerclassic($media_url, $EpisodeData);
584
+ }; break;
585
+ case 'audio-player': {
586
+ $content .= powerpressplayer_build_1pxoutplayer($media_url, $EpisodeData);
587
+ }; break;
588
+ case 'flashmp3-maxi': {
589
+ $content .= powerpressplayer_build_flashmp3maxi($media_url, $EpisodeData);
590
+ }; break;
591
+ case 'audioplay': {
592
+ $content .= powerpressplayer_build_audioplay($media_url, $EpisodeData);
593
+ }; break;
594
+ case 'simple_flash': {
595
+ $content .= powerpressplayer_build_simpleflash($media_url, $EpisodeData);
596
+ }; break;
597
+ case 'html5audio': {
598
+ $content .= powerpressplayer_build_html5audio($media_url, $EpisodeData);
599
+ }; break;
600
+ case 'mediaelement-audio': {
601
+ $content .= powerpressplayer_build_mediaelementaudio($media_url, $EpisodeData);
602
+ }; break;
603
+ }
604
+
605
+ }; break;
606
+ case 'm4a': {
607
+
608
+ $Settings = get_option('powerpress_general');
609
+ if( empty($Settings['m4a']) || $Settings['m4a'] != 'use_players' )
610
+ break;
611
+
612
+ if( !isset($Settings['player']) && version_compare($GLOBALS['wp_version'], '3.6-alpha', '>') )
613
+ $Settings['player'] = 'mediaelement-audio';
614
+ else if( !isset($Settings['player']) )
615
+ $Settings['player'] = 'default';
616
+
617
+ switch( $Settings['player'] )
618
+ {
619
+ case 'default':
620
+ case 'flow-player-classic': {
621
+ $content .= powerpressplayer_build_flowplayerclassic($media_url, $EpisodeData);
622
+ }; break;
623
+ case 'html5audio': {
624
+ $content .= powerpressplayer_build_html5audio($media_url, $EpisodeData);
625
+ }; break;
626
+ case 'mediaelement-audio': {
627
+ $content .= powerpressplayer_build_mediaelementaudio($media_url, $EpisodeData);
628
+ }; break;
629
+ default: {
630
+ $content .= powerpressplayer_build_playimageaudio($media_url, true);
631
+ };
632
+ }
633
+
634
+ // Use Flow player if configured
635
+ }; break;
636
+ case 'ogg': {
637
+ if( defined('POWERPRESS_OGG_VIDEO') && POWERPRESS_OGG_VIDEO )
638
+ return $content; // Ogg is handled as video
639
+ }
640
+ case 'oga': {
641
+ if( !isset($Settings['player']) && version_compare($GLOBALS['wp_version'], '3.6-alpha', '>') )
642
+ $Settings['player'] = 'mediaelement-audio';
643
+
644
+ switch( $Settings['player'] )
645
+ {
646
+ case 'mediaelement-audio': {
647
+ $content .= powerpressplayer_build_mediaelementaudio($media_url, $EpisodeData);
648
+ }; break;
649
+ case 'html5audio':
650
+ default: {
651
+ $content .= powerpressplayer_build_html5audio($media_url, $EpisodeData);
652
+ }
653
+ }
654
+ }; break;
655
+ }
656
+
657
+ return $content;
658
+ }
659
+
660
+ /*
661
+ Video Players - HTML5/Flash compliant video formats
662
+ */
663
+ function powerpressplayer_player_video($content, $media_url, $EpisodeData = array() )
664
+ {
665
+ if( powerpress_is_mobile_client() ) // Mobile clients are handled in powerpressplayer_player_other
666
+ return $content;
667
+
668
+ $extension = powerpressplayer_get_extension($media_url);
669
+ switch( $extension )
670
+ {
671
+ // OGG (audio or video)
672
+ case 'ogg': {
673
+ // Ogg special case, we treat as audio unless specified otherwise
674
+ if( !defined('POWERPRESS_OGG_VIDEO') || POWERPRESS_OGG_VIDEO == false )
675
+ return $content;
676
+ }
677
+ // OGG Video / WebM
678
+ case 'webm':
679
+ case 'ogv': { // Use native player when possible
680
+ $Settings = get_option('powerpress_general');
681
+ if( !isset($Settings['video_player']) && version_compare($GLOBALS['wp_version'], '3.6-alpha', '>') )
682
+ $Settings['video_player'] = 'mediaelement-video';
683
+ else if( !isset($Settings['video_player']) )
684
+ $Settings['video_player'] = 'html5video';
685
+
686
+ // HTML5 Video as an embed
687
+ switch( $Settings['video_player'] )
688
+ {
689
+ case 'videojs-html5-video-player-for-wordpress': {
690
+ $content .= powerpressplayer_build_videojs($media_url, $EpisodeData);
691
+ }; break;
692
+ case 'mediaelement-video': {
693
+ $content .= powerpressplayer_build_mediaelementvideo($media_url, $EpisodeData);
694
+ }; break;
695
+ default: {
696
+ $content .= powerpressplayer_build_html5video($media_url, $EpisodeData);
697
+ }; break;
698
+ }
699
+ }; break;
700
+ // H.264
701
+ case 'm4v':
702
+ case 'mp4':
703
+ // Okay, lets see if we we have a player setup to handle this
704
+ {
705
+ $Settings = get_option('powerpress_general');
706
+ if( !isset($Settings['video_player']) && version_compare($GLOBALS['wp_version'], '3.6-alpha', '>') )
707
+ $Settings['video_player'] = 'mediaelement-video';
708
+ else if( !isset($Settings['video_player']) )
709
+ $Settings['video_player'] = 'default';
710
+
711
+ switch( $Settings['video_player'] )
712
+ {
713
+ case 'default':
714
+ case 'flow-player-classic': {
715
+
716
+ $content .= powerpressplayer_build_flowplayerclassic($media_url, $EpisodeData);
717
+ }; break;
718
+ case 'videojs-html5-video-player-for-wordpress': {
719
+ $content .= powerpressplayer_build_videojs($media_url, $EpisodeData);
720
+ }; break;
721
+ case 'html5video': {
722
+ // HTML5 Video as an embed
723
+ $content .= powerpressplayer_build_html5video($media_url, $EpisodeData);
724
+ }; break;
725
+ case 'mediaelement-video': {
726
+ $content .= powerpressplayer_build_mediaelementvideo($media_url, $EpisodeData);
727
+ }; break;
728
+ }
729
+ }; break;
730
+ }
731
+
732
+ return $content;
733
+ }
734
+
735
+ function powerpressplayer_player_other($content, $media_url, $EpisodeData = array() )
736
+ {
737
+ if( powerpress_is_mobile_client() )
738
+ {
739
+ $content .= powerpressplayer_build_html5mobile($media_url, $EpisodeData);
740
+ return $content;
741
+ }
742
+
743
+ // Very important setting, we need to know if the media should auto play or not...
744
+ $autoplay = false; // (default)
745
+ if( isset($EpisodeData['autoplay']) && $EpisodeData['autoplay'] )
746
+ $autoplay = true;
747
+ $cover_image = '';
748
+ if( !empty($EpisodeData['image']) )
749
+ $cover_image = $EpisodeData['image'];
750
+
751
+ $extension = powerpressplayer_get_extension($media_url);
752
+
753
+ switch( $extension )
754
+ {
755
+ // Common formats, we already handle them separately
756
+ case 'mp3':
757
+ case 'mp4':
758
+ case 'm4v':
759
+ case 'webm';
760
+ case 'ogg':
761
+ case 'ogv':
762
+ case 'oga':
763
+ {
764
+ return $content;
765
+ }; break;
766
+ case 'flv': {
767
+ $content .= powerpressplayer_build_flowplayerclassic($media_url, $EpisodeData);
768
+ }; break;
769
+ case 'm4a': // Special case for thos audiobook folks (could be modern player, could be old embed)
770
+ // Old Quicktime formats:
771
+ case 'avi':
772
+ case 'mpg':
773
+ case 'mpeg':
774
+ case 'm4b':
775
+ case 'm4r':
776
+ case 'qt':
777
+ case 'mov': {
778
+
779
+ $Settings = get_option('powerpress_general');
780
+
781
+ // Special case for thos audiobook folks
782
+ if( $extension == 'm4a' && !empty($Settings['m4a']) && $Settings['m4a'] == 'use_players' )
783
+ break;
784
+
785
+ $player_id = powerpressplayer_get_next_id();
786
+ $player_width = 400;
787
+ $player_height = 225;
788
+ $scale = 'tofit';
789
+ if( !empty($Settings['player_width']) )
790
+ $player_width = $Settings['player_width'];
791
+ if( !empty($Settings['player_height']) )
792
+ $player_height = $Settings['player_height'];
793
+ if( !empty($EpisodeData['width']) && is_numeric($EpisodeData['width']) )
794
+ $player_width = $EpisodeData['width'];
795
+ if( !empty($EpisodeData['height']) && is_numeric($EpisodeData['height']) )
796
+ $player_height = $EpisodeData['height'];
797
+
798
+ if( !empty($Settings['player_scale']) )
799
+ $scale = $Settings['player_scale'];
800
+
801
+ // If there is no cover image specified, lets use the default...
802
+ if( $cover_image == '' )
803
+ $cover_image = powerpress_get_root_url() . 'play_video_default.jpg';
804
+
805
+ if( $autoplay )
806
+ {
807
+ $content .= '<div class="powerpress_player" id="powerpress_player_'. $player_id .'"></div>'.PHP_EOL;
808
+ $content .= '<script type="text/javascript"><!--'.PHP_EOL;
809
+ $content .= "powerpress_embed_quicktime('powerpress_player_{$player_id}', '{$media_url}', {$player_width}, {$player_height}, '{$scale}');\n";
810
+ $content .= "//-->\n";
811
+ $content .= "</script>\n";
812
+ }
813
+ else
814
+ {
815
+ $content .= '<div class="powerpress_player" id="powerpress_player_'. $player_id .'">'.PHP_EOL;
816
+ $content .= '<a href="'. $media_url .'" title="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" onclick="';
817
+ $content .= "return powerpress_embed_quicktime('powerpress_player_{$player_id}', '{$media_url}', {$player_width}, {$player_height}, '{$scale}' );";
818
+ $content .= '">';
819
+ $content .= '<img src="'. $cover_image .'" title="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" alt="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" style="width: '. $player_width .'px; height: '.$player_height .'px;" />';
820
+ $content .= '</a>';
821
+ $content .= "</div>\n";
822
+ }
823
+
824
+ }; break;
825
+
826
+ // Windows Media:
827
+ case 'wma':
828
+ case 'wmv':
829
+ case 'asf': {
830
+
831
+ $Settings = get_option('powerpress_general');
832
+ $player_id = powerpressplayer_get_next_id();
833
+ $player_width = 400;
834
+ $player_height = 225;
835
+ $scale = 'tofit';
836
+ if( !empty($Settings['player_width']) )
837
+ $player_width = $Settings['player_width'];
838
+ if( !empty($Settings['player_height']) )
839
+ $player_height = $Settings['player_height'];
840
+ if( !empty($EpisodeData['width']) && is_numeric($EpisodeData['width']) )
841
+ $player_width = $EpisodeData['width'];
842
+ if( !empty($EpisodeData['height']) && is_numeric($EpisodeData['height']) )
843
+ $player_height = $EpisodeData['height'];
844
+
845
+ // If there is no cover image specified, lets use the default...
846
+ if( $cover_image == '' )
847
+ $cover_image = powerpress_get_root_url() . 'play_video_default.jpg';
848
+
849
+ $content .= '<div class="powerpress_player" id="powerpress_player_'. $player_id .'">';
850
+ $firefox = (stristr($_SERVER['HTTP_USER_AGENT'], 'firefox') !== false );
851
+
852
+ if( (!$cover_image && !$firefox ) || $autoplay ) // if we don't have a cover image or we're supposed to auto play the media anyway...
853
+ {
854
+ $content .= '<object id="winplayer" classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6" width="'. $player_width .'" height="'. $player_height .'" standby="..." type="application/x-oleobject">';
855
+ $content .= ' <param name="url" value="'. $media_url .'" />';
856
+ $content .= ' <param name="AutoStart" value="'. ($autoplay?'true':'false') .'" />';
857
+ $content .= ' <param name="AutoSize" value="true" />';
858
+ $content .= ' <param name="AllowChangeDisplaySize" value="true" />';
859
+ $content .= ' <param name="standby" value="Media is loading..." />';
860
+ $content .= ' <param name="AnimationAtStart" value="true" />';
861
+ $content .= ' <param name="scale" value="aspect" />';
862
+ $content .= ' <param name="ShowControls" value="true" />';
863
+ $content .= ' <param name="ShowCaptioning" value="false" />';
864
+ $content .= ' <param name="ShowDisplay" value="false" />';
865
+ $content .= ' <param name="ShowStatusBar" value="false" />';
866
+ $content .= ' <embed type="application/x-mplayer2" src="'. $media_url .'" width="'. $player_width .'" height="'. $player_height .'" scale="ASPECT" autostart="'. ($autoplay?'1':'0') .'" ShowDisplay="0" ShowStatusBar="0" autosize="1" AnimationAtStart="1" AllowChangeDisplaySize="1" ShowControls="1"></embed>';
867
+ $content .= '</object>';
868
+ }
869
+ else
870
+ {
871
+ if( $cover_image == '' )
872
+ $cover_image = powerpress_get_root_url() . 'play_video_default.jpg';
873
+
874
+ $content .= '<a href="'. $media_url .'" title="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" onclick="';
875
+ $content .= "return powerpress_embed_winplayer('powerpress_player_{$player_id}', '{$media_url}', {$player_width}, {$player_height} );";
876
+ $content .= '">';
877
+ $content .= '<img src="'. $cover_image .'" title="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" alt="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" />';
878
+ $content .= '</a>';
879
+ }
880
+
881
+ if( $firefox )
882
+ {
883
+ $content .= '<p style="font-size: 85%;margin-top:0;">'. __('Best viewed with', 'powerpress');
884
+ $content .= ' <a href="http://support.mozilla.com/en-US/kb/Using+the+Windows+Media+Player+plugin+with+Firefox#Installing_the_plugin" target="_blank">';
885
+ $content .= __('Windows Media Player plugin for Firefox', 'powerpress') .'</a></p>';
886
+ }
887
+
888
+ $content .= "</div>\n";
889
+
890
+ }; break;
891
+
892
+ // Flash:
893
+ case 'swf': {
894
+
895
+ $Settings = get_option('powerpress_general');
896
+ $player_id = powerpressplayer_get_next_id();
897
+ $player_width = 400;
898
+ $player_height = 225;
899
+ if( !empty($Settings['player_width']) )
900
+ $player_width = $Settings['player_width'];
901
+ if( !empty($Settings['player_height']) )
902
+ $player_height = $Settings['player_height'];
903
+ if( !empty($EpisodeData['width']) && is_numeric($EpisodeData['width']) )
904
+ $player_width = $EpisodeData['width'];
905
+ if( !empty($EpisodeData['height']) && is_numeric($EpisodeData['height']) )
906
+ $player_height = $EpisodeData['height'];
907
+
908
+ // If there is no cover image specified, lets use the default...
909
+ if( $cover_image == '' )
910
+ $cover_image = powerpress_get_root_url() . 'play_video_default.jpg';
911
+
912
+ $content .= '<div class="powerpress_player" id="powerpress_player_'. $player_id .'">';
913
+ if( !$autoplay )
914
+ {
915
+ $content .= '<a href="'. $media_url .'" title="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" onclick="';
916
+ $content .= "return powerpress_embed_swf('powerpress_player_{$player_id}','{$media_url}',{$player_width},{$player_height});";
917
+ $content .= '">';
918
+ $content .= '<img src="'. $cover_image .'" title="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" alt="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" />';
919
+ $content .= '</a>';
920
+ }
921
+ $content .= "</div>\n";
922
+ if( $autoplay )
923
+ {
924
+ $content .= '<script type="text/javascript"><!--'.PHP_EOL;
925
+ $content .= "powerpress_embed_swf('powerpress_player_{$player_id}','{$media_url}',{$player_width},{$player_height});\n";
926
+ $content .= "//-->\n";
927
+ $content .= "</script>\n";
928
+ }
929
+
930
+ }; break;
931
+
932
+ case 'pdf': {
933
+ $content .= powerpressplayer_build_playimagepdf($media_url, true);
934
+ }; break;
935
+ case 'epub': {
936
+ $content .= powerpressplayer_build_playimageepub($media_url, true);
937
+ }; break;
938
+
939
+ // Default, just display the play image.
940
+ default: {
941
+
942
+ $content .= powerpressplayer_build_playimage($media_url, $EpisodeData, true);
943
+
944
+ }; break;
945
+ }
946
+
947
+ return $content;
948
+ }
949
+
950
+ add_filter('powerpress_player', 'powerpressplayer_player_audio', 10, 3); // Audio players (mp3)
951
+ add_filter('powerpress_player', 'powerpressplayer_player_video', 10, 3); // Video players (mp4/m4v, webm, ogv)
952
+ add_filter('powerpress_player', 'powerpressplayer_player_other', 10, 3); // Audio/Video flv, wmv, wma, oga, m4a and other non-standard media files
953
+
954
+ /*
955
+ Filters for media links, appear below the selected player
956
+ */
957
+ function powerpressplayer_link_download($content, $media_url, $ExtraData = array() )
958
+ {
959
+ $GeneralSettings = get_option('powerpress_general');
960
+ if( !isset($GeneralSettings['podcast_link']) )
961
+ $GeneralSettings['podcast_link'] = 1;
962
+
963
+ $player_links = '';
964
+ if( $GeneralSettings['podcast_link'] == 1 )
965
+ {
966
+ $player_links .= "<a href=\"{$media_url}\" class=\"powerpress_link_d\" title=\"". POWERPRESS_DOWNLOAD_TEXT ."\" rel=\"nofollow\" download=\"". htmlspecialchars(basename($media_url)) ."\">". POWERPRESS_DOWNLOAD_TEXT ."</a>".PHP_EOL;
967
+ }
968
+ else if( $GeneralSettings['podcast_link'] == 2 )
969
+ {
970
+ $player_links .= "<a href=\"{$media_url}\" class=\"powerpress_link_d\" title=\"". POWERPRESS_DOWNLOAD_TEXT ."\" rel=\"nofollow\" download=\"". htmlspecialchars(basename($media_url)) ."\">". POWERPRESS_DOWNLOAD_TEXT ."</a> (".powerpress_byte_size($ExtraData['size']).") ".PHP_EOL;
971
+ }
972
+ else if( $GeneralSettings['podcast_link'] == 3 )
973
+ {
974
+ if( !empty($ExtraData['duration']) && ltrim($ExtraData['duration'], '0:') != '' )
975
+ $player_links .= "<a href=\"{$media_url}\" class=\"powerpress_link_d\" title=\"". POWERPRESS_DOWNLOAD_TEXT ."\" rel=\"nofollow\" download=\"". htmlspecialchars(basename($media_url)) ."\">". POWERPRESS_DOWNLOAD_TEXT ."</a> (". htmlspecialchars(POWERPRESS_DURATION_TEXT) .": " . powerpress_readable_duration($ExtraData['duration']) ." &#8212; ".powerpress_byte_size($ExtraData['size']).")".PHP_EOL;
976
+ else
977
+ $player_links .= "<a href=\"{$media_url}\" class=\"powerpress_link_d\" title=\"". POWERPRESS_DOWNLOAD_TEXT ."\" rel=\"nofollow\" download=\"". htmlspecialchars(basename($media_url)) ."\">". POWERPRESS_DOWNLOAD_TEXT ."</a> (".powerpress_byte_size($ExtraData['size']).")".PHP_EOL;
978
+ }
979
+
980
+ if( $player_links && !empty($content) )
981
+ $content .= ' '.POWERPRESS_LINK_SEPARATOR .' ';
982
+
983
+ return $content . $player_links;
984
+ }
985
+
986
+ function powerpressplayer_link_pinw($content, $media_url, $ExtraData = array() )
987
+ {
988
+ $GeneralSettings = get_option('powerpress_general');
989
+ if( !isset($GeneralSettings['player_function']) )
990
+ $GeneralSettings['player_function'] = 1;
991
+ $is_pdf = (strtolower( substr($media_url, -3) ) == 'pdf' );
992
+
993
+ $player_links = '';
994
+ switch( $GeneralSettings['player_function'] )
995
+ {
996
+ case 1: // Play on page and new window
997
+ case 3: // Play in new window only
998
+ case 5: { // Play in page and new window
999
+ if( $is_pdf )
1000
+ $player_links .= "<a href=\"{$media_url}\" class=\"powerpress_link_pinw\" target=\"_blank\" title=\"". __('Open in New Window', 'powerpress') ."\" rel=\"nofollow\">". __('Open in New Window', 'powerpress') ."</a>".PHP_EOL;
1001
+ else if( !empty($ExtraData['id']) && !empty($ExtraData['feed']) )
1002
+ $player_links .= "<a href=\"{$media_url}\" class=\"powerpress_link_pinw\" target=\"_blank\" title=\"". POWERPRESS_PLAY_IN_NEW_WINDOW_TEXT ."\" onclick=\"return powerpress_pinw('{$ExtraData['id']}-{$ExtraData['feed']}');\" rel=\"nofollow\">". POWERPRESS_PLAY_IN_NEW_WINDOW_TEXT ."</a>".PHP_EOL;
1003
+ else
1004
+ $player_links .= "<a href=\"{$media_url}\" class=\"powerpress_link_pinw\" target=\"_blank\" title=\"". POWERPRESS_PLAY_IN_NEW_WINDOW_TEXT ."\" rel=\"nofollow\">". POWERPRESS_PLAY_IN_NEW_WINDOW_TEXT ."</a>".PHP_EOL;
1005
+ }; break;
1006
+ }//end switch
1007
+
1008
+ if( $player_links && !empty($content) )
1009
+ $content .= ' '.POWERPRESS_LINK_SEPARATOR .' ';
1010
+
1011
+ return $content . $player_links;
1012
+ }
1013
+
1014
+ function powerpressplayer_embedable($media_url, $ExtraData = array())
1015
+ {
1016
+ if( empty($ExtraData['id']) || empty($ExtraData['feed']) )
1017
+ return false;
1018
+
1019
+ $extension = powerpressplayer_get_extension($media_url);
1020
+ $player = false;
1021
+ if( preg_match('/(mp3|m4a|oga|mp4|m4v|webm|ogg|ogv)/i', $extension ) )
1022
+ {
1023
+ $GeneralSettings = get_option('powerpress_general');
1024
+ if( empty($GeneralSettings['podcast_embed']) )
1025
+ return false;
1026
+ if( !isset($GeneralSettings['player']) && version_compare($GLOBALS['wp_version'], '3.6-alpha', '>') )
1027
+ $GeneralSettings['player'] = 'mediaelement-audio';
1028
+ else if( !isset($GeneralSettings['player']) )
1029
+ $GeneralSettings['player'] = 'default';
1030
+
1031
+ if( !isset($GeneralSettings['video_player']) && version_compare($GLOBALS['wp_version'], '3.6-alpha', '>') )
1032
+ $GeneralSettings['video_player'] = 'mediaelement-video';
1033
+ else if( !isset($GeneralSettings['video_player']) )
1034
+ $GeneralSettings['video_player'] = 'flow-player-classic';
1035
+
1036
+ switch( $extension )
1037
+ {
1038
+ case 'mp3':
1039
+ case 'oga':
1040
+ case 'm4a': {
1041
+ if( in_array( $GeneralSettings['player'], array('mediaelement-audio', 'flow-player-classic', 'default') ) )
1042
+ $player = $GeneralSettings['player'];
1043
+ }; break;
1044
+ case 'mp4':
1045
+ case 'm4v':
1046
+ case 'webm':
1047
+ case 'ogg':
1048
+ case 'ogv': {
1049
+ if( in_array( $GeneralSettings['video_player'], array('mediaelement-video', 'html5video', 'flow-player-classic') ) )
1050
+ $player = $GeneralSettings['video_player'];
1051
+ }; break;
1052
+ }
1053
+ }
1054
+
1055
+ return $player;
1056
+ }
1057
+
1058
+ function powerpressplayer_link_embed($content, $media_url, $ExtraData = array() )
1059
+ {
1060
+ $player_links = '';
1061
+
1062
+ $player = powerpressplayer_embedable($media_url, $ExtraData);
1063
+ if( $player )
1064
+ {
1065
+ $player_links .= "<a href=\"#\" class=\"powerpress_link_e\" title=\"". htmlspecialchars(POWERPRESS_EMBED_TEXT) ."\" onclick=\"return powerpress_show_embed('{$ExtraData['id']}-{$ExtraData['feed']}');\" rel=\"nofollow\">". htmlspecialchars(POWERPRESS_EMBED_TEXT) ."</a>";
1066
+ }
1067
+
1068
+ if( $player_links && !empty($content) )
1069
+ $content .= ' '.POWERPRESS_LINK_SEPARATOR .' ';
1070
+ return $content . $player_links;
1071
+ }
1072
+
1073
+ function powerpressplayer_link_title($content, $media_url, $ExtraData = array() )
1074
+ {
1075
+ if( $content )
1076
+ {
1077
+ $extension = 'unknown';
1078
+ $parts = pathinfo($media_url);
1079
+ if( $parts && isset($parts['extension']) )
1080
+ $extension = strtolower($parts['extension']);
1081
+
1082
+ $prefix = '';
1083
+ if( $extension == 'pdf' )
1084
+ $prefix .= __('E-Book PDF', 'powerpress') . ( $ExtraData['feed']=='pdf'||$ExtraData['feed']=='podcast'?'':" ({$ExtraData['feed']})") .POWERPRESS_TEXT_SEPARATOR;
1085
+ else if( $ExtraData['feed'] != 'podcast' )
1086
+ $prefix .= htmlspecialchars(POWERPRESS_LINKS_TEXT) .' ('. htmlspecialchars($ExtraData['feed']) .')'. POWERPRESS_TEXT_SEPARATOR;
1087
+ else
1088
+ $prefix .= htmlspecialchars(POWERPRESS_LINKS_TEXT) . POWERPRESS_TEXT_SEPARATOR;
1089
+ if( !empty($prefix) )
1090
+ $prefix .= ' ';
1091
+
1092
+ $return = '<p class="powerpress_links powerpress_links_'. $extension .'">'. $prefix . $content . '</p>';
1093
+ $player = powerpressplayer_embedable($media_url, $ExtraData);
1094
+ if( $player )
1095
+ {
1096
+ $iframe_src = powerpress_generate_embed($player, $ExtraData);
1097
+ $return .= '<p class="powerpress_embed_box" id="powerpress_embed_'. "{$ExtraData['id']}-{$ExtraData['feed']}" .'" style="display: none;">';
1098
+ $return .= '<input id="powerpress_embed_'. "{$ExtraData['id']}-{$ExtraData['feed']}" .'_t" type="text" value="'. htmlspecialchars($iframe_src) .'" onclick="javascript: this.select();" onfocus="javascript: this.select();" style="width: 70%;" readOnly>';
1099
+ $return .= '</p>';
1100
+ }
1101
+ return $return;
1102
+ }
1103
+ return '';
1104
+ }
1105
+
1106
+ add_filter('powerpress_player_links', 'powerpressplayer_link_pinw', 30, 3);
1107
+ add_filter('powerpress_player_links', 'powerpressplayer_link_download', 50, 3);
1108
+ add_filter('powerpress_player_links', 'powerpressplayer_link_embed', 50, 3);
1109
+ add_filter('powerpress_player_links', 'powerpressplayer_link_title', 1000, 3);
1110
+
1111
+ /*
1112
+ Do Play in new Window
1113
+ */
1114
+ function powerpress_do_pinw($pinw, $process_podpress)
1115
+ {
1116
+ if( !WP_DEBUG && defined('POWERPRESS_FIX_WARNINGS') )
1117
+ {
1118
+ @error_reporting( E_ALL | E_CORE_ERROR | E_COMPILE_ERROR | E_PARSE );
1119
+ }
1120
+
1121
+ list($post_id, $feed_slug) = explode('-', $pinw, 2);
1122
+ $EpisodeData = powerpress_get_enclosure_data($post_id, $feed_slug);
1123
+
1124
+ if( $EpisodeData == false && $process_podpress && $feed_slug == 'podcast' )
1125
+ {
1126
+ $EpisodeData = powerpress_get_enclosure_data_podpress($post_id);
1127
+ }
1128
+
1129
+ $GeneralSettings = get_option('powerpress_general');
1130
+
1131
+ echo '<!DOCTYPE html>'; // HTML5!
1132
+ ?>
1133
+ <html xmlns="http://www.w3.org/1999/xhtml">
1134
+ <head>
1135
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
1136
+ <title><?php echo __('Blubrry PowerPress Player', 'powerpress'); ?></title>
1137
+ <meta name="robots" content="noindex" />
1138
+ <?php
1139
+
1140
+ if( defined('POWERPRESS_JS_DEBUG') )
1141
+ wp_enqueue_script( 'powerpress-player', powerpress_get_root_url() .'player.js');
1142
+ else
1143
+ wp_enqueue_script( 'powerpress-player', powerpress_get_root_url() .'player.min.js');
1144
+
1145
+ if( version_compare($GLOBALS['wp_version'], '3.6-alpha', '>') )
1146
+ {
1147
+ $include_mejs = false;
1148
+ if( empty($GeneralSettings['player']) || empty($GeneralSettings['video_player']) )
1149
+ {
1150
+ $include_mejs = true;
1151
+ }
1152
+ else if( !empty($GeneralSettings['player']) && ($GeneralSettings['player'] == 'mediaelement-audio' || $GeneralSettings['video_player'] == 'mediaelement-video' ) )
1153
+ {
1154
+ $include_mejs = true;
1155
+ }
1156
+
1157
+ if( $include_mejs )
1158
+ {
1159
+ wp_enqueue_style('mediaelement');
1160
+ wp_enqueue_style('wp-mediaelement');
1161
+ wp_enqueue_script('mediaelement');
1162
+ if( defined('POWERPRESS_JS_DEBUG') )
1163
+ wp_enqueue_script( 'powerpress-mejs', powerpress_get_root_url() .'powerpress-mejs.js');
1164
+ else
1165
+ wp_enqueue_script( 'powerpress-mejs', powerpress_get_root_url() .'powerpress-mejs.min.js');
1166
+ }
1167
+ }
1168
+
1169
+ wp_print_styles();
1170
+ wp_print_scripts();
1171
+
1172
+ //wp_head();
1173
+ ?>
1174
+ <style type="text/css">
1175
+ body { font-size: 13px; font-family: Arial, Helvetica, sans-serif; /* width: 100%; min-height: 100%; } html { height: 100%; */ }
1176
+ </style>
1177
+ </head>
1178
+ <body>
1179
+ <div style="margin: 5px;">
1180
+ <?php
1181
+
1182
+ if( !$EpisodeData )
1183
+ {
1184
+ echo '<p>'. __('Unable to retrieve media information.', 'powerpress') .'</p>';
1185
+ }
1186
+ else if( !empty($GeneralSettings['premium_caps']) && !powerpress_premium_content_authorized($feed_slug) )
1187
+ {
1188
+ echo powerpress_premium_content_message($post_id, $feed_slug, $EpisodeData);
1189
+ }
1190
+ else if( !empty($EpisodeData['embed']) )
1191
+ {
1192
+ echo $EpisodeData['embed'];
1193
+ }
1194
+ else // if( !isset($EpisodeData['no_player']) ) // Even if there is no player set, if the play in new window option is enabled then it should play here...
1195
+ {
1196
+ echo apply_filters('powerpress_player', '', powerpress_add_flag_to_redirect_url($EpisodeData['url'], 'p'), array('feed'=>$feed_slug, 'autoplay'=>true, 'type'=>$EpisodeData['type']) );
1197
+ }
1198
+
1199
+ ?>
1200
+ </div>
1201
+ </body>
1202
+ </html>
1203
+ <?php
1204
+ exit;
1205
+ }
1206
+
1207
+ /*
1208
+ Do embed
1209
+ */
1210
+ function powerpress_do_embed($player, $embed, $process_podpress)
1211
+ {
1212
+ list($post_id, $feed_slug) = explode('-', $embed, 2);
1213
+ $EpisodeData = powerpress_get_enclosure_data($post_id, $feed_slug);
1214
+
1215
+ if( $EpisodeData == false && $process_podpress && $feed_slug == 'podcast' )
1216
+ {
1217
+ $EpisodeData = powerpress_get_enclosure_data_podpress($post_id);
1218
+ }
1219
+
1220
+ // Embeds are only available for the following players
1221
+ do_powerpressplayer_embed($player, $EpisodeData['url'], $EpisodeData);
1222
+ exit;
1223
+ }
1224
+
1225
+ /*
1226
+ HTTML 5 Video Player
1227
+ */
1228
+ function powerpressplayer_build_html5video($media_url, $EpisodeData=array(), $embed = false )
1229
+ {
1230
+ $player_id = powerpressplayer_get_next_id();
1231
+ $cover_image = '';
1232
+ $player_width = 400;
1233
+ $player_height = 225;
1234
+ $autoplay = false;
1235
+ // Global Settings
1236
+ $Settings = get_option('powerpress_general');
1237
+ if( !empty($Settings['player_width']) )
1238
+ $player_width = $Settings['player_width'];
1239
+ if( !empty($Settings['player_height']) )
1240
+ $player_height = $Settings['player_height'];
1241
+ if( !empty($Settings['poster_image']) )
1242
+ $cover_image = $Settings['poster_image'];
1243
+ // Episode Settings
1244
+ if( !empty($EpisodeData['image']) )
1245
+ $cover_image = $EpisodeData['image'];
1246
+ if( !empty($EpisodeData['width']) )
1247
+ $player_width = $EpisodeData['width'];
1248
+ if( !empty($EpisodeData['height']) )
1249
+ $player_height = $EpisodeData['height'];
1250
+ if( !empty($EpisodeData['autoplay']) )
1251
+ $autoplay = true;
1252
+
1253
+ $content = '';
1254
+ if( $embed )
1255
+ {
1256
+ $content .= '<div class="powerpress_player" id="powerpress_player_'. $player_id .'">'.PHP_EOL;
1257
+ $content .= '<video width="'. $player_width .'" height="'. $player_height .'" controls="controls"';
1258
+ if( $cover_image )
1259
+ $content .= ' poster="'. $cover_image .'"';
1260
+ if( $autoplay )
1261
+ $content .= ' autoplay="autoplay"';
1262
+ else
1263
+ $content .= ' preload="none"';
1264
+ $content .= '>'.PHP_EOL;
1265
+ $content_type = powerpress_get_contenttype($media_url);
1266
+ $content .='<source src="'. $media_url .'" type="'. $content_type .'" />';
1267
+
1268
+ if( !empty($EpisodeData['webm_src']) )
1269
+ {
1270
+ $EpisodeData['webm_src'] = powerpress_add_flag_to_redirect_url($EpisodeData['webm_src'], 'p');
1271
+ $content .='<source src="'. $EpisodeData['webm_src'] .'" type="video/webm" />';
1272
+ }
1273
+
1274
+ $content .= powerpressplayer_build_playimage($media_url, $EpisodeData);
1275
+ $content .= '</video>'.PHP_EOL;
1276
+ $content .= '</div>'.PHP_EOL;
1277
+ }
1278
+ else
1279
+ {
1280
+
1281
+ if( !$cover_image )
1282
+ $cover_image = powerpress_get_root_url() . 'black.png';
1283
+ $webm_src = '';
1284
+ if( !empty($EpisodeData['webm_src']) )
1285
+ $webm_src = powerpress_add_flag_to_redirect_url($EpisodeData['webm_src'], 'p');
1286
+ $content .= '<div class="powerpress_player" id="powerpress_player_'. $player_id .'">';
1287
+ $content .= '<a href="'. $media_url .'" title="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" onclick="return powerpress_embed_html5v(\''.$player_id.'\',\''.$media_url.'\',\''. $player_width .'\',\''. $player_height .'\', \''. $webm_src .'\');" target="_blank" style="position: relative;">';
1288
+ if( !empty($EpisodeData['custom_play_button']) ) // This currently does not apply
1289
+ {
1290
+ $cover_image = $EpisodeData['custom_play_button'];
1291
+ $Settings['poster_play_image'] = false;
1292
+ $content .= '<img class="powerpress-player-poster" src="'. $cover_image .'" title="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" alt="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" />';
1293
+ }
1294
+ else
1295
+ {
1296
+ $content .= '<img class="powerpress-player-poster" src="'. $cover_image .'" title="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" alt="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" style="width: '. $player_width .'px; height: '. $player_height .'px;" />';
1297
+ }
1298
+
1299
+ if(!isset($Settings['poster_play_image']) || $Settings['poster_play_image'] )
1300
+ {
1301
+ $play_image_button_url = powerpress_get_root_url() .'play_video.png';
1302
+ if( !empty($Settings['video_custom_play_button']) )
1303
+ $play_image_button_url = $Settings['video_custom_play_button'];
1304
+
1305
+ $bottom = floor(($player_height/2)-30);
1306
+ if( $bottom < 0 )
1307
+ $bottom = 0;
1308
+ $left = floor(($player_width/2)-30);
1309
+ if( $left < 0 )
1310
+ $left = 0;
1311
+ $content .= '<img class="powerpress-player-play-image" src="'. $play_image_button_url .'" title="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" alt="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" style="position: absolute; bottom: '. $bottom .'px; left: '. $left .'px; border:0;" />';
1312
+ }
1313
+ $content .= '</a>';
1314
+ $content .= "</div>\n";
1315
+
1316
+ if( $autoplay )
1317
+ {
1318
+ $content .= '<script type="text/javascript"><!--'.PHP_EOL;
1319
+ $content .= "powerpress_embed_html5v('{$player_id}','{$media_url}',{$player_width},{$player_height},'{$webm_src}');\n";
1320
+ $content .= "//-->\n";
1321
+ $content .= "</script>\n";
1322
+ }
1323
+ }
1324
+ return $content;
1325
+ }
1326
+
1327
+ /*
1328
+ MediaElement.js Video Player
1329
+ */
1330
+ function powerpressplayer_build_mediaelementvideo($media_url, $EpisodeData=array(), $embed = false )
1331
+ {
1332
+ $player_id = powerpressplayer_get_next_id();
1333
+ $cover_image = '';
1334
+ $player_width = 400;
1335
+ $player_height = 225;
1336
+ $autoplay = false;
1337
+ // Global Settings
1338
+ $Settings = get_option('powerpress_general');
1339
+ if( !empty($Settings['player_width']) )
1340
+ $player_width = $Settings['player_width'];
1341
+ if( !empty($Settings['player_height']) )
1342
+ $player_height = $Settings['player_height'];
1343
+ if( !empty($Settings['poster_image']) )
1344
+ $cover_image = $Settings['poster_image'];
1345
+ // Episode Settings
1346
+ if( !empty($EpisodeData['image']) )
1347
+ $cover_image = $EpisodeData['image'];
1348
+ if( !empty($EpisodeData['width']) )
1349
+ $player_width = $EpisodeData['width'];
1350
+ if( !empty($EpisodeData['height']) )
1351
+ $player_height = $EpisodeData['height'];
1352
+ if( !empty($EpisodeData['autoplay']) )
1353
+ $autoplay = true;
1354
+
1355
+
1356
+
1357
+
1358
+ $content = '';
1359
+
1360
+ $content .= '<div class="powerpress_player" id="powerpress_player_'. $player_id .'">'.PHP_EOL;
1361
+ $content .= '<video class="powerpress-mejs-video" width="'. $player_width .'" height="'. $player_height .'" controls="controls"';
1362
+ if( $cover_image )
1363
+ $content .= ' poster="'. $cover_image .'"';
1364
+ if( $autoplay )
1365
+ $content .= ' autoplay="autoplay"';
1366
+ else
1367
+ $content .= ' preload="none"';
1368
+ $content .= '>'.PHP_EOL;
1369
+ $content_type = powerpress_get_contenttype($media_url);
1370
+
1371
+ // Prevent pre-loading in certain browsers
1372
+ $media_url_src = $media_url;
1373
+ // Special case for mobile browsers
1374
+ //if( preg_match('/msie|webkit|applecoremedia/i', $_SERVER['HTTP_USER_AGENT']) && !preg_match('/chrome/i', $_SERVER['HTTP_USER_AGENT']) ) {
1375
+ // $media_url_src = '#'.$media_url;
1376
+ //}
1377
+
1378
+ $content .='<source src="'. $media_url_src .'" type="'. $content_type .'" />';
1379
+
1380
+ if( !empty($EpisodeData['webm_src']) )
1381
+ {
1382
+ $EpisodeData['webm_src'] = powerpress_add_flag_to_redirect_url($EpisodeData['webm_src'], 'p');
1383
+ $content .='<source src="'. $EpisodeData['webm_src'] .'" type="video/webm" />';
1384
+ }
1385
+
1386
+ $content .= powerpressplayer_build_playimage($media_url, $EpisodeData);
1387
+ $content .= '</video>'.PHP_EOL;
1388
+ $content .= '</div>'.PHP_EOL;
1389
+ return $content;
1390
+ }
1391
+
1392
+ /*
1393
+ HTTML 5 Audio Player
1394
+ */
1395
+ function powerpressplayer_build_html5audio($media_url, $EpisodeData=array(), $embed = false )
1396
+ {
1397
+ $player_id = powerpressplayer_get_next_id();
1398
+ $autoplay = false;
1399
+ // Episode Settings
1400
+ if( !empty($EpisodeData['autoplay']) )
1401
+ $autoplay = true;
1402
+ $content = '';
1403
+ if( $embed )
1404
+ {
1405
+ $content .= '<div class="powerpress_player" id="powerpress_player_'. $player_id .'">'.PHP_EOL;
1406
+ $content .= '<audio controls="controls"';
1407
+ $content .=' src="'. $media_url .'"';
1408
+ if( $autoplay )
1409
+ $content .= ' autoplay="autoplay"';
1410
+ else
1411
+ $content .= ' preload="none"';
1412
+ $content .= '>'.PHP_EOL;
1413
+
1414
+ $content .= powerpressplayer_build_playimageaudio($media_url);
1415
+ $content .= '</audio>'.PHP_EOL;
1416
+ $content .= '</div>'.PHP_EOL;
1417
+ }
1418
+ else
1419
+ {
1420
+ $GeneralSettings = get_option('powerpress_general');
1421
+ $cover_image = powerpress_get_root_url() . 'play_audio.png';
1422
+ if( !empty($EpisodeData['custom_play_button']) )
1423
+ {
1424
+ $cover_image = $EpisodeData['custom_play_button'];
1425
+ }
1426
+ else if( !empty($GeneralSettings['audio_custom_play_button']) )
1427
+ {
1428
+ $cover_image = $GeneralSettings['audio_custom_play_button'];
1429
+ }
1430
+
1431
+ $content .= '<div class="powerpress_player" id="powerpress_player_'. $player_id .'">';
1432
+ $content .= '<a href="'. $media_url .'" title="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" onclick="return powerpress_embed_html5a(\''.$player_id.'\',\''.$media_url.'\');" target="_blank">';
1433
+ $content .= '<img src="'. $cover_image .'" title="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" alt="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" style="border:0;" />';
1434
+ $content .= '</a>';
1435
+ $content .= "</div>\n";
1436
+
1437
+ if( $autoplay )
1438
+ {
1439
+ $content .= '<script type="text/javascript"><!--'.PHP_EOL;
1440
+ $content .= "powerpress_embed_html5a('{$player_id}','{$media_url}');\n";
1441
+ $content .= "//-->\n";
1442
+ $content .= "</script>\n";
1443
+ }
1444
+ }
1445
+
1446
+ return $content;
1447
+ }
1448
+
1449
+ /*
1450
+ MediaElement.js Audio Player
1451
+ */
1452
+ function powerpressplayer_build_mediaelementaudio($media_url, $EpisodeData=array(), $embed = false )
1453
+ {
1454
+ $player_id = powerpressplayer_get_next_id();
1455
+ $autoplay = false;
1456
+ // Episode Settings
1457
+ if( !empty($EpisodeData['autoplay']) )
1458
+ $autoplay = true;
1459
+ $content = '';
1460
+
1461
+
1462
+ $content .= '<div class="powerpress_player" id="powerpress_player_'. $player_id .'">'.PHP_EOL;
1463
+ $content .= '<audio class="powerpress-mejs-audio" controls="controls"';
1464
+
1465
+ // Set the type if required
1466
+ $extension = powerpressplayer_get_extension($media_url);
1467
+ switch( $extension )
1468
+ {
1469
+ case 'm4a': {
1470
+ $content .= ' type="audio/mp4"';
1471
+ }; break;
1472
+ }
1473
+
1474
+ // Prevent pre-loading in certain browsers
1475
+ $media_url_src = $media_url;
1476
+ // Folloowing is for mobile browsers that pre-load the audio
1477
+ //if( preg_match('/msie|webkit|applecoremedia/i', $_SERVER['HTTP_USER_AGENT']) && !preg_match('/chrome/i', $_SERVER['HTTP_USER_AGENT']) ) {
1478
+ // $media_url_src = '#'.$media_url;
1479
+ //}
1480
+
1481
+ $content .=' src="'. $media_url_src .'"';
1482
+ //if( $cover_image ) // Audio does not have a coverart image (not yet anyway)
1483
+ // $content .= ' poster="'. $cover_image .'"';
1484
+ if( $autoplay )
1485
+ $content .= ' autoplay="autoplay"';
1486
+ else
1487
+ $content .= ' preload="none"';
1488
+ $content .= '>'.PHP_EOL;
1489
+
1490
+
1491
+ $content .= powerpressplayer_build_playimageaudio($media_url);
1492
+ $content .= '</audio>'.PHP_EOL;
1493
+ $content .= '</div>'.PHP_EOL;
1494
+
1495
+
1496
+ return $content;
1497
+ }
1498
+
1499
+ /*
1500
+ HTTML 5 Mobile Player
1501
+ */
1502
+ function powerpressplayer_build_html5mobile($media_url, $EpisodeData)
1503
+ {
1504
+ $content = '';
1505
+ $html5 = true;
1506
+ // Special logic, we need to check if we're dealing with Android 2.2 or older, in which case we don't want to use HTML5 audio/video due to controls bug
1507
+ if( preg_match('/android ([\d\.]+)/i', $_SERVER['HTTP_USER_AGENT'], $matches) )
1508
+ {
1509
+ if( !empty($matches[1]) && version_compare($matches[1], "2.3") < 0 )
1510
+ $html5 = false;
1511
+ }
1512
+
1513
+ $extension = powerpressplayer_get_extension($media_url);
1514
+ switch( $extension )
1515
+ {
1516
+ case 'mp4':
1517
+ case 'webm':
1518
+ case 'm4v':
1519
+ case 'ogg':
1520
+ case 'ogv': {
1521
+ // Video
1522
+ $Settings = get_option('powerpress_general');
1523
+
1524
+ // MEJS is not ready for mobile, using native HTML5 performs more efficiently at this point. Someday though we will be able to use MEJS for mobile.
1525
+ if( false && $html5 && !empty($Settings['video_player']) && $Settings['video_player'] == 'mediaelement-video' )
1526
+ $content .= powerpressplayer_build_mediaelementvideo($media_url, $EpisodeData);
1527
+ else if( $html5 )
1528
+ $content .= powerpressplayer_build_html5video($media_url, $EpisodeData);
1529
+ else
1530
+ $content .= powerpressplayer_build_playimage($media_url, $EpisodeData, true);
1531
+ }; break;
1532
+ case 'mp3':
1533
+ case 'm4a':
1534
+ case 'oga': {
1535
+ // Audio
1536
+ $Settings = get_option('powerpress_general');
1537
+
1538
+ // MEJS is not ready for mobile, using native HTML5 performs more efficiently at this point. Someday though we will be able to use MEJS for mobile.
1539
+ if( false && $html5 && !empty($Settings['player']) && $Settings['player'] == 'mediaelement-audio' )
1540
+ $content .= powerpressplayer_build_mediaelementaudio($media_url, $EpisodeData);
1541
+ else if( $html5 )
1542
+ $content .= powerpressplayer_build_html5audio($media_url, $EpisodeData);
1543
+ else
1544
+ $content .= powerpressplayer_build_playimageaudio($media_url, true);
1545
+ }; break;
1546
+ }
1547
+
1548
+ return $content;
1549
+ }
1550
+
1551
+ /*
1552
+ Flow Player Classic
1553
+ */
1554
+ function powerpressplayer_build_flowplayerclassic($media_url, $EpisodeData = array(), $embed = false)
1555
+ {
1556
+ if( preg_match('/\.(mp3|m4a|oga)/i', $media_url ) )
1557
+ return powerpressplayer_build_mediaelementaudio($media_url, $EpisodeData, $embed );
1558
+ return powerpressplayer_build_mediaelementvideo($media_url, $EpisodeData, $embed );
1559
+ }
1560
+
1561
+
1562
+ function powerpressplayer_build_playimage($media_url, $EpisodeData = array(), $include_div = false)
1563
+ {
1564
+ $content = '';
1565
+ $autoplay = false;
1566
+ if( !empty($EpisodeData['autoplay']) && $EpisodeData['autoplay'] )
1567
+ $autoplay = true;
1568
+ $player_width = 400;
1569
+ $player_height = 225;
1570
+ $cover_image = '';
1571
+ // Global settings
1572
+ $Settings = get_option('powerpress_general');
1573
+ if( !empty($Settings['player_width']) )
1574
+ $player_width = $Settings['player_width'];
1575
+ if( !empty($Settings['player_height']) )
1576
+ $player_height = $Settings['player_height'];
1577
+ if( !empty($Settings['poster_image']) )
1578
+ $cover_image = $Settings['poster_image'];
1579
+ // episode settings
1580
+ if( !empty($EpisodeData['width']) )
1581
+ $player_width = $EpisodeData['width'];
1582
+ if( !empty($EpisodeData['height']) )
1583
+ $player_height = $EpisodeData['height'];
1584
+ if( !empty($EpisodeData['image']) )
1585
+ $cover_image = $EpisodeData['image'];
1586
+
1587
+ if( !$cover_image )
1588
+ $cover_image = powerpress_get_root_url() . 'black.png';
1589
+
1590
+ if( $include_div )
1591
+ $content .= '<div class="powerpress_player" id="powerpress_player_'. powerpressplayer_get_next_id() .'">';
1592
+ $content .= '<a href="'. $media_url .'" title="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" target="_blank" style="position: relative;">';
1593
+ $content .= '<img src="'. $cover_image .'" title="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" alt="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" style="width: '. $player_width .'px; height: '. $player_height .'px;" />';
1594
+ if(!isset($Settings['poster_play_image']) || $Settings['poster_play_image'] )
1595
+ {
1596
+ $play_image_button_url = powerpress_get_root_url() .'play_video.png';
1597
+ if( !empty($Settings['video_custom_play_button']) )
1598
+ $play_image_button_url = $Settings['video_custom_play_button'];
1599
+
1600
+ $bottom = floor(($player_height/2)-30);
1601
+ if( $bottom < 0 )
1602
+ $bottom = 0;
1603
+ $left = floor(($player_width/2)-30);
1604
+ if( $left < 0 )
1605
+ $left = 0;
1606
+ $content .= '<img src="'. $play_image_button_url .'" title="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" alt="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" style="position: absolute; bottom:'. $bottom .'px; left:'. $left .'px; border:0;" />';
1607
+ }
1608
+ $content .= '</a>';
1609
+ if( $include_div )
1610
+ $content .= "</div>\n";
1611
+ return $content;
1612
+ }
1613
+
1614
+ function powerpressplayer_build_playimageaudio($media_url, $include_div = false)
1615
+ {
1616
+ $content = '';
1617
+ $cover_image = powerpress_get_root_url() . 'play_audio.png';
1618
+ $GeneralSettings = get_option('powerpress_general');
1619
+ if( !empty($GeneralSettings['custom_play_button']) )
1620
+ $cover_image = $GeneralSettings['custom_play_button'];
1621
+
1622
+ if( $include_div )
1623
+ $content .= '<div class="powerpress_player" id="powerpress_player_'. powerpressplayer_get_next_id() .'">';
1624
+ $content .= '<a href="'. $media_url .'" title="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" target="_blank">';
1625
+ $content .= '<img src="'. $cover_image .'" title="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" alt="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" style="border:0;" />';
1626
+ $content .= '</a>';
1627
+ if( $include_div )
1628
+ $content .= "</div>\n";
1629
+ return $content;
1630
+ }
1631
+
1632
+ function powerpressplayer_build_playimagepdf($media_url, $include_div = false)
1633
+ {
1634
+ $content = '';
1635
+ $cover_image = powerpress_get_root_url() . 'play_pdf.png';
1636
+ $GeneralSettings = get_option('powerpress_general');
1637
+ if( !empty($GeneralSettings['pdf_custom_play_button']) )
1638
+ $cover_image = $GeneralSettings['pdf_custom_play_button'];
1639
+
1640
+ if( $include_div )
1641
+ $content .= '<div class="powerpress_player" id="powerpress_player_'. powerpressplayer_get_next_id() .'">';
1642
+ $content .= '<a href="'. $media_url .'" title="'. htmlspecialchars(POWERPRESS_READ_TEXT) .'" target="_blank">';
1643
+ $content .= '<img src="'. $cover_image .'" title="'. htmlspecialchars(POWERPRESS_READ_TEXT) .'" alt="'. htmlspecialchars(POWERPRESS_READ_TEXT) .'" style="border:0;" />';
1644
+ $content .= '</a>';
1645
+ if( $include_div )
1646
+ $content .= "</div>\n";
1647
+ return $content;
1648
+ }
1649
+
1650
+ function powerpressplayer_build_playimageepub($media_url, $include_div = false)
1651
+ {
1652
+ $content = '';
1653
+ $cover_image = powerpress_get_root_url() . 'play_epub.png';
1654
+ $GeneralSettings = get_option('powerpress_general');
1655
+ if( !empty($GeneralSettings['epub_custom_play_button']) )
1656
+ $cover_image = $GeneralSettings['epub_custom_play_button'];
1657
+
1658
+ if( $include_div )
1659
+ $content .= '<div class="powerpress_player" id="powerpress_player_'. powerpressplayer_get_next_id() .'">';
1660
+ $content .= '<a href="'. $media_url .'" title="'. htmlspecialchars(POWERPRESS_READ_TEXT) .'" target="_blank">';
1661
+ $content .= '<img src="'. $cover_image .'" title="'. htmlspecialchars(POWERPRESS_READ_TEXT) .'" alt="'. htmlspecialchars(POWERPRESS_READ_TEXT) .'" style="border:0;" />';
1662
+ $content .= '</a>';
1663
+ if( $include_div )
1664
+ $content .= "</div>\n";
1665
+ return $content;
1666
+ }
1667
+
1668
+ /*
1669
+ 1 pixel out player
1670
+ */
1671
+ function powerpressplayer_build_1pxoutplayer($media_url, $EpisodeData = array())
1672
+ {
1673
+ $content = '';
1674
+ $autoplay = false;
1675
+ if( isset($EpisodeData['autoplay']) && $EpisodeData['autoplay'] )
1676
+ $autoplay = true; // TODO: We need to handle this
1677
+
1678
+ $PlayerSettings = get_option('powerpress_audio-player');
1679
+ if( !$PlayerSettings )
1680
+ {
1681
+ $PlayerSettings = array(
1682
+ 'width'=>'290',
1683
+ 'transparentpagebg' => 'yes',
1684
+ 'lefticon' => '#333333',
1685
+ 'leftbg' => '#CCCCCC',
1686
+ 'bg' => '#E5E5E5',
1687
+ 'voltrack' => '#F2F2F2',
1688
+ 'volslider' => '#666666',
1689
+ 'rightbg' => '#B4B4B4',
1690
+ 'rightbghover' => '#999999',
1691
+ 'righticon' => '#333333',
1692
+ 'righticonhover' => '#FFFFFF',
1693
+ 'loader' => '#009900',
1694
+ 'track' => '#FFFFFF',
1695
+ 'tracker' => '#DDDDDD',
1696
+ 'border' => '#CCCCCC',
1697
+ 'skip' => '#666666',
1698
+ 'text' => '#333333',
1699
+ 'pagebg' => '',
1700
+ 'noinfo'=>'yes',
1701
+ 'rtl' => 'no' );
1702
+ }
1703
+
1704
+ if( empty($PlayerSettings['titles']) )
1705
+ $PlayerSettings['titles'] = 'Blubrry PowerPress';
1706
+ else if( strtoupper($PlayerSettings['titles']) == __('TRACK', 'powerpress') )
1707
+ unset( $PlayerSettings['titles'] );
1708
+
1709
+ // Set player width
1710
+ if( !isset($PlayerSettings['width']) )
1711
+ $PlayerSettings['width'] = 290;
1712
+ if( !empty($EpisodeData['width']) && is_numeric($EpisodeData['width']) )
1713
+ $PlayerSettings['width'] = $EpisodeData['width'];
1714
+
1715
+ $transparency = '<param name="wmode" value="transparent" />';
1716
+ $PlayerSettings['transparentpagebg'] = 'yes';
1717
+ if( !empty($PlayerSettings['pagebg']) )
1718
+ {
1719
+ $transparency = '<param name="bgcolor" value="'.$PlayerSettings['pagebg'].'" />';
1720
+ $PlayerSettings['transparentpagebg'] = 'no';
1721
+ }
1722
+
1723
+ $flashvars ='';
1724
+ while( list($key,$value) = each($PlayerSettings) )
1725
+ {
1726
+ $flashvars .= '&amp;'. $key .'='. preg_replace('/\#/','',$value);
1727
+ }
1728
+
1729
+ if( $autoplay )
1730
+ {
1731
+ $flashvars .= '&amp;autostart=yes';
1732
+ }
1733
+
1734
+ // TODO: Add 1 px out audio-player player here
1735
+ $player_id = powerpressplayer_get_next_id();
1736
+ if( empty($EpisodeData['nodiv']) )
1737
+ $content .= '<div class="powerpress_player" id="powerpress_player_'. $player_id .'">';
1738
+ $content .= '<object type="application/x-shockwave-flash" data="'.powerpress_get_root_url().'audio-player.swf" id="'.$player_id.'" height="24" width="'. $PlayerSettings['width'] .'">'.PHP_EOL;
1739
+ $content .= '<param name="movie" value="'.powerpress_get_root_url().'audio-player.swf" />'.PHP_EOL;
1740
+ $content .= '<param name="FlashVars" value="playerID='.$player_id.'&amp;soundFile='.urlencode($media_url).$flashvars.'" />'.PHP_EOL;
1741
+ $content .= '<param name="quality" value="high" />'.PHP_EOL;
1742
+ $content .= '<param name="menu" value="false" />'.PHP_EOL;
1743
+ $content .= '<param name="wmode" value="transparent" />'.PHP_EOL;
1744
+ // $content .= powerpressplayer_build_html5audio($media_url, $EpisodeData, true); // Feature removed since it causes double players to be insrted in Safari/Firefox
1745
+ $content .= powerpressplayer_build_playimageaudio($media_url);
1746
+ $content .= '</object>'.PHP_EOL;
1747
+ if( empty($EpisodeData['nodiv']) )
1748
+ $content .= '</div>'.PHP_EOL;
1749
+
1750
+ return $content;
1751
+ }
1752
+
1753
+ /*
1754
+ Flash Mp3 player Maxi
1755
+ */
1756
+ function powerpressplayer_build_flashmp3maxi($media_url, $EpisodeData = array())
1757
+ {
1758
+ $autoplay = false;
1759
+ if( isset($EpisodeData['autoplay']) && $EpisodeData['autoplay'] )
1760
+ $autoplay = true; // TODO: We need to handle this
1761
+
1762
+ $PlayerSettings = get_option('powerpress_flashmp3-maxi');
1763
+ $keys = array('bgcolor1','bgcolor2','bgcolor','textcolor','buttoncolor','buttonovercolor','showstop','showinfo','showvolume','height','width','showloading','buttonwidth','volume','showslider');
1764
+
1765
+ //set PlayerSettings as blank array for initial setup
1766
+ //This keeps the foreach loop from returning an error
1767
+ if( empty($PlayerSettings) )
1768
+ {
1769
+ $PlayerSettings = array(
1770
+ 'bgcolor1'=>'#7c7c7c',
1771
+ 'bgcolor2'=>'#333333',
1772
+ 'textcolor' => '#FFFFFF',
1773
+ 'buttoncolor' => '#FFFFFF',
1774
+ 'buttonovercolor' => '#FFFF00',
1775
+ 'showstop' => '0',
1776
+ 'showinfo' => '0',
1777
+ 'showvolume' => '1',
1778
+ 'height' => '20',
1779
+ 'width' => '200',
1780
+ 'showloading' => 'autohide',
1781
+ 'buttonwidth' => '26',
1782
+ 'volume' => '100',
1783
+ 'showslider' => '1',
1784
+ 'slidercolor1'=>'#cccccc',
1785
+ 'slidercolor2'=>'#888888',
1786
+ 'sliderheight' => '10',
1787
+ 'sliderwidth' => '20',
1788
+ 'loadingcolor' => '#FFFF00',
1789
+ 'volumeheight' => '6',
1790
+ 'volumewidth' => '30',
1791
+ 'sliderovercolor' => '#eeee00');
1792
+ }
1793
+
1794
+ $flashvars = '';
1795
+ $flashvars .= "mp3=" . urlencode($media_url);
1796
+ if( $autoplay )
1797
+ $flashvars .= '&amp;autoplay=1';
1798
+
1799
+ //set non-blank options without dependencies as flash variables for preview
1800
+ foreach($keys as $key)
1801
+ {
1802
+ if( !empty($PlayerSettings[$key]) )
1803
+ {
1804
+ $flashvars .= '&amp;'. $key .'='. preg_replace('/\#/','',$PlayerSettings[''.$key.'']);
1805
+ }
1806
+ }
1807
+
1808
+ //set slider dependencies
1809
+ if( !empty($PlayerSettings['showslider']) ) // IF not zero
1810
+ {
1811
+ if( !empty($PlayerSettings['sliderheight']) ) {
1812
+ $flashvars .= '&amp;sliderheight='. $PlayerSettings['sliderheight'];
1813
+ }
1814
+ if( !empty($PlayerSettings['sliderwidth']) ) {
1815
+ $flashvars .= '&amp;sliderwidth='. $PlayerSettings['sliderwidth'];
1816
+ }
1817
+ if( !empty($PlayerSettings['sliderovercolor']) ){
1818
+ $flashvars .= '&amp;sliderovercolor='. preg_replace('/\#/','',$PlayerSettings['sliderovercolor']);
1819
+ }
1820
+ }
1821
+
1822
+ //set volume dependencies
1823
+ if($PlayerSettings['showvolume'] != "0")
1824
+ {
1825
+ if( !empty($PlayerSettings['volumeheight']) ) {
1826
+ $flashvars .= '&amp;volumeheight='. $PlayerSettings['volumeheight'];
1827
+ }
1828
+ if( !empty($PlayerSettings['volumewidth']) ) {
1829
+ $flashvars .= '&amp;volumewidth='. $PlayerSettings['volumewidth'];
1830
+ }
1831
+ }
1832
+
1833
+ //set autoload dependencies
1834
+ if($PlayerSettings['showloading'] != "never")
1835
+ {
1836
+ if( !empty($PlayerSettings['loadingcolor']) ) {
1837
+ $flashvars .= '&amp;loadingcolor='. preg_replace('/\#/','',$PlayerSettings['loadingcolor']);
1838
+ }
1839
+ }
1840
+
1841
+ //set default width for object
1842
+ if( empty($PlayerSettings['width']) )
1843
+ $width = '200';
1844
+ else
1845
+ $width = $PlayerSettings['width'];
1846
+ if( !empty($EpisodeData['width']) && is_numeric($EpisodeData['width']))
1847
+ $width = $EpisodeData['width'];
1848
+
1849
+ if( empty($PlayerSettings['height']) )
1850
+ $height = '20';
1851
+ else
1852
+ $height = $PlayerSettings['height'];
1853
+ if( !empty($EpisodeData['height']) && is_numeric($EpisodeData['height']) )
1854
+ $height = $EpisodeData['height'];
1855
+
1856
+ //set background transparency
1857
+ if( !empty($PlayerSettings['bgcolor']) )
1858
+ $transparency = '<param name="bgcolor" value="'. $PlayerSettings['bgcolor'] .'" />';
1859
+ else
1860
+ $transparency = '<param name="wmode" value="transparent" />';
1861
+
1862
+ // Add flashmp3-maxi player here
1863
+ $player_id = powerpressplayer_get_next_id();
1864
+ $content = '';
1865
+ $content .= '<div class="powerpress_player" id="powerpress_player_'. $player_id .'">'.PHP_EOL;
1866
+ $content .= '<object type="application/x-shockwave-flash" data="'. powerpress_get_root_url().'player_mp3_maxi.swf" id="player_mp3_maxi_'.$player_id.'" width="'. $width.'" height="'. $height .'">'.PHP_EOL;
1867
+ $content .= '<param name="movie" value="'. powerpress_get_root_url().'player_mp3_maxi.swf" />'.PHP_EOL;
1868
+ $content .= $transparency.PHP_EOL;
1869
+ $content .= '<param name="FlashVars" value="'. $flashvars .'" />'.PHP_EOL;
1870
+ // $content .= powerpressplayer_build_html5audio($media_url, $EpisodeData, true); // Feature removed since it causes double players to be insrted in Safari/Firefox
1871
+ $content .= powerpressplayer_build_playimageaudio($media_url);
1872
+ $content .= '</object>'.PHP_EOL;
1873
+ $content .= '</div>'.PHP_EOL;
1874
+ return $content;
1875
+ }
1876
+
1877
+ /*
1878
+ Audio Play player
1879
+ */
1880
+ function powerpressplayer_build_audioplay($media_url, $EpisodeData = array())
1881
+ {
1882
+ $autoplay = false;
1883
+ if( isset($EpisodeData['autoplay']) && $EpisodeData['autoplay'] )
1884
+ $autoplay = true;
1885
+
1886
+ $PlayerSettings = get_option('powerpress_audioplay');
1887
+ if( empty($PlayerSettings) )
1888
+ {
1889
+ $PlayerSettings = array(
1890
+ 'bgcolor' => '',
1891
+ 'buttondir' => 'negative',
1892
+ 'mode' => 'playpause');
1893
+ }
1894
+
1895
+ $width = $height = (strstr($PlayerSettings['buttondir'], 'small')===false?30:15);
1896
+
1897
+ // Set standard variables for player
1898
+ $flashvars = 'file='.urlencode($media_url) ;
1899
+ $flashvars .= '&amp;repeat=1';
1900
+ if( $autoplay )
1901
+ $flashvars .= '&amp;auto=yes';
1902
+
1903
+ if( empty($PlayerSettings['bgcolor']) )
1904
+ {
1905
+ $flashvars .= "&amp;usebgcolor=no";
1906
+ $transparency = '<param name="wmode" value="transparent" />';
1907
+ $htmlbg = "";
1908
+ }
1909
+ else
1910
+ {
1911
+ $flashvars .= "&amp;bgcolor=". preg_replace('/\#/','0x',$PlayerSettings['bgcolor']);
1912
+ $transparency = '<param name="bgcolor" value="'. $PlayerSettings['bgcolor']. '" />';
1913
+ $htmlbg = 'bgcolor="'. $PlayerSettings['bgcolor'].'"';
1914
+ }
1915
+
1916
+ if( empty($PlayerSettings['buttondir']) )
1917
+ $flashvars .= "&amp;buttondir=".powerpress_get_root_url()."buttons/negative";
1918
+ else
1919
+ $flashvars .= "&amp;buttondir=".powerpress_get_root_url().'buttons/'.$PlayerSettings['buttondir'];
1920
+
1921
+ $flashvars .= '&amp;mode='. $PlayerSettings['mode'];
1922
+
1923
+ // Add audioplay player here
1924
+ $player_id = powerpressplayer_get_next_id();
1925
+ $content = '';
1926
+ $content .= '<div class="powerpress_player" id="powerpress_player_'. $player_id .'">';
1927
+ $content .= '<object type="application/x-shockwave-flash" width="'. $width .'" height="'. $height .'" id="audioplay_'.$player_id.'" data="'. powerpress_get_root_url().'audioplay.swf?'.$flashvars.'">'.PHP_EOL;
1928
+ $content .= '<param name="movie" value="'. powerpress_get_root_url().'audioplay.swf?'.$flashvars.'" />'.PHP_EOL;
1929
+ $content .= '<param name="quality" value="high" />'.PHP_EOL;
1930
+ $content .= $transparency.PHP_EOL;
1931
+ $content .= '<param name="FlashVars" value="'.$flashvars.'" />'.PHP_EOL;
1932
+ $content .= '<embed src="'. powerpress_get_root_url().'audioplay.swf?'.$flashvars.'" quality="high" width="30" height="30" type="application/x-shockwave-flash">'.PHP_EOL;
1933
+ // $content .= powerpressplayer_build_html5audio($media_url, $EpisodeData, true); // Feature removed since it causes double players to be insrted in Safari/Firefox
1934
+ $content .= powerpressplayer_build_playimageaudio($media_url);
1935
+ $content .= "</embed>\n </object>\n";
1936
+ $content .= "</div>\n";
1937
+ return $content;
1938
+ }
1939
+
1940
+ /*
1941
+ Simple Flash player
1942
+ */
1943
+ function powerpressplayer_build_simpleflash($media_url, $EpisodeData = array())
1944
+ {
1945
+ $autoplay = false;
1946
+ if( isset($EpisodeData['autoplay']) && $EpisodeData['autoplay'] )
1947
+ $autoplay = true; // TODO: We need to handle this
1948
+
1949
+ $player_id = powerpressplayer_get_next_id();
1950
+ $content = '';
1951
+ $content .= '<div class="powerpress_player" id="powerpress_player_'. $player_id .'">';
1952
+ $content .= '<object type="application/x-shockwave-flash" data="'. powerpress_get_root_url() .'simple_mp3.swf" id="simple_mp3_'.$player_id.'" width="150" height="50">';
1953
+ $content .= '<param name="movie" value="'. powerpress_get_root_url().'simple_mp3.swf" />';
1954
+ $content .= '<param name="wmode" value="transparent" />';
1955
+ $content .= '<param name="FlashVars" value="'. get_bloginfo('url') .'?url='. urlencode($media_url).'&amp;autostart='. ($autoplay?'true':'false') .'" />';
1956
+ $content .= '<param name="quality" value="high" />';
1957
+ $content .= '<embed wmode="transparent" src="'. get_bloginfo('url') .'?url='.urlencode($media_url).'&amp;autostart='. ($autoplay?'true':'false') .'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="150" height="50">';
1958
+ // $content .= powerpressplayer_build_html5audio($media_url, $EpisodeData, true); // Feature removed since it causes double players to be insrted in Safari/Firefox
1959
+ $content .= powerpressplayer_build_playimageaudio($media_url);
1960
+ $content .= '</embed>';
1961
+ $content .= '</object>';
1962
+ $content .= "</div>\n";
1963
+ return $content;
1964
+ }
1965
+
1966
+ /*
1967
+ VideoJS for PowerPress 4.0
1968
+ */
1969
+ function powerpressplayer_build_videojs($media_url, $EpisodeData = array())
1970
+ {
1971
+ $content = '';
1972
+ if( function_exists('add_videojs_header') )
1973
+ {
1974
+ // Global Settings
1975
+ $Settings = get_option('powerpress_general');
1976
+
1977
+ $player_id = powerpressplayer_get_next_id();
1978
+ $cover_image = '';
1979
+ $player_width = 400;
1980
+ $player_height = 225;
1981
+ $autoplay = false;
1982
+
1983
+ if( !empty($Settings['player_width']) )
1984
+ $player_width = $Settings['player_width'];
1985
+ if( !empty($Settings['player_height']) )
1986
+ $player_height = $Settings['player_height'];
1987
+ if( !empty($Settings['poster_image']) )
1988
+ $cover_image = $Settings['poster_image'];
1989
+
1990
+ // Episode Settings
1991
+ if( !empty($EpisodeData['image']) )
1992
+ $cover_image = $EpisodeData['image'];
1993
+ if( !empty($EpisodeData['width']) )
1994
+ $player_width = $EpisodeData['width'];
1995
+ if( !empty($EpisodeData['height']) )
1996
+ $player_height = $EpisodeData['height'];
1997
+ if( !empty($EpisodeData['autoplay']) )
1998
+ $autoplay = true;
1999
+
2000
+ // Poster image supplied
2001
+ $poster_attribute = '';
2002
+ if ($cover_image)
2003
+ $poster_attribute = ' poster="'.$cover_image.'"';
2004
+
2005
+ // Autoplay the video?
2006
+ $autoplay_attribute = '';
2007
+ if ( $autoplay )
2008
+ $autoplay_attribute = ' autoplay';
2009
+
2010
+ // We never do pre-poading for podcasting as it inflates statistics
2011
+
2012
+ // Is there a custom class?
2013
+ $class = '';
2014
+ if ( !empty($Settings['videojs_css_class']) )
2015
+ $class = ' '. $Settings['videojs_css_class'];
2016
+
2017
+ $content .= '<div class="powerpress_player" id="powerpress_player_'. $player_id .'">';
2018
+
2019
+ $content .= '<video id="videojs_player_'. $player_id .'" class="video-js vjs-default-skin'. $class .'" width="'. $player_width .'" height="'. $player_height .'"'. $poster_attribute .' controls '. $autoplay_attribute .' data-setup="{}">';
2020
+
2021
+ $content_type = powerpress_get_contenttype($media_url);
2022
+ if( $content_type == 'video/x-m4v' )
2023
+ $content_type = 'video/mp4'; // Mp4
2024
+ $content .='<source src="'. $media_url .'" type="'. $content_type .'" />';
2025
+
2026
+ if( !empty($EpisodeData['webm_src']) )
2027
+ {
2028
+ $EpisodeData['webm_src'] = powerpress_add_flag_to_redirect_url($EpisodeData['webm_src'], 'p');
2029
+ $content .='<source src="'. $EpisodeData['webm_src'] .'" type="video/webm; codecs="vp8, vorbis" />';
2030
+ }
2031
+
2032
+ $content .= '</video>';
2033
+ $content .= "</div>\n";
2034
+ }
2035
+ else
2036
+ {
2037
+ $content .= powerpressplayer_build_html5video($media_url, $EpisodeData);
2038
+ }
2039
+
2040
+ return $content;
2041
+ }
2042
+
2043
+ ?>
powerpress.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Blubrry PowerPress
4
  Plugin URI: http://create.blubrry.com/resources/powerpress/
5
  Description: <a href="http://create.blubrry.com/resources/powerpress/" target="_blank">Blubrry PowerPress</a> adds podcasting support to your blog. Features include: media player, 3rd party statistics, iTunes integration, Blubrry Services (Media Statistics and Hosting) integration and a lot more.
6
- Version: 5.0.9
7
  Author: Blubrry
8
  Author URI: http://www.blubrry.com/
9
  Change Log:
@@ -32,7 +32,7 @@ if( !function_exists('add_action') )
32
  die("access denied.");
33
 
34
  // WP_PLUGIN_DIR (REMEMBER TO USE THIS DEFINE IF NEEDED)
35
- define('POWERPRESS_VERSION', '5.0.9' );
36
 
37
  // Translation support:
38
  if ( !defined('POWERPRESS_ABSPATH') )
3
  Plugin Name: Blubrry PowerPress
4
  Plugin URI: http://create.blubrry.com/resources/powerpress/
5
  Description: <a href="http://create.blubrry.com/resources/powerpress/" target="_blank">Blubrry PowerPress</a> adds podcasting support to your blog. Features include: media player, 3rd party statistics, iTunes integration, Blubrry Services (Media Statistics and Hosting) integration and a lot more.
6
+ Version: 5.0.10
7
  Author: Blubrry
8
  Author URI: http://www.blubrry.com/
9
  Change Log:
32
  die("access denied.");
33
 
34
  // WP_PLUGIN_DIR (REMEMBER TO USE THIS DEFINE IF NEEDED)
35
+ define('POWERPRESS_VERSION', '5.0.10' );
36
 
37
  // Translation support:
38
  if ( !defined('POWERPRESS_ABSPATH') )
powerpressadmin.php CHANGED
@@ -3897,7 +3897,6 @@ function powerpressadmin_community_news($items=3)
3897
  if( $embed_tag && !empty($embed_tag[0]['data']) )
3898
  $embed = $embed_tag[0]['data'];
3899
 
3900
- echo '<div class="powerpressNewsPlayer">';
3901
 
3902
  if( $first_item && $embed )
3903
  {
@@ -3907,9 +3906,12 @@ function powerpressadmin_community_news($items=3)
3907
  $embed = preg_replace('/width="/i', 'style="max-width: '.$max_width.'px;" width="', $embed );
3908
  }
3909
  $embed = preg_replace('/width="(\d{1,4})"/i', 'width="100%"', $embed );
 
 
3910
  echo $embed;
 
3911
  }
3912
- else
3913
  {
3914
  $EpisodeData = array();
3915
  $EpisodeData['type'] = $enclosure->type;
@@ -3923,22 +3925,26 @@ function powerpressadmin_community_news($items=3)
3923
  case 'mp4':
3924
  case 'm4v':
3925
  case 'webm': {
3926
-
3927
  if( version_compare($GLOBALS['wp_version'], '3.6-alpha', '>') )
3928
  echo powerpressplayer_build_mediaelementvideo($enclosure->link, $EpisodeData);
3929
  else
3930
  echo powerpressplayer_build_html5video($enclosure->link, $EpisodeData);
 
3931
  }; break;
3932
  case 'mp3':
3933
  case 'm4a': {
 
3934
  if( version_compare($GLOBALS['wp_version'], '3.6-alpha', '>') )
3935
  echo powerpressplayer_build_mediaelementaudio($enclosure->link, $EpisodeData);
3936
  else
3937
  echo powerpressplayer_build_html5audio($enclosure->link, $EpisodeData);
 
3938
  }; break;
3939
  }
3940
  }
3941
- echo '</div>';
 
3942
  }
3943
  echo '</li>';
3944
  $first_item = false;
3897
  if( $embed_tag && !empty($embed_tag[0]['data']) )
3898
  $embed = $embed_tag[0]['data'];
3899
 
 
3900
 
3901
  if( $first_item && $embed )
3902
  {
3906
  $embed = preg_replace('/width="/i', 'style="max-width: '.$max_width.'px;" width="', $embed );
3907
  }
3908
  $embed = preg_replace('/width="(\d{1,4})"/i', 'width="100%"', $embed );
3909
+
3910
+ echo '<div class="powerpressNewsPlayer">';
3911
  echo $embed;
3912
+ echo '</div>';
3913
  }
3914
+ else if( $first_item )
3915
  {
3916
  $EpisodeData = array();
3917
  $EpisodeData['type'] = $enclosure->type;
3925
  case 'mp4':
3926
  case 'm4v':
3927
  case 'webm': {
3928
+ echo '<div class="powerpressNewsPlayer powerpressadmin-mejs-video">';
3929
  if( version_compare($GLOBALS['wp_version'], '3.6-alpha', '>') )
3930
  echo powerpressplayer_build_mediaelementvideo($enclosure->link, $EpisodeData);
3931
  else
3932
  echo powerpressplayer_build_html5video($enclosure->link, $EpisodeData);
3933
+ echo '</div>';
3934
  }; break;
3935
  case 'mp3':
3936
  case 'm4a': {
3937
+ echo '<div class="powerpressNewsPlayer">';
3938
  if( version_compare($GLOBALS['wp_version'], '3.6-alpha', '>') )
3939
  echo powerpressplayer_build_mediaelementaudio($enclosure->link, $EpisodeData);
3940
  else
3941
  echo powerpressplayer_build_html5audio($enclosure->link, $EpisodeData);
3942
+ echo '</div>';
3943
  }; break;
3944
  }
3945
  }
3946
+
3947
+ //echo '<div style="clear: both;"></div>';
3948
  }
3949
  echo '</li>';
3950
  $first_item = false;
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: amandato, blubrry
3
  Tags: podcasting, podcast, podcaster, itunes, enclosure, zune, iphone, youtube, viddler, blip.tv, ustream, podcasting, audio, video, rss2, feed, player, media, rss, mp3, music, embed, feedburner, statistics, stats, flv, flash, id3, episodes, blubrry, webm, mp4, m4v, wordpressmu, mu, wordpress mu, multisite, multi site, mediacaster, post, plugin, posts, simple, social, dashboard, TSG, Buzzsprout, MTR, WP-boxCast, CastMyBlog, simple podcasting, seriously simple podcasting, seriously-simple-podcasting, podlove, podcast.de
4
  Requires at least: 3.0
5
- Tested up to: 3.9.1
6
- Stable tag: 5.0.9
7
  Donate link: http://create.blubrry.com/
8
  License: GPLv2 or later
9
 
@@ -175,6 +175,13 @@ To install Blubrry PowerPress manually, follow these steps:
175
  * We are looking for beta testers! If you would like to beta test future versions of PowerPress, please [contact us](http://www.blubrry.com/contact.php) with your name and email.
176
 
177
 
 
 
 
 
 
 
 
178
  = 5.0.9 =
179
  * Released on 7/28/2014
180
  * Fixed wo logic errors in the powerpress-player.php (Thanks Tom from the Hawaii Vacation Connection podcast for bringing to our attention)
2
  Contributors: amandato, blubrry
3
  Tags: podcasting, podcast, podcaster, itunes, enclosure, zune, iphone, youtube, viddler, blip.tv, ustream, podcasting, audio, video, rss2, feed, player, media, rss, mp3, music, embed, feedburner, statistics, stats, flv, flash, id3, episodes, blubrry, webm, mp4, m4v, wordpressmu, mu, wordpress mu, multisite, multi site, mediacaster, post, plugin, posts, simple, social, dashboard, TSG, Buzzsprout, MTR, WP-boxCast, CastMyBlog, simple podcasting, seriously simple podcasting, seriously-simple-podcasting, podlove, podcast.de
4
  Requires at least: 3.0
5
+ Tested up to: 4.1
6
+ Stable tag: 5.0.10
7
  Donate link: http://create.blubrry.com/
8
  License: GPLv2 or later
9
 
175
  * We are looking for beta testers! If you would like to beta test future versions of PowerPress, please [contact us](http://www.blubrry.com/contact.php) with your name and email.
176
 
177
 
178
+ = 5.0.10 =
179
+ * Released on 12/16/2014
180
+ * Update your copy of PowerPress to version 5.0.10 immediately
181
+ * Due to concerns of possible security exploits, the FlowPlayer flash based player has been removed from PowerPress as of version 5.0.10. PowerPress users are strongly encouraged to update their copy of PowerPress immediately.
182
+ * FlowPlayer will be replaced with the default WordPress MediaElement.js player.
183
+
184
+
185
  = 5.0.9 =
186
  * Released on 7/28/2014
187
  * Fixed wo logic errors in the powerpress-player.php (Thanks Tom from the Hawaii Vacation Connection podcast for bringing to our attention)