更新网页接口
更新接口
This commit is contained in:
@@ -65,10 +65,10 @@
|
||||
$.get("/nas/music/getlocalhost.do?token=PlVodzYhvxRQbOHKakpKs2dvnoc43Cnk", function (obj) {
|
||||
try {
|
||||
let json = JSON.parse(obj);
|
||||
localhost = json.data+":8000";
|
||||
console.log("音频地址:"+localhost)
|
||||
if(localhost==='http://null:8000'||localhost===":8000"){
|
||||
localhost="http://127.0.0.1"
|
||||
localhost = json.data + ":8000";
|
||||
console.log("音频地址:" + localhost)
|
||||
if (localhost === 'http://null:8000' || localhost === ":8000") {
|
||||
localhost = "http://127.0.0.1"
|
||||
}
|
||||
} catch (e) {
|
||||
localhost = ""
|
||||
@@ -80,23 +80,29 @@
|
||||
let listTable = table.render({
|
||||
elem: '#playlist'
|
||||
, url: localhost + '/nas/music/list.do?token=PlVodzYhvxRQbOHKakpKs2dvnoc43Cnk' //数据接口
|
||||
, method: 'post'
|
||||
, where: {
|
||||
path: 'root',
|
||||
type: false
|
||||
}
|
||||
, contentType: 'application/json'
|
||||
, page: true //开启分页
|
||||
, cols: [[
|
||||
{field: 'title', title: '标题', width: 400,sort:true, templet: "#listTemplet"}
|
||||
{field: 'title', title: '标题', width: 400, sort: true, templet: "#listTemplet"}
|
||||
, {field: 'artist', title: '艺术家', width: 200}
|
||||
, {field: 'album', title: '专辑', width: 200}
|
||||
, {field: 'composer', title: '作曲', width: 200}
|
||||
, {field: 'track', title: '音轨号', width: 100,sort:true}
|
||||
, {field: 'track', title: '音轨号', width: 100, sort: true}
|
||||
, {field: "right", width: 150, toolbar: '#music'}
|
||||
]]
|
||||
, done: function (res, curr, count) {
|
||||
musicLib = res.data
|
||||
$('#musicSize').html("歌单总数:"+res.size)
|
||||
$('#musicSize').html("歌单总数:" + res.size)
|
||||
}
|
||||
})
|
||||
table.on('rowDouble(music)', function (obj) {
|
||||
//obj 同上
|
||||
if (obj.data.isdir===1) {
|
||||
if (obj.data.isdir === 1) {
|
||||
listTable.reload({
|
||||
where: {
|
||||
path: obj.data.file
|
||||
@@ -116,16 +122,16 @@
|
||||
table.on('tool(music)', function (obj) {
|
||||
let data = obj.data;
|
||||
if (obj.event === 'download') {
|
||||
if (data.isdir===0) {
|
||||
if (data.isdir === 0) {
|
||||
window.open(localhost + "/nas/music/play.do?token=PlVodzYhvxRQbOHKakpKs2dvnoc43Cnk&random=false&filePath=" + new Base64().encode(data.file))
|
||||
}
|
||||
} else if (obj.event === 'play') {
|
||||
$.get(localhost + "/nas/music/list.do?token=PlVodzYhvxRQbOHKakpKs2dvnoc43Cnk&type=all&path=" + new Base64().encode(data.file), function (obj) {
|
||||
$.post(localhost + "/nas/music/list.do", {type: false, path: data.file}, function (obj) {
|
||||
let json = JSON.parse(obj);
|
||||
if(json.code===0){
|
||||
playIndex=0;
|
||||
musicLib=json.data;
|
||||
isRandom=false;
|
||||
if (json.code === 0) {
|
||||
playIndex = 0;
|
||||
musicLib = json.data;
|
||||
isRandom = false;
|
||||
playNext()
|
||||
}
|
||||
|
||||
@@ -142,7 +148,7 @@
|
||||
player.init({
|
||||
container: '#audioWrap'
|
||||
, source: ''
|
||||
, imagePath: '/assets/'
|
||||
, imagePath: '/assets'
|
||||
, debuggers: false
|
||||
, allowSeek: true
|
||||
, endedCallback: function () {
|
||||
@@ -168,25 +174,25 @@
|
||||
$('#download').click(function () {
|
||||
window.open(localhost + "/nas/music/play.do?token=PlVodzYhvxRQbOHKakpKs2dvnoc43Cnk&random=false&filePath=" + playNow)
|
||||
});
|
||||
$('#next').click(function (){
|
||||
$('#next').click(function () {
|
||||
playNext()
|
||||
});
|
||||
$('#reload').click(function (){
|
||||
$.get(localhost+"/nas/music/reload.do?token=PlVodzYhvxRQbOHKakpKs2dvnoc43Cnk",function (obj){
|
||||
$('#reload').click(function () {
|
||||
$.post(localhost + "/nas/music/reload.do", function (obj) {
|
||||
layer.msg("提交刷新请求成功,几分钟后生效")
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
function playNext() {
|
||||
if(isRandom){
|
||||
if (isRandom) {
|
||||
random()
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
if (playIndex === musicLib.length) {
|
||||
playIndex = 0;
|
||||
}
|
||||
if (musicLib[playIndex].isdir===1) {
|
||||
if (musicLib[playIndex].isdir === 1) {
|
||||
playIndex++
|
||||
playNext()
|
||||
} else {
|
||||
@@ -196,7 +202,7 @@
|
||||
}
|
||||
|
||||
function random() {
|
||||
$.get(localhost + "/nas/music/random.do?token=PlVodzYhvxRQbOHKakpKs2dvnoc43Cnk", function (data) {
|
||||
$.post(localhost + "/nas/music/random.do", function (data) {
|
||||
let json = JSON.parse(data)
|
||||
if (json.code === 0) {
|
||||
playNow = json.data
|
||||
@@ -223,36 +229,41 @@
|
||||
}
|
||||
|
||||
function update(fileName) {
|
||||
$.get(localhost + '/nas/music/find/file.do?token=PlVodzYhvxRQbOHKakpKs2dvnoc43Cnk&path=' + fileName, function (data) {
|
||||
let json = JSON.parse(data);
|
||||
if(isRandom){
|
||||
$('#playerNowList').html("播放列表: (全列表随机播放)")
|
||||
}else{
|
||||
$('#playerNowList').html("播放列表: (" + playIndex+"/"+musicLib.length+")")
|
||||
$.ajax({
|
||||
type: 'post'
|
||||
, url: localhost + '/nas/music/find/file.do'
|
||||
, contentType: "application/json"
|
||||
, data: JSON.stringify({"path": fileName})
|
||||
, success: function (data) {
|
||||
let json = JSON.parse(data);
|
||||
if (isRandom) {
|
||||
$('#playerNowList').html("播放列表: (全列表随机播放)")
|
||||
} else {
|
||||
$('#playerNowList').html("播放列表: (" + playIndex + "/" + musicLib.length + ")")
|
||||
}
|
||||
$('#title').html("标题:" + json.data.title)
|
||||
$('#artist').html("艺术家:" + json.data.artist)
|
||||
$('#album').html("专辑:" + json.data.album)
|
||||
$('#composer').html("作曲:" + json.data.composer)
|
||||
navigator.mediaSession.metadata = new MediaMetadata({
|
||||
title: json.data.title,
|
||||
artist: json.data.artist,
|
||||
album: json.data.album,
|
||||
artwork:[
|
||||
{
|
||||
src: localhost+'/nas/music/web/image.do?fileName='+fileName,
|
||||
type: 'image/png',
|
||||
sizes: '128x128'
|
||||
}
|
||||
]
|
||||
});
|
||||
navigator.mediaSession.setActionHandler('nexttrack', function () {
|
||||
// 用户点击了“下一首”媒体通知图标
|
||||
playNext();
|
||||
});
|
||||
}
|
||||
$('#title').html("标题:" + json.data.title)
|
||||
$('#artist').html("艺术家:" + json.data.artist)
|
||||
$('#album').html("专辑:" + json.data.album)
|
||||
$('#composer').html("作曲:" + json.data.composer)
|
||||
navigator.mediaSession.metadata=new MediaMetadata({
|
||||
title:json.data.title,
|
||||
artist:json.data.artist,
|
||||
album:json.data.album
|
||||
});
|
||||
navigator.mediaSession.setActionHandler('nexttrack', function () {
|
||||
// 用户点击了“下一首”媒体通知图标
|
||||
playNext();
|
||||
});
|
||||
});
|
||||
$.get(localhost + "/nas/music/image.do?token=PlVodzYhvxRQbOHKakpKs2dvnoc43Cnk&fileName=" + fileName, function (data) {
|
||||
let json = JSON.parse(data);
|
||||
$('#img').attr("src", "data:image/png;base64," + json.data),
|
||||
navigator.mediaSession.metadata.artwork=[{
|
||||
src:"data:image/png;base64," + json.data,
|
||||
type: 'image/png',
|
||||
sizes: '128x128'
|
||||
}]
|
||||
})
|
||||
$('#img').attr("src",'/nas/music/web/image.do?fileName='+fileName);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user