page-music.php 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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="<?php bloginfo('template_url'); ?>/img/none.svg" 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;">
  38. <img id="eq" src="" title="eq" style="float:left;margin:3px 10px 0 7px;">
  39. <span id="amplitude-now-playing-name">Playing: <span id="track">* Off Air *</span></span>
  40. </h6>
  41. </div>
  42. </div>
  43. </div>
  44. </div>
  45. </div>
  46. </div>
  47. <div class="divider"></div>
  48. <?php the_content(); ?>
  49. <div class="row">
  50. <div class="col-sm-12">
  51. <p>&nbsp;</p>
  52. </div>
  53. </div>
  54. <div class="row">
  55. <div class="col-sm-12">
  56. <h5 class="cm-type"><em></em></h5>
  57. <div class="timeline">
  58. <canvas id="timechart" width="900" height="400"></canvas>
  59. </div>
  60. </div>
  61. </div>
  62. <div class="row">
  63. <div class="col-sm-2">
  64. <h5 class="cm-type"><em></em></h5>
  65. </div>
  66. <div class="col-sm-2">
  67. <h5 class="cm-type"><em></em></h5>
  68. </div>
  69. <div class="col-sm-4">
  70. </div>
  71. <div class="col-sm-4">
  72. </div>
  73. </div>
  74. <div class="row">
  75. <div class="col-md-4">
  76. <div class="row">
  77. <div class="col-sm-6">
  78. <ul class="list-group">
  79. <li class="list-group-item active">Tracks</li>
  80. <li class='list-group-item'>Year<span class='badge'>7151</span></li>
  81. <li class='list-group-item'>Month<span class='badge'>687</span></li>
  82. <li class='list-group-item'>Day<span class='badge'>37</span></li>
  83. </li>
  84. </ul>
  85. <ul class="list-group">
  86. <li class="list-group-item active">Albums</li>
  87. <li class='list-group-item'>Year<span class='badge'>160</span></li>
  88. <li class='list-group-item'>Month<span class='badge'>11</span></li>
  89. </li>
  90. </ul>
  91. </div>
  92. <div class="col-sm-6">
  93. <div id="key">
  94. </div>
  95. </div>
  96. </div>
  97. </div>
  98. <div class="col-md-8">
  99. <div class="row">
  100. <div class="col-sm-6">
  101. <div class="music-types">
  102. <canvas id="typechart" width="300" height="300"></canvas>
  103. </div>
  104. </div>
  105. <div class="col-sm-6">
  106. <div class="music-typed">
  107. <canvas id="artchart" width="300" height="300"></canvas>
  108. </div>
  109. </div>
  110. </div>
  111. </div>
  112. </div>
  113. <div class="row">
  114. <div class="col-sm-12">
  115. <div id="music-notes">
  116. <p>&nbsp;</p>
  117. </div>
  118. </div>
  119. </div>
  120. <div class="row">
  121. <div class="col-sm-12">
  122. <div id="music-notes">
  123. <p>&nbsp;</p>
  124. </div>
  125. </div>
  126. </div>
  127. <div class="row">
  128. <div class="col-sm-12">
  129. <div id="linechart"></div>
  130. </div>
  131. </div>
  132. <div class="row">
  133. <div class="col-sm-12">
  134. </div>
  135. </div>
  136. <?php class NowPlaying{
  137. private $url;
  138. private $noTrackPlayingMessage;
  139. function __construct($user, $api_key){
  140. $this->url = 'http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&limit=1';
  141. $this->url .= '&user=' . $user . '&api_key=' . $api_key;
  142. $this->noTrackPlayingMessage = 'All Quiet - Silence is Golden';
  143. }
  144. public function getNowPlaying(){
  145. $xml = simplexml_load_file($this->url);
  146. $track = $xml->recenttracks->track;
  147. $nowplaying = $track->attributes()->nowplaying;
  148. if($nowplaying){
  149. $artist = $track->artist;
  150. $songname = $track->name;
  151. $albumname = $track->album;
  152. $albumart = $track->album->image[2];
  153. return '<img src="../../wp-content/themes/daw/img/eq.gif"> ' . ' ' . $artist . ' - ' . $songname;
  154. }
  155. else{
  156. return $this->noTrackPlayingMessage;
  157. }
  158. }
  159. public function setNoTrackPlayingMessage($messageIn){
  160. $this->noTrackPlayingMessage = $messageIn;
  161. }
  162. }
  163. $nowPlaying = new NowPlaying('windhamdavid', 'e12ea1d0253898ee9a93edfe42ffdeab');
  164. ?>
  165. <div class="row">
  166. <div class="col-sm-12">
  167. <h5 class="cm-type"><em>Currently Playing</em></h5>
  168. <ul class="list-group">
  169. <li class="list-group-item"><h5 style="margin:0;"><?php echo $nowPlaying->getNowPlaying(); ?></h5></li>
  170. </ul>
  171. <h5 class="cm-type"><em>Recently Played</em></h5>
  172. <ul class="list-group">
  173. <div class="recent"></div>
  174. </ul>
  175. </div>
  176. </div>
  177. <div class="row">
  178. <div class="col-sm-4">
  179. <h5 class="cm-type"><em>Artists: 7 Days</em></h5>
  180. <ul class="list-group">
  181. <div class="wartists"></div>
  182. </ul>
  183. </div>
  184. <div class="col-sm-8">
  185. <h5 class="cm-type"><em>Tracks: 7 Days</em></h5>
  186. <ul class="list-group">
  187. <div class="wtracks"></div>
  188. </ul>
  189. </div>
  190. </div>
  191. <div class="row">
  192. <div class="col-sm-4">
  193. <h5 class="cm-type"><em>Artists: 1 Month</em></h5>
  194. <ul class="list-group">
  195. <div class="martists"></div>
  196. </ul>
  197. </div>
  198. <div class="col-sm-8">
  199. <h5 class="cm-type"><em>Tracks: 1 Month</em></h5>
  200. <ul class="list-group">
  201. <div class="mtracks"></div>
  202. </ul>
  203. </div>
  204. </div>
  205. <div class="row">
  206. <div class="col-sm-4">
  207. <h5 class="cm-type"><em>Artists: 6 Months</em></h5>
  208. <ul class="list-group">
  209. <div class="artists"></div>
  210. </ul>
  211. </div>
  212. <div class="col-sm-8">
  213. <h5 class="cm-type"><em>Tracks: 6 Months</em></h5>
  214. <ul class="list-group">
  215. <div class="tracks"></div>
  216. </ul>
  217. </div>
  218. </div>
  219. <div class="row">
  220. <div class="col-sm-4">
  221. <h5 class="cm-type"><em>Artists: 1 Year</em></h5>
  222. <ul class="list-group">
  223. <div class="artists"></div>
  224. </ul>
  225. </div>
  226. <div class="col-sm-8">
  227. <h5 class="cm-type"><em>Tracks: 1 Year</em></h5>
  228. <ul class="list-group">
  229. <div class="tracks"></div>
  230. </ul>
  231. </div>
  232. </div>
  233. <h5 class="cm-type"><em>Top 200 Albums From the Last Year</em></h5>
  234. <div class="albums"></div>
  235. </div>
  236. </div>
  237. <?php endwhile; ?>
  238. </article>
  239. </div>
  240. <?php get_footer(); ?>