Changeset 1107
- Timestamp:
- 10/22/08 22:26:24 (1 year ago)
- Files:
-
- trunk/swisscenter/base/capabilities.php (modified) (1 diff)
- trunk/swisscenter/base/image_screens.php (modified) (2 diffs)
- trunk/swisscenter/base/playlist.php (modified) (1 diff)
- trunk/swisscenter/music_radio_image.php (modified) (1 diff)
- trunk/swisscenter/music_radio_urls.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/swisscenter/base/capabilities.php
r1095 r1107 378 378 379 379 #------------------------------------------------------------------------------------------------- 380 # Returns the POD (Picture On Demand) parameter to pass to the hardware player that controls how 381 # an audio stream with images will be synchronized together. 382 #------------------------------------------------------------------------------------------------- 383 384 function stream_pod_type() 385 { 386 $result = 1; // Default values for players unless we discover otherwise. 387 388 switch ( get_player_type() ) 389 { 390 case 'POPCORN': 391 $result = 2; 392 break; 393 } 394 395 return $result; 396 } 397 398 #------------------------------------------------------------------------------------------------- 380 399 # The transition effect to use between "Now Playing" screens. 381 400 # trunk/swisscenter/base/image_screens.php
r1013 r1107 83 83 //------------------------------------------------------------------------------------------------ 84 84 85 function station_playing_image( $station_name )85 function station_playing_image( $station_name, $now_playing ) 86 86 { 87 87 $title_text_size = font_size( 24, SCREEN_COORDS); … … 94 94 $image->resize( convert_x(1000,SCREEN_COORDS), convert_y(1000,SCREEN_COORDS), 0, false); 95 95 wrap( $image,$station_name, $title_x, $title_y, convert_x(500,SCREEN_COORDS), $title_text_col, $title_text_size); 96 $title_y+=($title_text_size*2.5); 97 wrap( $image,$now_playing, $title_x, $title_y, convert_x(500,SCREEN_COORDS), $title_text_col, $title_text_size); 96 98 return $image; 97 99 } trunk/swisscenter/base/playlist.php
r1095 r1107 244 244 function play_internet_radio( $playlist_url, $station_name ) 245 245 { 246 return 'href="'.$playlist_url.'" pod=" 1,1,'.server_address().'music_radio_image.php?'.current_session().'&list=&station='.urlencode($station_name).'"';246 return 'href="'.$playlist_url.'" pod="'.stream_pod_type().',1,'.server_address().'music_radio_image.php?'.current_session().'&list=&station='.urlencode($station_name).'&playlist='.urlencode($playlist_url).'"'; 247 247 } 248 248 trunk/swisscenter/music_radio_image.php
r1030 r1107 7 7 require_once( realpath(dirname(__FILE__).'/base/capabilities.php')); 8 8 9 /** 10 * Returns the track title currently being played by the ShoutCast server. 11 * 12 * @param integer $host 13 * @param integer $port 14 * @return string 15 */ 16 function shoutcast_now_playing($host, $port) 17 { 18 send_to_log(5,'Connecting to ShoutCast server '.$host.':'.$port); 19 $fp = @fsockopen($host,$port,$errno,$errstr,10); 20 if (!$fp) 21 { 22 send_to_log(5,'- Connection refused'); // Displays when sever is offline 23 } 24 else 25 { 26 fputs($fp, "GET /7.html HTTP/1.0\r\nUser-Agent: Mozilla\r\n\r\n"); 27 while (!feof($fp)) 28 { 29 $info = fgets($fp); 30 } 31 $info = str_replace('</body></html>', "", $info); 32 $split = explode(',', $info); 33 if (empty($split[6]) ) 34 { 35 send_to_log(5,'- The current song is not available'); // Displays when server is online but no song title 36 } 37 else 38 { 39 $title = str_replace('\'', '`', $split[6]); 40 $title = str_replace(',', ' ', $title); 41 send_to_log(5,'- Now playing "'.$title.'"'); 42 return $title; // Displays song 43 } 44 } 45 } 46 47 if ( empty($_REQUEST["host"]) || empty($_REQUEST["port"]) ) 48 { 49 // Retrieve server details from playlist (pls) (3 attempts) 50 $i=0; 51 send_to_log(6,'Attempting to obtain server details from radio playlist'); 52 while ( $i < 3 && empty($info) ) 53 { 54 if ( ($info = file_get_contents(urldecode(un_magic_quote($_REQUEST["playlist"])))) == false ) 55 send_to_log(6,'- Attempt '.$i.': Failed to download playlist'); 56 elseif ( preg_match('/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}):(\d{1,5})/', $info, $host) == 0 ) 57 send_to_log(6,'- Failed to find internet radio server in playlist:', $info); 58 else 59 send_to_log(6,'- Radio server found at '.$host[1].':'.$host[2]); 60 $i++; 61 } 62 } 63 else 64 { 65 $host[1] = $_REQUEST["host"]; 66 $host[2] = $_REQUEST["port"]; 67 } 68 9 69 if ( isset($_REQUEST["list"])) 10 70 { 11 71 // List of images to display to the user (changes every 30 seconds) 12 72 $server = server_address(); 13 $url = $server."music_radio_image.php?".current_session()."&station=".urlencode(un_magic_quote($_REQUEST["station"]))."&x=.jpg"; 73 $station = un_magic_quote($_REQUEST["station"]); 74 $url = $server."music_radio_image.php?".current_session()."&host=".$host[1]."&port=".$host[2]. 75 "&station=".urlencode($station)."&x=.jpg"; 14 76 $transition = now_playing_transition(); 15 echo "3 600|$transition| |$url|\n";16 echo "3 600|$transition| |$url|\n";77 echo "30|$transition| |$url|\n"; 78 echo "30|$transition| |$url|\n"; 17 79 } 18 80 else 19 81 { 20 // Generate and display the "Now Playing" screen. 21 $image = station_playing_image(un_magic_quote($_REQUEST["station"])); 82 // Generate and display the "Now Playing" screen. 83 $playing = shoutcast_now_playing($host[1], $host[2]); 84 $image = station_playing_image(un_magic_quote($_REQUEST["station"]), $playing); 22 85 $image->output('jpeg'); 23 86 } trunk/swisscenter/music_radio_urls.php
r914 r1107 14 14 preg_match('/\bURL=.*\n?/',$contents,$matches); 15 15 $url = substr($matches[0],4); 16 return play_internet_radio($url, file_noext($ url));16 return play_internet_radio($url, file_noext($file)); 17 17 } 18 18