Some code improves, fixed bug with Tracknames without ID3 tags

master
santic-zombie 5 years ago
parent 1a5e774948
commit d35971887c
  1. 7
      css/style.css
  2. 4
      index.html
  3. 2
      js/audio.js
  4. 33
      js/radio.js
  5. 28
      js/radio.js.bak

@ -1,9 +1,11 @@
body {
background-color: rgb(62, 50, 64);
/*
background-image: url("/pic/bg.jpg");
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center center;
background-size: cover;
background-size: cover; */
}
.parent {
@ -11,12 +13,15 @@ body {
height: 100%;
position: fixed;
top: 0;
background: url(/pic/bg.jpg) no-repeat center center / cover;
left: 0;
display: flex;
align-items: center;
align-content: center;
justify-content: center;
overflow: auto;
}
#song{

@ -4,7 +4,7 @@
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css">
<link rel="stylesheet" type="text/css" href="/css/style1.css">
<link rel="stylesheet" type="text/css" href="/css/style.css">
<title>My Test Radio</title>
<script
src="https://code.jquery.com/jquery-3.4.1.js"
@ -47,7 +47,7 @@
<input id="volume" type="range" min="0" max="10" value="5" step="0.1" />
</div>
<span id="duration"></span>
<!-- <span id="duration"></span> -->
<br>
</div>
</div>

@ -14,6 +14,7 @@ pause.addEventListener('click', function() {
audio.pause();
}, false);
/*
audio.addEventListener("timeupdate", function() {
var duration = document.getElementById('duration');
var s = parseInt(audio.currentTime % 60);
@ -24,6 +25,7 @@ audio.addEventListener("timeupdate", function() {
if (h < 10) h = '0' + h;
duration.innerHTML = h + ':' + m + ':' + s;
}, false);
*/
$("#volume").mousemove(function(){
audio.volume = parseFloat(this.value / 10);

@ -1,3 +1,11 @@
var lastfm = new LastFM({
apiKey : '59ab8307ec00a5ec90574ac91885798e',
apiSecret : 'e09bec215fdc3100ff998167e5b401f8',
});
var MPDartist, MPDsong, MPDfile, MPDCurr;
MPDartist = MPDsong = MPDfile = MPDCurr = 'empty';
function show()
{
@ -17,8 +25,7 @@ function show()
xmlHttpRequest()
.then(function(temp){
var MPDartist, MPDsong, MPDfile;
MPDartist = MPDsong = MPDfile = 'empty';
// Получение информации из файла
var array = temp.toString().split("\n");
// вывод в консоль информации о файле
/*
@ -26,18 +33,20 @@ function show()
console.log(array[i]);} */
// .replace - удаление пробелов в начале и конце строки
MPDartist = array[0].replace(/^\s*/,'').replace(/\s*$/,'');
MPDartist = array[0];
MPDsong = array[1];
MPDfile = array[2].replace(/^vk_kun\//,'').replace(/\.mp3/,'');
//console.log(MPDartist);
if (MPDartist == '') {
$('#title').html(MPDfile);
} else {
if (MPDartist == '' && MPDCurr != MPDfile) {
MPDartist = MPDfile.replace(/\s-.*/,'').replace(/^\s*/,'').replace(/\s*$/,'');
MPDsong = MPDfile.replace(/^.*\s-/,'').replace(/^\s*/,'').replace(/\s*$/,'');
getLastFM_url(MPDartist, MPDsong);
} else if (MPDCurr != MPDfile) {
getLastFM_url(MPDartist, MPDsong);
}
MPDCurr = MPDfile;
});
}
$(document).ready(
@ -49,19 +58,13 @@ $(document).ready(
function getLastFM_url(FMartist, FMsong)
{
var lastfm = new LastFM({
apiKey : '59ab8307ec00a5ec90574ac91885798e',
apiSecret : 'e09bec215fdc3100ff998167e5b401f8',
});
lastfm.artist.getInfo({artist: FMartist}, {success: function(data){
var artistLink = data.artist.url;
console.log(data.artist.url);
// формируем ссылку на артиста в LastFM
document.querySelector('a[name="lastFMlink"]').setAttribute('href', artistLink);
document.querySelector('a[name="lastFMlink"]').setAttribute('href', data.artist.url);
// выводим название артиста и трека ссылкой
$('#title').html(FMartist+' - '+FMsong);
}, error: function(code, message){
console.log('Error #'+code+': '+message);}
});
console.log('WHAT??!')
}

@ -1,28 +0,0 @@
function show()
{
/*
// php-scrip exec mpc current command
$.ajax({
url: '../trackname.php',
cache: false,
success: function(data){
$('#title').html(data);
}
}); */
$.ajax({
url: '../online.php',
cache: false,
success: function(html){
$('#listeners').html(html);
}
});
}
$(document).ready(
() => {
show();
setInterval(show, 5000);
}
);
Loading…
Cancel
Save