Skip to first unread message

Radio 397

unread,
Aug 23, 2016, 9:11:56 AM8/23/16
to MIT App Inventor Forum
Hi

I want to display the Track Name as a Label, which is currently being Played in my Radio App. The Track name is provided by Shoutcast servers which stream my radio too. Shoutcast servers have given two options to get the Track Name:
Option 1:
They have provided a javascript:
I am using this javascript in a webpage and then displaying that webpage in my App. But it looks ugly and I do not want to do that.

Option 2:
They have provided a PHP script too. but I have no Idea how to use that to get the Track Name

Is there any method, which allows me to get the track name in a string and that string can be used then to name the Label ?

JavaScript:
<script src="http://scripts.myradiostream.com/s34/13110/song.js"></script>

PHP Script:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "s34.myradiostream.com:13110/7.html");
curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
$data = curl_exec($ch);
curl_close($ch);
$data = str_replace('</body></html>', "", $data);
$split = explode(',', $data); 
if (empty($split[6])) { 
	$title = "The current song is not available "; 
} else { 
	$count = count($split); 
	$i = "6"; 
	while($i<=$count) { 
		if ($i > 6) { 
			$title .= "," . $split[$i]; 
		} else { 
			$title .= $split[$i]; 
		} 
		$i++; 
	}
}
$title = substr($title, 0, -1);
echo $title;
?>

Mika

unread,
Aug 23, 2016, 1:57:52 PM8/23/16
to mitappinv...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages