windhamdavid 4 years ago
parent
commit
fe78f50058
2 changed files with 52 additions and 48 deletions
  1. 14 5
      js/fm.js
  2. 38 43
      page-music.php

+ 14 - 5
js/fm.js

@@ -601,27 +601,35 @@ function get_radio_tower() {
 function get_radio_none() {
 	return '../../wp-content/themes/dw/img/none.svg';
 }
+function get_radio_eq() {
+	return '../../wp-content/themes/dw/img/eq.gif';
+}
+function get_radio_eq_none() {
+	return '../../wp-content/themes/dw/img/1.png';
+}
 
 function radioTitle() {
-	$('#radio').attr('src', get_radio_none()).fadeIn(100);
+	$('#radio').attr('src', get_radio_none()).fadeIn(300);
+	$('#eq').attr('src', get_radio_eq_none()).fadeIn(300);
     var url = 'http://code.davidawindham.com:8008/status2.xsl';
     var mountpoint = '/stream';
- 
     $.ajax({ type: 'GET',
           url: url,
           async: true,
           jsonpCallback: 'parseMusic',
           contentType: "application/json",
           dataType: 'jsonp',
-          success: function (json) {
+          success: function (json) {	
 			$('#track').text(json[mountpoint].title);
             $('#listeners').text(json[mountpoint].listeners);
 			$('#peak-listeners').text(json[mountpoint].peak_listeners); 
 			$('#bitrate').text(json[mountpoint].bitrate); 
-			$('#radio').attr('src', get_radio_tower()).fadeIn(100); 
+			$('#radio').attr('src', get_radio_tower()).fadeIn(300);
+			$('#eq').attr('src', get_radio_eq()).fadeIn(300);
         },
           error: function (e) { console.log(e.message);
-			  $('#radio').attr('src', get_radio_none()).fadeIn(100); 
+			  $('#radio').attr('src', get_radio_none()).fadeIn(300);
+			  $('#eq').attr('src', get_radio_eq_none()).fadeIn(300);
         }
     });
 }
@@ -631,6 +639,7 @@ $(document).ready(function () {
     setInterval(function () {radioTitle();}, 30000); // update every 30 seconds
 });
 
+
 $('.nav-toggle').on('touchstart click', function(e) {
 	e.preventDefault();
 	$( this ).toggleClass( 'active' );

+ 38 - 43
page-music.php

@@ -12,36 +12,6 @@ get_header(); ?>
 				<div id="music" class="entry-content">
 					<div class="row">
 						<div class="col-sm-12">							
-							<?php class NowPlaying{
-							    private $url;
-							    private $noTrackPlayingMessage;
-							    function __construct($user, $api_key){
-							        $this->url  = 'http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&limit=1';
-							        $this->url .= '&user=' . $user . '&api_key=' . $api_key;
-							        $this->noTrackPlayingMessage = 'All Quiet - Silence is Golden';
-							    }
-							    public function getNowPlaying(){
-							        $xml = simplexml_load_file($this->url);
-							        $track = $xml->recenttracks->track;
-							        $nowplaying = $track->attributes()->nowplaying;
-							        if($nowplaying){
-							            $artist = $track->artist;
-							            $songname = $track->name;
-										$albumname = $track->album;
-										$albumart = $track->album->image[2];
-							            return '<img src="../../wp-content/themes/dw/img/eq.gif"> ' . ' ' . $artist . ' - ' . $songname;
-							        }
-							        else{
-							            return $this->noTrackPlayingMessage;
-							        }
-							    }
-							    public function setNoTrackPlayingMessage($messageIn){
-							        $this->noTrackPlayingMessage = $messageIn;
-							    }
-							} 
-							$nowPlaying = new NowPlaying('windhamdavid', 'e12ea1d0253898ee9a93edfe42ffdeab');
-							?>
-
 							<div class="row">
 								<div class="col-sm-8 col-sm-offset-2">
 									<div class="panel panel-default">
@@ -49,13 +19,13 @@ get_header(); ?>
 											<div id="player">
 												<div id="song-information">
 													<div class="row">
-														<div class="col-xs-6">
+														<div class="col-xs-8">
 															<img id="radio" src="" title="radio" width="25px" style="float:left;margin-right:15px;">
 															<span id="amplitude-now-playing-listeners">Listeners: <span id="listeners">00</span> - Peak: <span id="peak-listeners">00</span></span><br>
 															<span id="amplitude-now-playing-bitrate">Bitrate: <span id="bitrate">00</span> Kbps 44.100 Khz</span>
 														</div>
-														<div class="col-xs-6">
-															<span id="amplitude-now-playing-name">Current track: <span id="track">* Off Air *</span></span><br>
+														<div class="col-xs-4">
+															
 														</div>
 													</div>
 												</div>
@@ -68,18 +38,13 @@ get_header(); ?>
 											</div>
 										</div>
 										<div class="panel-footer">
-											<h6 style="margin:0;"><?php echo $nowPlaying->getNowPlaying(); ?></h6>
+											<h6 style="margin:0;"><img id="eq" src="" title="eq" style="float:left;margin:3px 10px 0 7px;"> <span id="amplitude-now-playing-name">Current track: <span id="track">* Off Air *</span></span></h6>
 										</div>
 									</div>
 								</div>
 							</div>
 						</div>
 					</div>
-					<div class="row">
-						<div class="col-sm-12">
-							<p>&nbsp;</p>
-						</div>
-					</div>
 					<div class="divider"></div>
 					<?php the_content(); ?>
 					<div class="row">
@@ -147,7 +112,6 @@ get_header(); ?>
 							</div>
 						</div>
 					</div>
-
 					<div class="row">
 						<div class="col-sm-12">
 							<div id="music-notes">
@@ -171,11 +135,42 @@ get_header(); ?>
 						<div class="col-sm-12">
 
 						</div>
-					</div>
-					
-					
+					</div>		
+					<?php class NowPlaying{
+					    private $url;
+					    private $noTrackPlayingMessage;
+					    function __construct($user, $api_key){
+					        $this->url  = 'http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&limit=1';
+					        $this->url .= '&user=' . $user . '&api_key=' . $api_key;
+					        $this->noTrackPlayingMessage = 'All Quiet - Silence is Golden';
+					    }
+					    public function getNowPlaying(){
+					        $xml = simplexml_load_file($this->url);
+					        $track = $xml->recenttracks->track;
+					        $nowplaying = $track->attributes()->nowplaying;
+					        if($nowplaying){
+					            $artist = $track->artist;
+					            $songname = $track->name;
+								$albumname = $track->album;
+								$albumart = $track->album->image[2];
+					            return '<img src="../../wp-content/themes/dw/img/eq.gif"> ' . ' ' . $artist . ' - ' . $songname;
+					        }
+					        else{
+					            return $this->noTrackPlayingMessage;
+					        }
+					    }
+					    public function setNoTrackPlayingMessage($messageIn){
+					        $this->noTrackPlayingMessage = $messageIn;
+					    }
+					} 
+					$nowPlaying = new NowPlaying('windhamdavid', 'e12ea1d0253898ee9a93edfe42ffdeab');
+					?>
 					<div class="row">
 						<div class="col-sm-12">
+							<h5 class="cm-type"><em>Currently Playing</em></h5>
+							<ul class="list-group">
+								<li class="list-group-item"><h5 style="margin:0;"><?php echo $nowPlaying->getNowPlaying(); ?></h5></li>
+							</ul>
 							<h5 class="cm-type"><em>Recently Played</em></h5>
 							<ul class="list-group">
 								<div class="recent"></div>