This commit is contained in:
DIYgod 2015-11-23 00:05:52 +08:00
parent 1a4c0761b1
commit 1d62a152cd
18 changed files with 359 additions and 303 deletions

3
.gitignore vendored
View File

@ -1 +1,2 @@
.idea
.idea
node_modules

View File

@ -1,298 +0,0 @@
@font-face {
font-family: 'aplayer-fontello';
src: url('font/aplayer-fontello.eot?72550380');
src: url('font/aplayer-fontello.eot?72550380#iefix') format('embedded-opentype'),
url('font/aplayer-fontello.woff?72550380') format('woff'),
url('font/aplayer-fontello.ttf?72550380') format('truetype'),
url('font/aplayer-fontello.svg?72550380#fontello') format('svg');
font-weight: normal;
font-style: normal;
}
.aplayer [class^="aplayer-icon-"]:before, [class*=" aplayer-icon-"]:before {
font-family: "aplayer-fontello";
font-style: normal;
font-weight: normal;
speak: none;
display: inline-block;
text-decoration: inherit;
width: 1em;
text-align: center;
font-variant: normal;
text-transform: none;
line-height: 1em;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.aplayer .aplayer-icon-weibo:before {
content: '\e805';
}
.aplayer .aplayer-icon-play:before {
content: '\e806';
}
.aplayer .aplayer-icon-pause:before {
content: '\e807';
}
.aplayer .aplayer-icon-to-start:before {
content: '\e808';
}
.aplayer .aplayer-icon-to-end:before {
content: '\e809';
}
.aplayer .aplayer-icon-list:before {
content: '\e80a';
}
.aplayer .aplayer-icon-menu:before {
content: '\e80b';
}
.aplayer .aplayer-icon-volume-off:before {
content: '\e800';
}
.aplayer .aplayer-icon-volume-down:before {
content: '\e801';
}
.aplayer .aplayer-icon-volume-up:before {
content: '\e802';
}
.aplayer-narrow {
width: 66px;
}
.aplayer-narrow .aplayer-info {
display: none;
}
.aplayer {
font-family: Arial, Helvetica, sans-serif;
margin: 5px;
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, .14), 0 3px 1px -2px rgba(0, 0, 0, .2), 0 1px 5px 0 rgba(0, 0, 0, .12);
border-radius: 2px;
height: 66px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.aplayer span {
cursor: default !important;
}
.aplayer .aplayer-pic {
position: relative;
float: left;
height: 100%;
width: 66px;
}
.aplayer .aplayer-pic img {
height: 100%;
width: 100%;
border-radius: 2px 0 0 2px;
}
.aplayer .aplayer-mask {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.2);
}
.aplayer .aplayer-button {
position: absolute;
color: #fff;
border-radius: 50%;
opacity: 0.8;
cursor: pointer;
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
background: rgba(0, 0, 0, 0.2);
}
.aplayer .aplayer-button:hover {
opacity: 1;
}
.aplayer .aplayer-hide {
display: none;
}
.aplayer .aplayer-play {
width: 26px;
height: 26px;
border: 2px solid #fff;
top: 50%;
left: 50%;
margin: -15px 0 0 -15px;
}
.aplayer .aplayer-play .aplayer-icon-play {
position: absolute;
top: 2px;
left: 4px;
font-size: 20px;
line-height: 23px;
}
.aplayer .aplayer-pause {
width: 16px;
height: 16px;
border: 2px solid #fff;
bottom: 4px;
right: 4px;
}
.aplayer .aplayer-pause .aplayer-icon-pause {
position: absolute;
top: 1px;
left: 2px;
font-size: 12px;
line-height: 14px;
}
.aplayer .aplayer-info {
margin-left: 66px;
padding: 17px 7px 0 10px;
}
.aplayer .aplayer-music {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
margin-bottom: 17px;
}
.aplayer .aplayer-title {
font-size: 14px;
}
.aplayer .aplayer-author {
font-size: 12px;
color: #666;
}
.aplayer .aplayer-music a {
margin-right: 7px;
font-size: 14px;
color: #000;
}
.aplayer .aplayer-music a:hover {
color: #E90F24;
}
.aplayer .aplayer-controller {
position: relative;
}
.aplayer .aplayer-bar-wrap {
margin-right: 120px;
}
.aplayer .aplayer-bar {
position: relative;
height: 2px;
width: 100%;
background: #cdcdcd;
cursor: pointer !important;
}
.aplayer .aplayer-loaded {
position: absolute;
left: 0;
top: 0;
bottom: 0;
background: #aaa;
height: 2px;
transition: all 0.5s ease;
}
.aplayer .aplayer-played {
position: absolute;
left: 0;
top: 0;
bottom: 0;
background: #b7daff;
height: 2px;
}
.aplayer .aplayer-thumb {
position: absolute;
top: 0;
right: 0;
margin-top: -4px;
margin-right: -10px;
height: 8px;
width: 8px;
border: 1px solid #b7daff;
border-radius: 50%;
background: #fff;
cursor: pointer !important;
}
.aplayer .aplayer-thumb:hover {
background: #b7daff;
}
.aplayer .aplayer-time {
position: absolute;
right: 0;
bottom: -5px;
height: 17px;
color: #999;
font-size: 11px;
}
.aplayer .aplayer-time i {
color: #666;
font-size: 15px;
}
.aplayer .aplayer-volume-wrap {
display: inline-block;
margin-left: 7px;
cursor: pointer !important;
}
.aplayer .aplayer-volume-wrap:hover .aplayer-volume-bar-wrap {
display: block;
}
.aplayer .aplayer-volume-bar-wrap {
display: none;
position: absolute;
bottom: 17px;
right: -5px;
width: 25px;
height: 40px;
}
.aplayer .aplayer-volume-bar {
position: absolute;
bottom: 0;
right: 10px;
width: 5px;
height: 35px;
background: #aaa;
}
.aplayer .aplayer-volume {
position: absolute;
bottom: 0;
right: 0;
width: 5px;
background: #b7daff;
}

View File

@ -57,6 +57,12 @@ API
+ `ap.play()`
+ `ap.pause()`
Development
```
gulp
```
## Todo
- [x] 播放进度拖拽控制

1
build/APlayer.min.css vendored Normal file

File diff suppressed because one or more lines are too long

1
build/APlayer.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

@ -4,7 +4,7 @@
<meta charset="UTF-8">
<title>APlayer Demo</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="../APlayer.css">
<link rel="stylesheet" href="../build/APlayer.min.css">
<style>
body {
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
@ -60,7 +60,7 @@
<div style="padding: 10px; font-size: 10px; text-align: center;">() APlayer 加载中,好累的说...</div>
</div>
</div>
<script src="../APlayer.js"></script>
<script src="../build/APlayer.min.js"></script>
<script>
var ap1 = new APlayer({
element: document.getElementById('player1'),

35
gulpfile.js Normal file
View File

@ -0,0 +1,35 @@
var gulp = require('gulp');
var sass = require('gulp-sass');
var prefix = require('gulp-autoprefixer');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var minifyCSS = require('gulp-minify-css');
var rename = require('gulp-rename');
// Move font file
gulp.task('font', function () {
return gulp.src('src/font/*')
.pipe(gulp.dest('build/font'));
});
// Build src and css js files
gulp.task('compress', function() {
gulp.src(['src/*.js'])
.pipe(uglify())
.pipe(rename('APlayer.min.js'))
.pipe(gulp.dest('build'));
gulp.src('src/*.scss')
.pipe(sass())
.pipe(prefix(['last 15 versions', '> 1%', 'ie 8', 'ie 7'], { cascade: true }))
.pipe(minifyCSS())
.pipe(rename('APlayer.min.css'))
.pipe(gulp.dest('build'));
});
// Watch js and scss files for changes & recompile
gulp.task('watch', function () {
gulp.watch(['src/*.js', 'src/*.scss'], ['compress']);
});
// Default task, running just `gulp` will move font, compress js and scss and watch files.
gulp.task('default', ['font', 'compress', 'watch']);

View File

@ -1,6 +1,6 @@
{
"name": "aplayer",
"version": "1.0.6",
"version": "1.0.7",
"description": "Wow, such a beautiful html5 music player",
"main": "APlayer.js",
"scripts": {
@ -20,5 +20,14 @@
"bugs": {
"url": "https://github.com/DIYgod/APlayer/issues"
},
"homepage": "https://github.com/DIYgod/APlayer#readme"
"homepage": "https://github.com/DIYgod/APlayer#readme",
"devDependencies": {
"gulp": "^3.9.0",
"gulp-autoprefixer": "^3.1.0",
"gulp-concat": "^2.6.0",
"gulp-minify-css": "^1.2.1",
"gulp-rename": "^1.2.2",
"gulp-sass": "^2.1.0",
"gulp-uglify": "^1.5.1"
}
}

280
src/APlayer.scss Normal file
View File

@ -0,0 +1,280 @@
$aplayer-height: 66px;
@font-face {
font-family: 'aplayer-fontello';
src: url('font/aplayer-fontello.eot?72550380');
src: url('font/aplayer-fontello.eot?72550380#iefix') format('embedded-opentype'),
url('font/aplayer-fontello.woff?72550380') format('woff'),
url('font/aplayer-fontello.ttf?72550380') format('truetype'),
url('font/aplayer-fontello.svg?72550380#fontello') format('svg');
font-weight: normal;
font-style: normal;
}
.aplayer {
font-family: Arial, Helvetica, sans-serif;
margin: 5px;
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, .14), 0 3px 1px -2px rgba(0, 0, 0, .2), 0 1px 5px 0 rgba(0, 0, 0, .12);
border-radius: 2px;
height: $aplayer-height;
user-select: none;
[class^="aplayer-icon-"]:before, [class*=" aplayer-icon-"]:before {
font-family: "aplayer-fontello";
font-style: normal;
font-weight: normal;
display: inline-block;
text-decoration: inherit;
width: 1em;
text-align: center;
font-variant: normal;
text-transform: none;
line-height: 1em;
}
.aplayer-icon-weibo:before {
content: '\e805';
}
.aplayer-icon-play:before {
content: '\e806';
}
.aplayer-icon-pause:before {
content: '\e807';
}
.aplayer-icon-to-start:before {
content: '\e808';
}
.aplayer-icon-to-end:before {
content: '\e809';
}
.aplayer-icon-list:before {
content: '\e80a';
}
.aplayer-icon-menu:before {
content: '\e80b';
}
.aplayer-icon-volume-off:before {
content: '\e800';
}
.aplayer-icon-volume-down:before {
content: '\e801';
}
.aplayer-icon-volume-up:before {
content: '\e802';
}
.aplayer-narrow {
width: $aplayer-height;
.aplayer-info {
display: none;
}
}
span {
cursor: default !important;
}
.aplayer-pic {
position: relative;
float: left;
height: 100%;
width: $aplayer-height;
img {
height: 100%;
width: 100%;
border-radius: 2px 0 0 2px;
}
.aplayer-button {
position: absolute;
color: #fff;
border-radius: 50%;
opacity: 0.8;
cursor: pointer;
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
background: rgba(0, 0, 0, 0.2);
&:hover {
opacity: 1;
}
}
.aplayer-hide {
display: none;
}
.aplayer-play {
width: 26px;
height: 26px;
border: 2px solid #fff;
top: 50%;
left: 50%;
margin: -15px 0 0 -15px;
.aplayer-icon-play {
position: absolute;
top: 2px;
left: 4px;
font-size: 20px;
line-height: 23px;
}
}
.aplayer-pause {
width: 16px;
height: 16px;
border: 2px solid #fff;
bottom: 4px;
right: 4px;
.aplayer-icon-pause {
position: absolute;
top: 1px;
left: 2px;
font-size: 12px;
line-height: 14px;
}
}
}
.aplayer-info {
margin-left: $aplayer-height;
padding: 17px 7px 0 10px;
.aplayer-music {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
margin-bottom: 17px;
.aplayer-title {
font-size: 14px;
}
.aplayer-author {
font-size: 12px;
color: #666;
}
a {
margin-right: 7px;
font-size: 14px;
color: #000;
&:hover {
color: #E90F24;
}
}
}
.aplayer-controller {
position: relative;
.aplayer-bar-wrap {
margin-right: 120px;
.aplayer-bar {
position: relative;
height: 2px;
width: 100%;
background: #cdcdcd;
cursor: pointer !important;
.aplayer-loaded {
position: absolute;
left: 0;
top: 0;
bottom: 0;
background: #aaa;
height: 2px;
transition: all 0.5s ease;
}
.aplayer-played {
position: absolute;
left: 0;
top: 0;
bottom: 0;
background: #b7daff;
height: 2px;
.aplayer-thumb {
position: absolute;
top: 0;
right: 0;
margin-top: -4px;
margin-right: -10px;
height: 8px;
width: 8px;
border: 1px solid #b7daff;
border-radius: 50%;
background: #fff;
cursor: pointer !important;
&:hover {
background: #b7daff;
}
}
}
}
}
.aplayer-time {
position: absolute;
right: 0;
bottom: -5px;
height: 17px;
color: #999;
font-size: 11px;
i {
color: #666;
font-size: 15px;
}
.aplayer-volume-wrap {
display: inline-block;
margin-left: 7px;
cursor: pointer !important;
&:hover .aplayer-volume-bar-wrap {
display: block;
}
.aplayer-volume-bar-wrap {
display: none;
position: absolute;
bottom: 17px;
right: -5px;
width: 25px;
height: 40px;
.aplayer-volume-bar {
position: absolute;
bottom: 0;
right: 10px;
width: 5px;
height: 35px;
background: #aaa;
.aplayer-volume {
position: absolute;
bottom: 0;
right: 0;
width: 5px;
background: #b7daff;
}
}
}
}
}
}
}
}

Binary file not shown.

View File

@ -0,0 +1,21 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg">
<metadata>Copyright (C) 2015 by original authors @ fontello.com</metadata>
<defs>
<font id="fontello" horiz-adv-x="1000" >
<font-face font-family="fontello" font-weight="400" font-stretch="normal" units-per-em="1000" ascent="850" descent="-150" />
<missing-glyph horiz-adv-x="1000" />
<glyph glyph-name="volume-off" unicode="&#xe800;" d="m429 654v-608q0-14-11-25t-25-10-25 10l-186 186h-146q-15 0-25 11t-11 25v214q0 15 11 25t25 11h146l186 186q10 10 25 10t25-10 11-25z" horiz-adv-x="428.6" />
<glyph glyph-name="volume-down" unicode="&#xe801;" d="m429 654v-608q0-14-11-25t-25-10-25 10l-186 186h-146q-15 0-25 11t-11 25v214q0 15 11 25t25 11h146l186 186q10 10 25 10t25-10 11-25z m214-304q0-42-24-79t-63-52q-5-3-14-3-14 0-25 10t-10 26q0 12 6 20t17 14 19 12 16 20 6 32-6 32-16 20-19 12-17 14-6 20q0 15 10 26t25 10q9 0 14-3 39-15 63-52t24-79z" horiz-adv-x="642.9" />
<glyph glyph-name="volume-up" unicode="&#xe802;" d="m429 654v-608q0-14-11-25t-25-10-25 10l-186 186h-146q-15 0-25 11t-11 25v214q0 15 11 25t25 11h146l186 186q10 10 25 10t25-10 11-25z m214-304q0-42-24-79t-63-52q-5-3-14-3-14 0-25 10t-10 26q0 12 6 20t17 14 19 12 16 20 6 32-6 32-16 20-19 12-17 14-6 20q0 15 10 26t25 10q9 0 14-3 39-15 63-52t24-79z m143 0q0-85-48-158t-125-105q-8-3-14-3-15 0-26 11t-10 25q0 22 21 33 32 16 43 25 41 30 64 75t23 97-23 97-64 75q-11 9-43 25-21 11-21 33 0 14 10 25t25 11q7 0 15-3 78-33 125-105t48-158z m143 0q0-128-71-236t-189-158q-7-3-14-3-15 0-26 11t-10 25q0 20 22 33 4 2 12 6t13 6q25 14 45 28 69 51 108 127t38 161-38 161-108 127q-20 14-45 28-4 3-13 6t-12 6q-22 13-22 33 0 14 10 25t26 11q7 0 14-3 118-51 189-158t71-236z" horiz-adv-x="928.6" />
<glyph glyph-name="weibo" unicode="&#xe805;" d="m377 134q11 18 6 38t-25 28q-19 8-41 0t-33-25q-13-19-8-38t24-29 42-1 35 27z m52 67q5 7 2 15t-10 10q-7 3-16 0t-12-10q-9-18 8-26 8-2 16 1t12 10z m97-60q-25-57-88-83t-125-7q-60 19-82 71t3 104q27 52 85 78t117 10q62-16 89-66t1-107z m174 90q-5 53-49 94t-117 61-153 12q-124-13-206-79t-74-148q5-53 50-94t116-61 153-12q125 13 206 79t74 148z m172-3q0-38-20-77t-61-77-94-65-126-47-151-17-154 19-134 51-96 85-36 111q0 64 39 137t110 144q94 94 191 131t137-3q36-36 11-117-2-8 0-11t5-4 8 0 8 2l3 1q78 33 138 33t85-34q25-35 0-99-1-8-3-11t3-7 7-5 9-3q32-10 58-26t44-46 19-65z m-41 349q23-27 30-61t-3-66q-5-12-17-19t-25-2q-12 5-19 17t-2 25q11 35-13 61t-60 20q-13-3-25 4t-14 21q-3 14 5 25t20 14q34 7 67-3t56-37z m101 91q48-54 63-125t-8-134q-5-16-19-23t-29-2-22 19-3 29q16 46 6 96t-45 88q-35 39-83 53t-96 5q-16-3-29 6t-17 24 5 29 25 16q68 14 136-6t116-75z" horiz-adv-x="1000" />
<glyph glyph-name="play" unicode="&#xe806;" d="m486 376q14-10 14-26 0-14-14-24l-428-266q-24-16-41-6t-17 40l0 514q0 30 17 40t41-6z" horiz-adv-x="500" />
<glyph glyph-name="pause" unicode="&#xe807;" d="m440 700q90 0 90-64l0-570q0-66-90-66t-90 66l0 570q0 64 90 64z m-350 0q90 0 90-64l0-570q0-66-90-66t-90 66l0 570q0 64 90 64z" horiz-adv-x="530" />
<glyph glyph-name="to-start" unicode="&#xe808;" d="m174 350q0 14 14 24l364 228q20 14 34 5t14-35l0-442q0-26-14-35t-34 5l-364 228q-14 10-14 22z m-174 234q0 58 76 58 74 0 74-58l0-466q0-58-74-58-76 0-76 58l0 466z" horiz-adv-x="600" />
<glyph glyph-name="to-end" unicode="&#xe809;" d="m412 374q14-10 14-24 0-12-14-22l-362-228q-22-14-36-5t-14 35l0 442q0 26 14 35t36-5z m114 268q74 0 74-58l0-466q0-58-74-58-76 0-76 58l0 466q0 58 76 58z" horiz-adv-x="600" />
<glyph glyph-name="list" unicode="&#xe80a;" d="m100 200q20 0 35-15t15-35-15-35-35-15l-50 0q-20 0-35 15t-15 35 14 35 36 15l50 0z m0 200q20 0 35-15t15-35-15-35-35-15l-50 0q-20 0-35 15t-15 35 14 35 36 15l50 0z m0 200q20 0 35-15t15-35-15-35-35-15l-50 0q-20 0-35 15t-15 35 14 35 36 15l50 0z m200-100q-20 0-35 15t-15 35 15 35 35 15l350 0q22 0 36-15t14-35-15-35-35-15l-350 0z m350-100q22 0 36-15t14-35-15-35-35-15l-350 0q-20 0-35 15t-15 35 15 35 35 15l350 0z m0-200q22 0 36-15t14-35-15-35-35-15l-350 0q-20 0-35 15t-15 35 15 35 35 15l350 0z" horiz-adv-x="700" />
<glyph glyph-name="menu" unicode="&#xe80b;" d="m650 400q22 0 36-15t14-35-15-35-35-15l-600 0q-20 0-35 15t-15 35 14 35 36 15l600 0z m-600 100q-20 0-35 15t-15 35 14 35 36 15l600 0q22 0 36-15t14-35-15-35-35-15l-600 0z m600-300q22 0 36-15t14-35-15-35-35-15l-600 0q-20 0-35 15t-15 35 14 35 36 15l600 0z" horiz-adv-x="700" />
</font>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Binary file not shown.