Move from miccall theme to kaze
This commit is contained in:
215
aplayer/demo/demo.js
Normal file
215
aplayer/demo/demo.js
Normal file
@@ -0,0 +1,215 @@
|
||||
const ap1 = new APlayer({
|
||||
element: document.getElementById('player1'),
|
||||
mini: false,
|
||||
autoplay: false,
|
||||
lrcType: false,
|
||||
mutex: true,
|
||||
preload: 'metadata',
|
||||
audio: [{
|
||||
name: '光るなら',
|
||||
artist: 'Goose house',
|
||||
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.mp3',
|
||||
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.jpg',
|
||||
theme: '#ebd0c2'
|
||||
}]
|
||||
});
|
||||
ap1.on('play', function () {
|
||||
console.log('play');
|
||||
});
|
||||
ap1.on('play', function () {
|
||||
console.log('play play');
|
||||
});
|
||||
ap1.on('pause', function () {
|
||||
console.log('pause');
|
||||
});
|
||||
ap1.on('canplay', function () {
|
||||
console.log('canplay');
|
||||
});
|
||||
ap1.on('playing', function () {
|
||||
console.log('playing');
|
||||
});
|
||||
ap1.on('ended', function () {
|
||||
console.log('ended');
|
||||
});
|
||||
ap1.on('error', function () {
|
||||
console.log('error');
|
||||
});
|
||||
|
||||
const ap2 = new APlayer({
|
||||
element: document.getElementById('player2'),
|
||||
mini: true,
|
||||
autoplay: false,
|
||||
lrcType: false,
|
||||
mutex: true,
|
||||
audio: [{
|
||||
name: '光るなら',
|
||||
artist: 'Goose house',
|
||||
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.mp3',
|
||||
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.jpg',
|
||||
lrc: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.lrc',
|
||||
theme: '#ebd0c2'
|
||||
}]
|
||||
});
|
||||
|
||||
const ap3 = new APlayer({
|
||||
element: document.getElementById('player3'),
|
||||
mini: false,
|
||||
autoplay: false,
|
||||
lrcType: 3,
|
||||
mutex: true,
|
||||
audio: [{
|
||||
name: '光るなら',
|
||||
artist: 'Goose house',
|
||||
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.mp3',
|
||||
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.jpg',
|
||||
lrc: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.lrc',
|
||||
theme: '#ebd0c2'
|
||||
}]
|
||||
});
|
||||
|
||||
const ap4 = new APlayer({
|
||||
element: document.getElementById('player4'),
|
||||
mini: false,
|
||||
autoplay: false,
|
||||
lrcType: false,
|
||||
mutex: true,
|
||||
theme: '#ad7a86',
|
||||
order: 'random',
|
||||
audio: [{
|
||||
name: '光るなら',
|
||||
artist: 'Goose house',
|
||||
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.mp3',
|
||||
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.jpg',
|
||||
lrc: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.lrc',
|
||||
theme: '#ebd0c2'
|
||||
}, {
|
||||
name: 'トリカゴ',
|
||||
artist: 'XX:me',
|
||||
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/darling.mp3',
|
||||
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/darling.jpg',
|
||||
lrc: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/darling.lrc',
|
||||
theme: '#46718b'
|
||||
}, {
|
||||
name: '前前前世',
|
||||
artist: 'RADWIMPS',
|
||||
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/yourname.mp3',
|
||||
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/yourname.jpg',
|
||||
lrc: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/yourname.lrc',
|
||||
theme: '#505d6b'
|
||||
}, {
|
||||
name: '光るなら(HLS)',
|
||||
artist: 'Goose house',
|
||||
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hls/hikarunara.m3u8',
|
||||
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.jpg',
|
||||
theme: '#ebd0c2',
|
||||
type: 'hls'
|
||||
}]
|
||||
});
|
||||
|
||||
const ap5 = new APlayer({
|
||||
element: document.getElementById('player5'),
|
||||
mini: false,
|
||||
autoplay: false,
|
||||
lrcType: 3,
|
||||
mutex: true,
|
||||
theme: '#e9e9e9',
|
||||
listFolded: false,
|
||||
listMaxHeight: 80,
|
||||
audio: [{
|
||||
name: '光るなら',
|
||||
artist: 'Goose house',
|
||||
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.mp3',
|
||||
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.jpg',
|
||||
lrc: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.lrc',
|
||||
}, {
|
||||
name: 'トリカゴ',
|
||||
artist: 'XX:me',
|
||||
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/darling.mp3',
|
||||
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/darling.jpg',
|
||||
lrc: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/darling.lrc',
|
||||
}, {
|
||||
name: '前前前世',
|
||||
artist: 'RADWIMPS',
|
||||
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/yourname.mp3',
|
||||
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/yourname.jpg',
|
||||
lrc: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/yourname.lrc',
|
||||
}]
|
||||
});
|
||||
const colorThief = new ColorThief();
|
||||
const image = new Image();
|
||||
const xhr = new XMLHttpRequest();
|
||||
const setTheme = (index) => {
|
||||
if (!ap5.list.audios[index].theme) {
|
||||
xhr.onload = function(){
|
||||
let coverUrl = URL.createObjectURL(this.response);
|
||||
image.onload = function(){
|
||||
let color = colorThief.getColor(image);
|
||||
ap5.theme(`rgb(${color[0]}, ${color[1]}, ${color[2]})`, index);
|
||||
URL.revokeObjectURL(coverUrl)
|
||||
};
|
||||
image.src = coverUrl;
|
||||
}
|
||||
xhr.open('GET', ap5.list.audios[index].cover, true);
|
||||
xhr.responseType = 'blob';
|
||||
xhr.send();
|
||||
}
|
||||
};
|
||||
setTheme(ap5.list.index);
|
||||
ap5.on('listswitch', (data) => {
|
||||
setTheme(data.index);
|
||||
});
|
||||
|
||||
const ap6 = new APlayer({
|
||||
element: document.getElementById('player6'),
|
||||
mutex: true,
|
||||
audio: [{
|
||||
name: '光るなら(HLS)',
|
||||
artist: 'Goose house',
|
||||
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hls/hikarunara.m3u8',
|
||||
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.jpg',
|
||||
theme: '#ebd0c2',
|
||||
type: 'hls'
|
||||
}]
|
||||
});
|
||||
const ap7 = new APlayer({
|
||||
element: document.getElementById('player7'),
|
||||
mutex: true,
|
||||
audio: [{
|
||||
name: '光るなら(HLS)',
|
||||
artist: 'Goose house',
|
||||
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hls/hikarunara.m3u8',
|
||||
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.jpg',
|
||||
theme: '#ebd0c2',
|
||||
type: 'customHls',
|
||||
}],
|
||||
customAudioType: {
|
||||
'customHls': function (audioElement, audio, player) {
|
||||
if (Hls.isSupported()) {
|
||||
const hls = new Hls();
|
||||
hls.loadSource(audio.url);
|
||||
hls.attachMedia(audioElement);
|
||||
}
|
||||
else if (audioElement.canPlayType('application/x-mpegURL') || audioElement.canPlayType('application/vnd.apple.mpegURL')) {
|
||||
audioElement.src = audio.url;
|
||||
}
|
||||
else {
|
||||
player.notice('Error: HLS is not supported.');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const ap8 = new APlayer({
|
||||
element: document.getElementById('player8'),
|
||||
mutex: true,
|
||||
theme: '#ad7a86',
|
||||
order: 'random',
|
||||
lrcType: 3,
|
||||
fixed: true,
|
||||
});
|
||||
$.ajax({
|
||||
url: 'https://api.i-meto.com/meting/api?server=netease&type=playlist&id=35798529',
|
||||
success: function (list) {
|
||||
ap8.list.add(JSON.parse(list));
|
||||
}
|
||||
});
|
||||
110
aplayer/demo/index.html
Normal file
110
aplayer/demo/index.html
Normal file
@@ -0,0 +1,110 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="Refresh" content="0; URL=https://aplayer.js.org/#/zh-Hans/" />
|
||||
<title>APlayer Demo</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
||||
}
|
||||
.container {
|
||||
max-width: 32rem;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
margin-bottom: 150px;
|
||||
}
|
||||
h1 {
|
||||
font-size: 54px;
|
||||
color: #333;
|
||||
margin: 30px 0 10px;
|
||||
}
|
||||
h2 {
|
||||
font-size: 22px;
|
||||
color: #555;
|
||||
}
|
||||
h3 {
|
||||
font-size: 24px;
|
||||
color: #555;
|
||||
}
|
||||
hr {
|
||||
display: block;
|
||||
width: 7rem;
|
||||
height: 1px;
|
||||
margin: 2.5rem 0;
|
||||
background-color: #eee;
|
||||
border: 0;
|
||||
}
|
||||
a {
|
||||
color: #08c;
|
||||
text-decoration: none;
|
||||
}
|
||||
p {
|
||||
font-size: 18px;
|
||||
}
|
||||
</style>
|
||||
<script src="https://cdn.jsdelivr.net/npm/vconsole/dist/vconsole.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/hls.js/dist/hls.min.js"></script>
|
||||
<script src="APlayer.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/color-thief-don@2.0.2/src/color-thief.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>APlayer</h1>
|
||||
<h2>Wow, such a beautiful html5 music player</h2>
|
||||
<p>Made by <a href="https://www.anotherhome.net/" target="_blank">DIYgod</a>. Available on <a href="https://github.com/DIYgod/APlayer" target="_blank">GitHub</a>. Licensed MIT.</p>
|
||||
<hr>
|
||||
<h3>Normal</h3>
|
||||
<div id="player1"></div>
|
||||
<p></p>
|
||||
<button onclick="ap1.play()">ap.play()</button>
|
||||
<button onclick="ap1.seek(100)">ap.seek(100)</button>
|
||||
<button onclick="ap1.pause()">ap.pause()</button>
|
||||
<button onclick="ap1.toggle()">ap.toggle()</button>
|
||||
<button onclick="ap1.volume(0.1)">ap.volume(0.1)</button>
|
||||
<button onclick="ap1.addAudio([
|
||||
{
|
||||
name: 'あっちゅ~ま青春!',
|
||||
artist: '七森中☆ごらく部',
|
||||
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/yuruyuri.mp3',
|
||||
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/yuruyuri.jpg'
|
||||
},
|
||||
{
|
||||
name: 'secret base~君がくれたもの~',
|
||||
artist: '茅野愛衣',
|
||||
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/secretbase.mp3',
|
||||
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/secretbase.jpg'
|
||||
},
|
||||
{
|
||||
name: '回レ!雪月花',
|
||||
artist: '小倉唯',
|
||||
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/snowmoonflowers.mp3',
|
||||
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/snowmoonflowers.jpg'
|
||||
}
|
||||
])">ap.addAudio(...)</button>
|
||||
<button onclick="ap1.destroy()">ap.destroy()</button>
|
||||
<h3>With playlist</h3>
|
||||
<div id="player4" class="aplayer"></div>
|
||||
<p></p>
|
||||
<button onclick="ap4.switchAudio(2)">ap.switchAudio(2)</button>
|
||||
<h3>With lyrics</h3>
|
||||
<div id="player3" class="aplayer"></div>
|
||||
<h3>With playlist and lyrics</h3>
|
||||
<div id="player5" class="aplayer"></div>
|
||||
<h3>Narrow</h3>
|
||||
<div id="player2" class="aplayer"></div>
|
||||
<h3>HLS</h3>
|
||||
<div id="player6" class="aplayer"></div>
|
||||
<div id="player7" class="aplayer"></div>
|
||||
<div id="player8" class="aplayer"></div>
|
||||
</div>
|
||||
<script>
|
||||
if (/mobile/i.test(window.navigator.userAgent)) {
|
||||
new VConsole();
|
||||
}
|
||||
</script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/jquery"></script>
|
||||
<script src="demo.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user