mirror of
https://github.com/AzuraCast/AzuraCast.git
synced 2024-06-15 05:36:37 +00:00
237 lines
6.8 KiB
PHTML
237 lines
6.8 KiB
PHTML
<?php
|
|
$stations = \Entity\Station::fetchArray();
|
|
?>
|
|
<div class="navbar navbar-inverse navbar-fixed-top">
|
|
<div class="navbar-inner">
|
|
<div class="container">
|
|
<a class="brand" style="padding: 5px 5px 5px 25px" href="<?=\DF\Url::route() ?>"><img src="<?=\DF\Url::content('pvl_dark.png') ?>" alt="Ponyville Live!"></a>
|
|
<ul class="nav">
|
|
<? foreach($stations as $station): ?>
|
|
<li class="header_station"><a href="#" id="header_station_<?=\Entity\Station::getStationShortName($station['name']) ?>" data-id="<?=$station['id'] ?>" data-type="<?=$station['type'] ?>" data-stream="<?=$station['stream_url'] ?>">
|
|
<img src="<?=\DF\Url::content($station['image_url']) ?>" style="width: 35px; height: 35px; border: 1px solid #163D63;">
|
|
<span class="max-width-only" style="margin-left: 5px;">
|
|
<?=str_replace(' Radio', '', $station['name']) ?>
|
|
</span>
|
|
</a></li>
|
|
<? endforeach; ?>
|
|
</ul>
|
|
<ul class="nav pull-right">
|
|
<li id="nowplaying-area">
|
|
<a href="#" id="btn_radio" class="clearfix">
|
|
<img id="nowplaying-image" src="<?=\DF\Url::content('stations/generic.png') ?>" style="width: 35px; height: 35px; border: 1px solid #163D63; float: left;">
|
|
<div id="nowplaying-icon">
|
|
<i class="current-status icon-music"></i>
|
|
</div>
|
|
<div id="nowplaying-wrapper">
|
|
<div id="nowplaying-artist">Select a Station</div>
|
|
<div id="nowplaying-title">to Tune In Live</div>
|
|
</div>
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script type="text/javascript">
|
|
var soundObject;
|
|
var volume = 50;
|
|
var nowplaying_id;
|
|
var generic_image = '<?=\DF\Url::content('stations/generic.png') ?>';
|
|
|
|
$(function() {
|
|
soundManager.setup({
|
|
url: '<?=\DF\Url::content('soundmanager/swf/') ?>',
|
|
onready: function() {
|
|
// Check for previously playing song and play it.
|
|
var nowplaying_cookie = getCookie('nowplaying_id');
|
|
if (nowplaying_cookie)
|
|
playStation(nowplaying_cookie);
|
|
}
|
|
});
|
|
|
|
$('#btn-tunein').click(function(e) {
|
|
var href = $(this).attr('href');
|
|
window.open(href, "pvlplayer", "width=300,height=600,menubar=0,toolbar=0,location=0,status=1");
|
|
|
|
e.preventDefault();
|
|
return false;
|
|
});
|
|
|
|
$('.nowplaying-status').hide();
|
|
$('.header_station a').click(function(e) {
|
|
e.preventDefault();
|
|
playStation($(this).attr('id'));
|
|
});
|
|
$('.station').click(function(e) {
|
|
e.preventDefault();
|
|
playStation('header_'+$(this).attr('id'));
|
|
});
|
|
$('#btn_radio').click(function(e) {
|
|
e.preventDefault();
|
|
stopAllPlayers();
|
|
});
|
|
|
|
checkNowPlaying();
|
|
});
|
|
|
|
$(window).bind("unload", function(){
|
|
document.cookie = "nowplaying_id="+nowplaying_id+"; expires=cookie_date.getTime+300; path=/";
|
|
});
|
|
|
|
function playStation(id)
|
|
{
|
|
var station = $('#'+id);
|
|
|
|
var stream_type = station.data('type');
|
|
var stream_url = station.data('stream');
|
|
var stream_id = station.data('id');
|
|
|
|
var currently_playing = (id == nowplaying_id);
|
|
|
|
if (currently_playing)
|
|
{
|
|
stopAllPlayers();
|
|
}
|
|
else
|
|
{
|
|
if (stream_url && stream_type)
|
|
{
|
|
stopAllPlayers();
|
|
|
|
if (stream_type == "shoutcast2" || stream_type == "shoutcast1")
|
|
{
|
|
soundObject = soundManager.createSound({
|
|
id:'pvlradio',
|
|
url: stream_url
|
|
});
|
|
soundObject.play({'volume': volume});
|
|
|
|
/*
|
|
var image = station.find('img').attr('src');
|
|
|
|
$('#jwplayer_outer').show();
|
|
jwplayer('jwplayer').setup({
|
|
'image': station.find('img').attr('src'),
|
|
'file': stream_url,
|
|
'type': 'mp3',
|
|
'source': 'sound',
|
|
'primary': 'flash',
|
|
'autostart': 'true',
|
|
'width': '100%',
|
|
'height': '150'
|
|
}).setVolume(volume).onError(function() {
|
|
setTimeout(function() {
|
|
stopAllPlayers();
|
|
playStation(id);
|
|
}, 5000);
|
|
});
|
|
*/
|
|
}
|
|
else if (stream_type == "video")
|
|
{
|
|
|
|
}
|
|
|
|
$('#nowplaying-area').addClass('active');
|
|
$('#nowplaying-icon i').removeClass('icon-music icon-pause').addClass('icon-pause');
|
|
$('#nowplaying-title').text('Now Playing...');
|
|
$('#nowplaying-artist').text(station.find('span').text());
|
|
|
|
station.closest('li').addClass('active');
|
|
|
|
var station_image = station.find('img').attr('src');
|
|
$('#nowplaying-image').attr('src', station_image);
|
|
|
|
nowplaying_id = id;
|
|
}
|
|
else
|
|
{
|
|
$('#player').text('Error: This stream is not currently active. Please select another stream to continue.');
|
|
}
|
|
}
|
|
}
|
|
|
|
function checkNowPlaying()
|
|
{
|
|
jQuery.ajax({
|
|
url: '<?=\DF\Url::route(array('module' => 'default', 'controller' => 'index', 'action' => 'nowplaying', 'v' => '2')) ?>',
|
|
dataType: 'json'
|
|
}).done(function(data) {
|
|
for (var station_id in data)
|
|
{
|
|
var station_info = data[station_id];
|
|
|
|
var header_station = 'header_station_'+station_id;
|
|
var is_playing = (header_station == nowplaying_id);
|
|
|
|
var station = $('#station_'+station_id);
|
|
|
|
if (!station_info.title)
|
|
{
|
|
var nowplaying_artist = station_info.text;
|
|
var nowplaying_title = '';
|
|
}
|
|
else
|
|
{
|
|
var nowplaying_artist = station_info.title;
|
|
var nowplaying_title = station_info.artist;
|
|
}
|
|
|
|
station.find('.nowplaying-artist').text(nowplaying_artist);
|
|
station.find('.nowplaying-title').text(nowplaying_title);
|
|
|
|
if (is_playing)
|
|
{
|
|
$('#nowplaying-artist').text(nowplaying_artist);
|
|
$('#nowplaying-title').text(nowplaying_title);
|
|
}
|
|
|
|
if (station_info.listeners)
|
|
station.find('.nowplaying-listeners').text(station_info.listeners+' Tuned In');
|
|
else
|
|
station.find('.nowplaying-listeners').hide();
|
|
}
|
|
|
|
setTimeout('checkNowPlaying()', 10000);
|
|
});
|
|
}
|
|
|
|
function stopAllPlayers()
|
|
{
|
|
$('#nowplaying-area').removeClass('active');
|
|
$('#nowplaying-icon i').removeClass('icon-music icon-pause').addClass('icon-music');
|
|
$('#nowplaying-image').attr('src', generic_image);
|
|
$('#nowplaying-artist').text('Select a Station');
|
|
$('#nowplaying-title').text('to Tune In Live');
|
|
|
|
$('.header_station').removeClass('active');
|
|
nowplaying_id = null;
|
|
|
|
soundManager.destroySound('pvlradio');
|
|
|
|
/*
|
|
jwplayer('jwplayer').stop();
|
|
$('#jwplayer_outer').hide();
|
|
|
|
$('i.current-status').removeClass('icon-stop icon-play').addClass('icon-play');
|
|
$('.nowplaying-status').hide();
|
|
$('.station').removeClass('playing');
|
|
*/
|
|
}
|
|
|
|
function getCookie(c_name)
|
|
{
|
|
var i,x,y,ARRcookies=document.cookie.split(";");
|
|
for (i=0;i<ARRcookies.length;i++)
|
|
{
|
|
x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
|
|
y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
|
|
x=x.replace(/^\s+|\s+$/g,"");
|
|
if (x==c_name)
|
|
{
|
|
return unescape(y);
|
|
}
|
|
}
|
|
}
|
|
</script>
|