Skip to content

Commit bdb5daf

Browse files
committed
narrow style; new demo page
1 parent d18f24b commit bdb5daf

4 files changed

Lines changed: 83 additions & 6 deletions

File tree

APlayer.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@
6565
content: '\e802';
6666
}
6767

68+
.aplayer-narrow {
69+
width: 66px;
70+
}
71+
72+
.aplayer-narrow .aplayer-info {
73+
display: none;
74+
}
75+
6876
.aplayer {
6977
font-family: Arial, Helvetica, sans-serif;
7078
margin: 5px;

APlayer.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ APlayer.prototype.init = function () {
4646
+ '</div>'
4747
+ '</div>';
4848

49+
// 切换窄样式
50+
if (this.option.narrow) {
51+
this.element.classList.add('aplayer-narrow');
52+
}
53+
4954
// 创建audio元素
5055
this.audio = document.createElement("audio");
5156
this.audio.src = this.music.url;

demo/index.html

Lines changed: 69 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,81 @@
22
<html>
33
<head>
44
<meta charset="UTF-8">
5-
<title>AnotherPlayer Demo</title>
5+
<title>APlayer Demo</title>
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
67
<link rel="stylesheet" href="../APlayer.css">
8+
<style>
9+
body {
10+
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
11+
}
12+
.container {
13+
max-width: 32rem;
14+
margin-left: auto;
15+
margin-right: auto;
16+
}
17+
h1 {
18+
font-size: 54px;
19+
color: #333;
20+
margin: 30px 0 10px;
21+
}
22+
h2 {
23+
font-size: 22px;
24+
color: #555;
25+
}
26+
h3 {
27+
font-size: 24px;
28+
color: #555;
29+
}
30+
hr {
31+
display: block;
32+
width: 7rem;
33+
height: 1px;
34+
margin: 2.5rem 0;
35+
background-color: #eee;
36+
border: 0;
37+
}
38+
a {
39+
color: #08c;
40+
text-decoration: none;
41+
}
42+
p {
43+
font-size: 18px;
44+
}
45+
</style>
746
</head>
847
<body>
9-
<div id="player1" class="aplayer">
10-
<div style="padding: 10px; font-size: 10px; text-align: center;">(>﹏<) APlayer 加载中,好累的说...</div>
48+
<a href="https://github.com/DIYgod/APlayer" target="_blank"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/652c5b9acfaddf3a9c326fa6bde407b87f7be0f4/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6f72616e67655f6666373630302e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_orange_ff7600.png"></a>
49+
<div class="container">
50+
<h1>APlayer</h1>
51+
<h2>Wow, such a beautiful html5 music player</h2>
52+
<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>
53+
<hr>
54+
<h3>Wide style and autoplay</h3>
55+
<div id="player1" class="aplayer">
56+
<div style="padding: 10px; font-size: 10px; text-align: center;">(>﹏<) APlayer 加载中,好累的说...</div>
57+
</div>
58+
<h3>Narrow style and no autoplay</h3>
59+
<div id="player2" class="aplayer">
60+
<div style="padding: 10px; font-size: 10px; text-align: center;">(>﹏<) APlayer 加载中,好累的说...</div>
61+
</div>
1162
</div>
1263
<script src="../APlayer.js"></script>
1364
<script>
14-
var ap = new APlayer({
65+
var ap1 = new APlayer({
1566
element: document.getElementById('player1'),
67+
narrow: false,
68+
autoplay: true,
69+
music: {
70+
title: 'Preparation',
71+
author: 'Hans Zimmer/Richard Harvey',
72+
url: 'http://7xifn9.com1.z0.glb.clouddn.com/Preparation.mp3',
73+
pic: 'http://7xifn9.com1.z0.glb.clouddn.com/Preparation.jpg'
74+
}
75+
});
76+
ap1.init();
77+
var ap2 = new APlayer({
78+
element: document.getElementById('player2'),
79+
narrow: true,
1680
autoplay: false,
1781
music: {
1882
title: 'Preparation',
@@ -21,7 +85,7 @@
2185
pic: 'http://7xifn9.com1.z0.glb.clouddn.com/Preparation.jpg'
2286
}
2387
});
24-
ap.init();
88+
ap2.init();
2589
</script>
2690
</body>
2791
</html>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "aplayer",
3-
"version": "1.0.5",
3+
"version": "1.0.6",
44
"description": "Wow, such a beautiful html5 music player",
55
"main": "APlayer.js",
66
"scripts": {

0 commit comments

Comments
 (0)