Skip to content

Commit

Permalink
Merge pull request #21 from gnehs/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
gnehs authored Aug 17, 2018
2 parents 75f4733 + a1f7aed commit 425daaf
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion js/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,6 @@ async function getAPI(CGI_PATH, API_NAME, METHOD, PARAMS_JSON = [], VERSION = 1)
"PARAMS": PARAMS
}
req_json = JSON.stringify(req_json)
const response = await axios.get('/api/' + ppEncode(req_json));
let response = await axios.get('/api/' + ppEncode(req_json));
return response.data
}
24 changes: 15 additions & 9 deletions js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ ap.on("play", async() => {
router.navigate('now');
showNow()
})
let nowPlaying = ap.list.audios[ap.list.index],
name, artist
if (nowPlaying) {
name = nowPlaying.name
artist = nowPlaying.artist
$(document).attr("title", `${name} - ${artist}`);
}
updateMediaSession()
})
ap.on("loadedmetadata", async() => {
Expand All @@ -63,6 +70,7 @@ ap.on("loadedmetadata", async() => {
id = nowPlaying.id,
artist = nowPlaying.artist,
lyricRegex = /\[([0-9.:]*)\]/i
$(document).attr("title", `${name} - ${artist}`);

let lrcResult = await getLrcByID(id),
lrcs = lrcResult.lyrics
Expand All @@ -84,20 +92,18 @@ ap.on("loadedmetadata", async() => {
}
})
ap.on("timeupdate", () => {
let name = ap.list.audios[ap.list.index].name || ""
let artist = ap.list.audios[ap.list.index].artist || ""

let img = window.localStorage["imgRes"] != "true" ? ap.list.audios[ap.list.index].cover : getBackground() //一定會有圖片
let name = ap.list.audios[ap.list.index].name || "",
artist = ap.list.audios[ap.list.index].artist || "",
img = window.localStorage["imgRes"] != "true" ? ap.list.audios[ap.list.index].cover : getBackground() //一定會有圖片
$('#player button.play[onclick="ap.toggle()"] i').text("pause")
if (name != $('#player .song-info .name').text()) { //歌名有變才更新
$('#player .song-info .name').text(name)
$('#player .song-info .artist').text(artist)
$('#player img').attr('src', img)
}
$('#player .song-info .name').text(name)
$('#player .song-info .artist').text(artist)
$('#player img').attr('src', img)
updateMediaSession()
})
ap.on("pause", () => {
$('#player button.play[onclick="ap.toggle()"] i').text("play_arrow")
$(document).attr("title", `Pokaplayer`);
})

function updateMediaSession() {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pokaplayer",
"version": "0.6.10",
"version": "0.6.11",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion views/index.pug
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ html
script(src='//cdnjs.cloudflare.com/ajax/libs/aplayer/1.10.1/APlayer.min.js')
script(src='//cdnjs.cloudflare.com/ajax/libs/axios/0.18.0/axios.min.js')
script(src='//cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js')
script(src='//cdnjs.cloudflare.com/ajax/libs/socket.io/2.1.1/socket.io.js')
script(src='//cdn.jsdelivr.net/npm/navigo@7.1.2/lib/navigo.min.js')
script(src='/socket.io/socket.io.js')
script(src='/js/lyrics.min.js')
script(src='/js/base64.js')
script(src='/js/template.js')
Expand Down

0 comments on commit 425daaf

Please sign in to comment.