2022-05-22 04:02:03 +00:00
|
|
|
|
/*
|
|
|
|
|
音乐信息
|
2022-01-16 15:30:27 +00:00
|
|
|
|
|
2022-05-22 04:02:03 +00:00
|
|
|
|
感谢 @武恩赐 提供的 MetingAPI
|
|
|
|
|
https://api.wuenci.com/meting/api/
|
2022-01-22 02:56:58 +00:00
|
|
|
|
|
2022-05-22 04:02:03 +00:00
|
|
|
|
作者: imsyy
|
|
|
|
|
主页:https://www.imsyy.top/
|
|
|
|
|
GitHub:https://github.com/imsyy/home
|
|
|
|
|
版权所有,请勿删除
|
|
|
|
|
*/
|
|
|
|
|
var server = "netease"; //netease: 网易云音乐; tencent: QQ音乐; kugou: 酷狗音乐; xiami: 虾米; kuwo: 酷我
|
|
|
|
|
var type = "playlist"; //song: 单曲; playlist: 歌单; album: 唱片
|
2022-05-24 06:30:14 +00:00
|
|
|
|
var id = "7452421335"; //封面 ID / 单曲 ID / 歌单 ID
|
2022-01-16 15:30:27 +00:00
|
|
|
|
|
2022-05-22 04:02:03 +00:00
|
|
|
|
$.ajax({
|
2022-07-07 13:42:10 +00:00
|
|
|
|
url: "https://api.wuenci.com/meting/api/?server=" + server + "&type=" + type + "&id=" + id,
|
2022-05-22 04:02:03 +00:00
|
|
|
|
type: "GET",
|
|
|
|
|
dataType: "JSON",
|
2022-05-29 03:19:48 +00:00
|
|
|
|
success: function (data) {
|
2022-05-22 04:02:03 +00:00
|
|
|
|
const ap = new APlayer({
|
|
|
|
|
container: document.getElementById('aplayer'),
|
|
|
|
|
order: 'random',
|
|
|
|
|
preload: 'auto',
|
|
|
|
|
listMaxHeight: '336px',
|
|
|
|
|
volume: '0.5',
|
|
|
|
|
mutex: true,
|
|
|
|
|
lrcType: 3,
|
|
|
|
|
audio: data,
|
|
|
|
|
});
|
2022-01-16 15:30:27 +00:00
|
|
|
|
|
2022-05-22 04:02:03 +00:00
|
|
|
|
/* 底栏歌词 */
|
|
|
|
|
setInterval(function () {
|
2022-06-21 04:02:27 +00:00
|
|
|
|
$("#lrc").html("<span class='lrc-show'><svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='18' height='18'><path fill='none' d='M0 0h24v24H0z'/><path d='M12 13.535V3h8v3h-6v11a4 4 0 1 1-2-3.465z' fill='rgba(255,255,255,1)'/></svg> " + $(".aplayer-lrc-current").text() + " <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='18' height='18'><path fill='none' d='M0 0h24v24H0z'/><path d='M12 13.535V3h8v3h-6v11a4 4 0 1 1-2-3.465z' fill='rgba(255,255,255,1)'/></svg></span>");
|
2022-05-22 04:02:03 +00:00
|
|
|
|
}, 500);
|
|
|
|
|
|
|
|
|
|
/* 音乐通知及控制 */
|
|
|
|
|
ap.on('play', function () {
|
|
|
|
|
music = $(".aplayer-title").text() + $(".aplayer-author").text();
|
|
|
|
|
iziToast.info({
|
2022-05-24 06:30:14 +00:00
|
|
|
|
timeout: 4000,
|
2022-06-20 13:20:45 +00:00
|
|
|
|
icon: "fa-solid fa-circle-play",
|
2022-05-22 04:02:03 +00:00
|
|
|
|
displayMode: 'replace',
|
|
|
|
|
message: music
|
|
|
|
|
});
|
2022-05-24 06:30:14 +00:00
|
|
|
|
$("#play").html("<i class='fa-solid fa-pause'>");
|
2022-05-22 04:02:03 +00:00
|
|
|
|
$("#music-name").html($(".aplayer-title").text() + $(".aplayer-author").text());
|
|
|
|
|
if ($(document).width() >= 990) {
|
|
|
|
|
$('.power').css("cssText", "display:none");
|
|
|
|
|
$('#lrc').css("cssText", "display:block !important");
|
2022-05-29 03:19:48 +00:00
|
|
|
|
};
|
|
|
|
|
// Notification.requestPermission().then(res => {
|
|
|
|
|
// console.log(res)
|
|
|
|
|
// });
|
|
|
|
|
// new Notification('音乐通知', {
|
|
|
|
|
// body: '正在播放:' + music,
|
|
|
|
|
// tag: 1
|
|
|
|
|
// });
|
2022-05-22 04:02:03 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
ap.on('pause', function () {
|
2022-05-24 06:30:14 +00:00
|
|
|
|
$("#play").html("<i class='fa-solid fa-play'>");
|
2022-05-22 04:02:03 +00:00
|
|
|
|
if ($(document).width() >= 990) {
|
|
|
|
|
$('#lrc').css("cssText", "display:none !important");
|
|
|
|
|
$('.power').css("cssText", "display:block");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$("#music").hover(function () {
|
|
|
|
|
$('.music-text').css("display", "none");
|
|
|
|
|
$('.music-volume').css("display", "flex");
|
|
|
|
|
}, function () {
|
|
|
|
|
$('.music-text').css("display", "block");
|
|
|
|
|
$('.music-volume').css("display", "none");
|
|
|
|
|
})
|
2022-01-29 05:09:21 +00:00
|
|
|
|
|
2022-05-22 04:02:03 +00:00
|
|
|
|
/* 一言与音乐切换 */
|
|
|
|
|
$('#open-music').on('click', function () {
|
|
|
|
|
$('#hitokoto').css("display", "none");
|
|
|
|
|
$('#music').css("display", "flex");
|
|
|
|
|
});
|
2022-01-29 05:09:21 +00:00
|
|
|
|
|
2022-05-22 04:02:03 +00:00
|
|
|
|
$("#hitokoto").hover(function () {
|
|
|
|
|
$('#open-music').css("display", "flex");
|
|
|
|
|
}, function () {
|
|
|
|
|
$('#open-music').css("display", "none");
|
|
|
|
|
})
|
2022-01-16 15:30:27 +00:00
|
|
|
|
|
2022-05-22 04:02:03 +00:00
|
|
|
|
$('#music-close').on('click', function () {
|
|
|
|
|
$('#music').css("display", "none");
|
|
|
|
|
$('#hitokoto').css("display", "flex");
|
|
|
|
|
});
|
2022-01-16 15:30:27 +00:00
|
|
|
|
|
2022-05-22 04:02:03 +00:00
|
|
|
|
/* 上下曲 */
|
|
|
|
|
$('#play').on('click', function () {
|
|
|
|
|
ap.toggle();
|
|
|
|
|
$("#music-name").html($(".aplayer-title").text() + $(".aplayer-author").text());
|
|
|
|
|
});
|
2022-01-16 15:30:27 +00:00
|
|
|
|
|
2022-05-22 04:02:03 +00:00
|
|
|
|
$('#last').on('click', function () {
|
|
|
|
|
ap.skipBack();
|
2022-07-09 02:13:12 +00:00
|
|
|
|
ap.play();
|
2022-05-22 04:02:03 +00:00
|
|
|
|
$("#music-name").html($(".aplayer-title").text() + $(".aplayer-author").text());
|
|
|
|
|
});
|
2022-01-16 15:30:27 +00:00
|
|
|
|
|
2022-05-22 04:02:03 +00:00
|
|
|
|
$('#next').on('click', function () {
|
|
|
|
|
ap.skipForward();
|
2022-07-09 02:13:12 +00:00
|
|
|
|
ap.play();
|
2022-05-22 04:02:03 +00:00
|
|
|
|
$("#music-name").html($(".aplayer-title").text() + $(".aplayer-author").text());
|
|
|
|
|
});
|
2022-01-16 15:30:27 +00:00
|
|
|
|
|
2022-07-14 08:25:08 +00:00
|
|
|
|
window.onkeydown = function (e) {
|
|
|
|
|
if (e.keyCode == 32) {
|
|
|
|
|
ap.toggle();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-22 04:02:03 +00:00
|
|
|
|
/* 打开音乐列表 */
|
|
|
|
|
$('#music-open').on('click', function () {
|
|
|
|
|
if ($(document).width() >= 990) {
|
|
|
|
|
$('#box').css("display", "block");
|
|
|
|
|
$('#row').css("display", "none");
|
|
|
|
|
$('#more').css("cssText", "display:none !important");
|
|
|
|
|
}
|
|
|
|
|
});
|
2022-01-17 14:38:05 +00:00
|
|
|
|
|
2022-05-22 04:02:03 +00:00
|
|
|
|
//音量调节
|
2022-06-23 14:44:17 +00:00
|
|
|
|
$("#volume").on('click touchend', function () {
|
2022-05-22 04:02:03 +00:00
|
|
|
|
var x = $("#volume").val();
|
|
|
|
|
ap.volume(x, true);
|
|
|
|
|
if (x == 0) {
|
2022-05-24 06:30:14 +00:00
|
|
|
|
$("#volume-ico").html("<i class='fa-solid fa-volume-xmark'></i>");
|
2022-05-22 04:02:03 +00:00
|
|
|
|
} else if (x > 0 && x <= 0.3) {
|
2022-06-20 13:20:45 +00:00
|
|
|
|
$("#volume-ico").html("<i class='fa-solid fa-volume-off'></i>");
|
2022-05-22 04:02:03 +00:00
|
|
|
|
} else if (x > 0.3 && x <= 0.6) {
|
2022-06-20 13:20:45 +00:00
|
|
|
|
$("#volume-ico").html("<i class='fa-solid fa-volume-low'></i>");
|
2022-05-22 04:02:03 +00:00
|
|
|
|
} else {
|
2022-05-24 06:30:14 +00:00
|
|
|
|
$("#volume-ico").html("<i class='fa-solid fa-volume-high'></i>");
|
2022-05-22 04:02:03 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
error: function () {
|
|
|
|
|
setTimeout(function () {
|
|
|
|
|
iziToast.info({
|
2022-05-24 06:30:14 +00:00
|
|
|
|
timeout: 8000,
|
|
|
|
|
icon: "fa-solid fa-circle-exclamation",
|
2022-05-22 04:02:03 +00:00
|
|
|
|
displayMode: 'replace',
|
|
|
|
|
message: '音乐播放器加载失败'
|
|
|
|
|
});
|
|
|
|
|
}, 3800);
|
2022-01-16 15:30:27 +00:00
|
|
|
|
}
|
2022-07-14 08:25:08 +00:00
|
|
|
|
})
|