windhamdavid 5 years ago
parent
commit
7bdea1a099
2 changed files with 31 additions and 0 deletions
  1. 28 0
      js/last.fm.js
  2. 3 0
      page-music.php

+ 28 - 0
js/last.fm.js

@@ -585,6 +585,34 @@ $(function(){
 });
 */
 
+
+function radioTitle() {
+ 
+    var url = 'http://64.207.154.37:8008/status2.xsl';
+    var mountpoint = '/stream';
+ 
+    $.ajax({  type: 'GET',
+          url: url,
+          async: true,
+          jsonpCallback: 'parseMusic',
+          contentType: "application/json",
+          dataType: 'jsonp',
+          success: function (json) {
+            $('#track').text(json[mountpoint].title);
+            $('#listeners').text(json[mountpoint].listeners); 
+			$('#bitrate').text(json[mountpoint].bitrate);  
+        },
+          error: function (e) {    console.log(e.message);  
+        }
+    });
+}
+
+$(document).ready(function () {
+    setTimeout(function () {radioTitle();}, 2000);
+    setInterval(function () {radioTitle();}, 30000); // update every 30 seconds
+});
+
+
 amplitude_config = {
 	"amplitude_songs": [
 		{

+ 3 - 0
page-music.php

@@ -149,6 +149,9 @@ get_header(); ?>
 								<div class="panel-footer">
 									<h5><?php echo $nowPlaying->getNowPlaying(); ?></h5>
 								</div>
+								<p>Listeners: <span id="listeners">00</span></p>
+								<p>Current track: <span id="track-title">Off Air</span></p>
+								<p>Bitrate: <span id="bitrate">bitrate</span> Kbps 44.100 Khz</p>
 								<!-- <ul class="mounts"></ul> -->
 							</div>
 						</div>