146 lines
4.6 KiB
HTML
146 lines
4.6 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
|
<title>来点Music~</title>
|
|
<link rel="stylesheet" href="/layui/css/layui.css">
|
|
</head>
|
|
<link href="/css/video-js.min.css" rel="stylesheet">
|
|
<body>
|
|
<div class="layui-layout layui-layout-admin">
|
|
<div id="header"></div>
|
|
<div class="layui-body" style="left: 200px;">
|
|
<div id="side"></div>
|
|
|
|
<div style="margin-left: 2%; margin-top: 2%;">
|
|
<div>
|
|
<img src="/assets/defaultPlayImg.jpg" id="img" style="height: 200px; width: 200px"/>
|
|
|
|
<div style="display:inline-block;">
|
|
<div id="title">title</div>
|
|
<div id="artist">by</div>
|
|
<div id="album">album</div>
|
|
<div id="composer">composer</div>
|
|
</div>
|
|
|
|
<div id="audioWrap"></div>
|
|
|
|
</div>
|
|
<table id="playlist" lay-filter="music" ></table>
|
|
</div>
|
|
|
|
<div id="footer"></div>
|
|
</div>
|
|
</div>
|
|
<script src="/layui/layui.js"></script>
|
|
<script src="/js/jquery-3.2.1.js"></script>
|
|
<script src="/js/video.min.js"></script>
|
|
<script src="/js/myjs.js"></script>
|
|
<link rel="stylesheet" href="/css/AudioPlayer.css">
|
|
<script src="/js/AudioPlayer.js"></script>
|
|
<script>
|
|
//let localhost="http://192.168.31.88:8000";
|
|
let localhost="";
|
|
layui.use('table', function () {
|
|
let table = layui.table;
|
|
table.render({
|
|
elem: '#playlist'
|
|
, height: 312
|
|
, url: localhost+'/nas/music/all.do' //数据接口
|
|
, page: true //开启分页
|
|
, cols: [[
|
|
{field: 'title', title: '标题', width: 400}
|
|
, {field: 'artist', title: '艺术家', width: 200}
|
|
, {field: 'album', title: '专辑', width: 200}
|
|
, {field: 'composer', title: '作曲', width: 200}
|
|
, {field: 'track', title: '音轨号', width: 100}
|
|
]]
|
|
})
|
|
table.on('rowDouble(music)', function(obj){
|
|
//obj 同上
|
|
console.log(obj.data.file) //得到当前行元素对象
|
|
play(obj.data.file)
|
|
});
|
|
});
|
|
$.get("/login/check.do", function (data) {
|
|
let json = JSON.parse(data);
|
|
if (json.code !== 0) {
|
|
window.location.href = "/"
|
|
}
|
|
})
|
|
let player = $.AudioPlayer;
|
|
player.init({
|
|
container: '#audioWrap'
|
|
, source: ''
|
|
, imagePath: '/assets/'
|
|
, debuggers: false
|
|
, allowSeek: true
|
|
, endedCallback: function () {
|
|
console.log('播放完成')
|
|
random()
|
|
},canplayCallback:function () {
|
|
console.log("点击播放")
|
|
}
|
|
});
|
|
$.ajax({cache: false})
|
|
$('#header').load("/html/header.html");
|
|
$('#footer').load("/html/footer.html");
|
|
$('#side').load("/html/body/nas/side.html");
|
|
$('#img').click(function () {
|
|
random()
|
|
});
|
|
|
|
function random() {
|
|
$.get(localhost+"/nas/music/random.do", function (data) {
|
|
let json = JSON.parse(data)
|
|
if (json.code === 1) {
|
|
player.updateSource({
|
|
source: localhost+"/nas/music/play.do?random=false&filePath=" + json.data
|
|
});
|
|
update(json.data)
|
|
player.play()
|
|
|
|
} else {
|
|
layer.msg(json.msg)
|
|
}
|
|
})
|
|
}
|
|
function play(file) {
|
|
let filePath=escape(new Base64().encode(file))
|
|
player.updateSource({
|
|
source:localhost+"/nas/music/play.do?random=false&filePath=" +filePath
|
|
});
|
|
update(filePath)
|
|
player.play()
|
|
}
|
|
function update(fileName) {
|
|
$.get(localhost+'/nas/music/find/file.do?path=' + fileName, function (data) {
|
|
let json = JSON.parse(data);
|
|
if (json.code === 0) {
|
|
layer.msg(json.msg);
|
|
return
|
|
}
|
|
$('#title').html("标题:" + json.data.title)
|
|
$('#artist').html("艺术家:" + json.data.artist)
|
|
$('#album').html("专辑:" + json.data.album)
|
|
$('#composer').html("作曲:" + json.data.composer)
|
|
})
|
|
$.get(localhost+"/nas/music/image.do?fileName=" + fileName, function (data) {
|
|
let json = JSON.parse(data);
|
|
if (json.code === 0) {
|
|
layer.msg(json.msg);
|
|
return
|
|
}
|
|
$('#img').attr("src", "data:image/png;base64," + json.data)
|
|
})
|
|
}
|
|
|
|
</script>
|
|
<style>
|
|
|
|
</style>
|
|
</body>
|
|
|
|
</html> |