-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const aplayer_path = "/aplayer/"; | ||
|
||
// 封装异步加载资源的方法 | ||
function loadExternalResource(url, type) { | ||
return new Promise((resolve, reject) => { | ||
let tag; | ||
|
||
if (type === "css") { | ||
tag = document.createElement("link"); | ||
tag.rel = "stylesheet"; | ||
tag.href = url; | ||
} | ||
else if (type === "js") { | ||
tag = document.createElement("script"); | ||
tag.src = url; | ||
} | ||
if (tag) { | ||
tag.onload = () => resolve(url); | ||
tag.onerror = () => reject(url); | ||
document.head.appendChild(tag); | ||
} | ||
}); | ||
} | ||
|
||
|
||
Promise.all([ | ||
loadExternalResource(aplayer_path + "APlayer.min.css", "css"), | ||
loadExternalResource(aplayer_path + "APlayer.min.js", "js"), | ||
loadExternalResource(aplayer_path + "list.js", "js") | ||
]) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const ap = new APlayer({ | ||
container: document.getElementById('aplayer'), | ||
fixed: true, | ||
autoplay: false, | ||
audio: [ | ||
{ | ||
name: '竹节虫', | ||
artist: 'unknow', | ||
url: '/music/warm.mp3' | ||
} | ||
] | ||
}); |