page-music.php 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <?php
  2. /*
  3. Template Name: Music
  4. */
  5. get_header(); ?>
  6. <div class="container">
  7. <article id="content" class="single" role="main">
  8. <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
  9. <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  10. <div id="music" class="entry-content">
  11. <div class="row">
  12. <div class="col-sm-12">
  13. <div class="row">
  14. <div class="col-sm-8 col-sm-offset-2">
  15. <div class="panel panel-default">
  16. <div class="panel-body">
  17. <div id="player">
  18. <div id="song-information">
  19. <div class="row">
  20. <div class="col-xs-8">
  21. <img id="radio" src="" title="radio" width="25px" style="float:left;margin-right:15px;">
  22. <span id="amplitude-now-playing-listeners">Listeners: <span id="listeners">00</span> - Peak: <span id="peak-listeners">00</span></span><br>
  23. <span id="amplitude-now-playing-bitrate">Bitrate: <span id="bitrate">00</span> Kbps 44.100 Khz</span>
  24. </div>
  25. <div class="col-xs-4">
  26. </div>
  27. </div>
  28. </div>
  29. <input class="bar" type="range" id="amplitude-volume-slider" value="90"/>
  30. <div id="controls">
  31. <div id="amplitude-play-pause" class="amplitude-paused"></div><br>
  32. <span id="amplitude-current-time">0:00</span>
  33. </div>
  34. </div>
  35. </div>
  36. <div class="panel-footer">
  37. <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>
  38. </div>
  39. </div>
  40. </div>
  41. </div>
  42. </div>
  43. </div>
  44. <div class="divider"></div>
  45. <?php the_content(); ?>
  46. <div class="row">
  47. <div class="col-sm-12">
  48. <p>&nbsp;</p>
  49. </div>
  50. </div>
  51. <div class="row">
  52. <div class="col-sm-12">
  53. <h5 class="cm-type"><em></em></h5>
  54. <div class="timeline">
  55. <canvas id="timechart" width="900" height="400"></canvas>
  56. </div>
  57. </div>
  58. </div>
  59. <div class="row">
  60. <div class="col-sm-2">
  61. <h5 class="cm-type"><em></em></h5>
  62. </div>
  63. <div class="col-sm-2">
  64. <h5 class="cm-type"><em></em></h5>
  65. </div>
  66. <div class="col-sm-4">
  67. </div>
  68. <div class="col-sm-4">
  69. </div>
  70. </div>
  71. <div class="row">
  72. <div class="col-md-4">
  73. <div class="row">
  74. <div class="col-sm-6">
  75. <ul class="list-group">
  76. <li class="list-group-item active">Tracks</li>
  77. <li class='list-group-item'>Year<span class='badge'>7151</span></li>
  78. <li class='list-group-item'>Month<span class='badge'>687</span></li>
  79. <li class='list-group-item'>Day<span class='badge'>37</span></li>
  80. </li>
  81. </ul>
  82. <ul class="list-group">
  83. <li class="list-group-item active">Albums</li>
  84. <li class='list-group-item'>Year<span class='badge'>160</span></li>
  85. <li class='list-group-item'>Month<span class='badge'>11</span></li>
  86. </li>
  87. </ul>
  88. </div>
  89. <div class="col-sm-6">
  90. <div id="key">
  91. </div>
  92. </div>
  93. </div>
  94. </div>
  95. <div class="col-md-8">
  96. <div class="row">
  97. <div class="col-sm-6">
  98. <div class="music-types">
  99. <canvas id="typechart" width="300" height="300"></canvas>
  100. </div>
  101. </div>
  102. <div class="col-sm-6">
  103. <div class="music-typed">
  104. <canvas id="artchart" width="300" height="300"></canvas>
  105. </div>
  106. </div>
  107. </div>
  108. </div>
  109. </div>
  110. <div class="row">
  111. <div class="col-sm-12">
  112. <div id="music-notes">
  113. <p>&nbsp;</p>
  114. </div>
  115. </div>
  116. </div>
  117. <div class="row">
  118. <div class="col-sm-12">
  119. <div id="music-notes">
  120. <p>&nbsp;</p>
  121. </div>
  122. </div>
  123. </div>
  124. <div class="row">
  125. <div class="col-sm-12">
  126. <div id="linechart"></div>
  127. </div>
  128. </div>
  129. <div class="row">
  130. <div class="col-sm-12">
  131. </div>
  132. </div>
  133. <?php class NowPlaying{
  134. private $url;
  135. private $noTrackPlayingMessage;
  136. function __construct($user, $api_key){
  137. $this->url = 'http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&limit=1';
  138. $this->url .= '&user=' . $user . '&api_key=' . $api_key;
  139. $this->noTrackPlayingMessage = 'All Quiet - Silence is Golden';
  140. }
  141. public function getNowPlaying(){
  142. $xml = simplexml_load_file($this->url);
  143. $track = $xml->recenttracks->track;
  144. $nowplaying = $track->attributes()->nowplaying;
  145. if($nowplaying){
  146. $artist = $track->artist;
  147. $songname = $track->name;
  148. $albumname = $track->album;
  149. $albumart = $track->album->image[2];
  150. return '<img src="../../wp-content/themes/dw/img/eq.gif"> ' . ' ' . $artist . ' - ' . $songname;
  151. }
  152. else{
  153. return $this->noTrackPlayingMessage;
  154. }
  155. }
  156. public function setNoTrackPlayingMessage($messageIn){
  157. $this->noTrackPlayingMessage = $messageIn;
  158. }
  159. }
  160. $nowPlaying = new NowPlaying('windhamdavid', 'e12ea1d0253898ee9a93edfe42ffdeab');
  161. ?>
  162. <div class="row">
  163. <div class="col-sm-12">
  164. <h5 class="cm-type"><em>Currently Playing</em></h5>
  165. <ul class="list-group">
  166. <li class="list-group-item"><h5 style="margin:0;"><?php echo $nowPlaying->getNowPlaying(); ?></h5></li>
  167. </ul>
  168. <h5 class="cm-type"><em>Recently Played</em></h5>
  169. <ul class="list-group">
  170. <div class="recent"></div>
  171. </ul>
  172. </div>
  173. </div>
  174. <div class="row">
  175. <div class="col-sm-4">
  176. <h5 class="cm-type"><em>Artists: 7 Days</em></h5>
  177. <ul class="list-group">
  178. <div class="wartists"></div>
  179. </ul>
  180. </div>
  181. <div class="col-sm-8">
  182. <h5 class="cm-type"><em>Tracks: 7 Days</em></h5>
  183. <ul class="list-group">
  184. <div class="wtracks"></div>
  185. </ul>
  186. </div>
  187. </div>
  188. <div class="row">
  189. <div class="col-sm-4">
  190. <h5 class="cm-type"><em>Artists: 3 Month</em></h5>
  191. <ul class="list-group">
  192. <div class="martists"></div>
  193. </ul>
  194. </div>
  195. <div class="col-sm-8">
  196. <h5 class="cm-type"><em>Tracks: 3 Month</em></h5>
  197. <ul class="list-group">
  198. <div class="mtracks"></div>
  199. </ul>
  200. </div>
  201. </div>
  202. <div class="row">
  203. <div class="col-sm-4">
  204. <h5 class="cm-type"><em>Artists: 6 Months</em></h5>
  205. <ul class="list-group">
  206. <div class="artists"></div>
  207. </ul>
  208. </div>
  209. <div class="col-sm-8">
  210. <h5 class="cm-type"><em>Tracks: 6 Months</em></h5>
  211. <ul class="list-group">
  212. <div class="tracks"></div>
  213. </ul>
  214. </div>
  215. </div>
  216. <h5 class="cm-type"><em>Top 200 Albums From the Last Year</em></h5>
  217. <div class="albums"></div>
  218. </div>
  219. </div>
  220. <?php endwhile; ?>
  221. </article>
  222. </div>
  223. <?php get_footer(); ?>