PageRenderTime 44ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/services/services/players/ptunes.php

https://github.com/jinzora/jinzora3
PHP | 183 lines | 81 code | 23 blank | 79 comment | 11 complexity | 588d97dbb440b831e11791d688cdc925 MD5 | raw file
  1. <?php if (!defined(JZ_SECURE_ACCESS)) die ('Security breach detected.');
  2. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  3. * JINZORA | Web-based Media Streamer
  4. *
  5. * Jinzora is a Web-based media streamer, primarily desgined to stream MP3s
  6. * (but can be used for any media file that can stream from HTTP).
  7. * Jinzora can be integrated into a CMS site, run as a standalone application,
  8. * or integrated into any PHP website. It is released under the GNU GPL.
  9. *
  10. * Jinzora Author:
  11. * Ross Carlson: ross@jasbone.com
  12. * http://www.jinzora.org
  13. * Documentation: http://www.jinzora.org/docs
  14. * Support: http://www.jinzora.org/forum
  15. * Downloads: http://www.jinzora.org/downloads
  16. * License: GNU GPL <http://www.gnu.org/copyleft/gpl.html>
  17. *
  18. * Contributors:
  19. * Please see http://www.jinzora.org/modules.php?op=modload&name=jz_whois&file=index
  20. *
  21. * Code Purpose: Creates and sends an M3U playlist to the Pocket Tunes player for PalmOS
  22. * Created: 03.03.05 by Ross Carlson
  23. *
  24. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  25. define('SERVICE_PLAYERS_ptunes','true');
  26. /**
  27. * Returns the player width
  28. *
  29. * @author Ben Dodson
  30. * @version 8/23/05
  31. * @since 8/23/05
  32. */
  33. function SERVICE_RETURN_PLAYER_WIDTH_ptunes(){
  34. return 0;
  35. }
  36. /**
  37. * Returns the players height.
  38. *
  39. * @author Ben Dodson
  40. * @version 8/23/05
  41. * @since 8/23/05
  42. */
  43. function SERVICE_RETURN_PLAYER_HEIGHT_ptunes(){
  44. return 0;
  45. }
  46. /**
  47. * Returns the data for the form posts for the player
  48. *
  49. * @author Ross Carlson
  50. * @version 06/05/05
  51. * @since 06/05/05
  52. * @param $formname The name of the form that is being created
  53. */
  54. function SERVICE_RETURN_PLAYER_FORM_LINK_ptunes($formname){
  55. return "document.". $formname. ".target='embeddedPlayer'; openMediaPlayer('', 100, 100);";
  56. }
  57. /**
  58. * Returns the data for the href's to open the popup player
  59. *
  60. * @author Ross Carlson
  61. * @version 06/05/05
  62. * @since 06/05/05
  63. */
  64. function SERVICE_RETURN_PLAYER_HREF_ptunes(){
  65. return ' target="embeddedPlayer" onclick="openMediaPlayer(this.href, 300, 150); return false;"';
  66. }
  67. /**
  68. * Actually displays this embedded player
  69. *
  70. * @author Ross Carlson
  71. * @version 3/03/05
  72. * @since 3/03/05
  73. * @param $list an array containing the tracks to be played
  74. */
  75. function SERVICE_DISPLAY_PLAYER_ptunes($asx){
  76. global $root_dir, $this_site, $css;
  77. if ($asx){
  78. echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='. $this_site. $root_dir. '/plist.asx">&nbsp;';
  79. } else {
  80. header("Location: ". $this_site. $root_dir. "/temp/ptunes-". $_SESSION['jz_playlist_number']. ".m3u");
  81. }
  82. }
  83. /**
  84. * Processes data for the jlGui embedded player
  85. *
  86. * @author Ross Carlson
  87. * @version 3/03/05
  88. * @since 3/03/05
  89. * @param $list an array containing the tracks to be played
  90. */
  91. function SERVICE_OPEN_PLAYER_ptunes($list){
  92. global $include_path, $root_dir;
  93. // Let's start the list off right
  94. $content = "#EXTM3U\n";
  95. $list->flatten();
  96. // First we need to make sure there aren't any WMV files here meaning they really want an ASX playlist
  97. $asx=false;
  98. foreach ($list->getList() as $track) {
  99. if (stristr($track->getPath("string"),".wmv")){
  100. $asx=true;
  101. $content = '<ASX version="3">'. "\n";
  102. $content .= ' <TITLE>Jinzora Playlist</Title>'. "\n";
  103. }
  104. }
  105. // Now let's loop throught the items to create the list
  106. foreach ($list->getList() as $track) {
  107. // Should we play this?
  108. if ((stristr($track->getPath("String"),".lofi.")
  109. or stristr($track->getPath("String"),".clip."))
  110. and $_SESSION['jz_play_all_tracks'] <> true){continue;}
  111. $meta = $track->getMeta();
  112. if ($asx){
  113. // Now let's get the extension to be sure it can be played
  114. $pArr = explode("/",$track->getPath("String"));
  115. $eArr = explode(".",$pArr[count($pArr)-1]);
  116. $ext = $eArr[count($eArr)-1];
  117. $meta = $track->getMeta();
  118. $content .= " <ENTRY>". "\n".
  119. " <TITLE>". $meta['artist'] . " - " . $meta['title']. "</TITLE>". "\n";
  120. // Now let's figure out the full track name
  121. $trackn = $track->getFileName("user");
  122. if (!stristr($trackn,"mediabroadcast.php")) {
  123. $track->increasePlayCount();
  124. }
  125. $content .= ' <REF HREF="'. $trackn. '"/>'. "\n".
  126. ' </ENTRY>'. "\n";
  127. } else {
  128. $content .= "#EXTINF:";
  129. $content .= $meta['length'] . ",";
  130. $content .= $meta['artist'] . " - " . $meta['title'] . "\n";
  131. // Now let's figure out the full track name
  132. $trackn = $track->getFileName("user");
  133. //echo $track; exit();
  134. $content .= $trackn. "\n";
  135. }
  136. if (!stristr($trackn,"mediabroadcast.php")) {
  137. $track->increasePlayCount();
  138. }
  139. }
  140. // Now let's generate a random number for the playlist
  141. $_SESSION['jz_playlist_number'] = rand(1,99999);
  142. if ($asx){
  143. $content .= '</ASX>';
  144. // Now that we've got the playlist, let's write it out to the disk
  145. $plFile = $include_path. "temp/windowsmobile-". $_SESSION['jz_playlist_number']. ".asx";
  146. @unlink($plFile);
  147. $handle = fopen ($plFile, "w");
  148. fwrite($handle,$content);
  149. fclose($handle);
  150. } else {
  151. // Now that we've got the playlist, let's write it out to the disk
  152. $plFile = $include_path. "temp/ptunes-". $_SESSION['jz_playlist_number']. ".m3u";
  153. @unlink($plFile);
  154. $handle = fopen ($plFile, "w");
  155. fwrite($handle,$content);
  156. fclose($handle);
  157. }
  158. SERVICE_DISPLAY_PLAYER_ptunes($asx);
  159. }
  160. ?>