icon compatibility
This commit is contained in:
+29
-26
@@ -1,16 +1,16 @@
|
||||
@font-face {
|
||||
font-family: 'fontello';
|
||||
src: url('font/fontello.eot?72550380');
|
||||
src: url('font/fontello.eot?72550380#iefix') format('embedded-opentype'),
|
||||
url('font/fontello.woff?72550380') format('woff'),
|
||||
url('font/fontello.ttf?72550380') format('truetype'),
|
||||
url('font/fontello.svg?72550380#fontello') format('svg');
|
||||
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;
|
||||
}
|
||||
|
||||
[class^="icon-"]:before, [class*=" icon-"]:before {
|
||||
font-family: "fontello";
|
||||
.aplayer [class^="aplayer-icon-"]:before, [class*=" aplayer-icon-"]:before {
|
||||
font-family: "aplayer-fontello";
|
||||
font-style: normal;
|
||||
font-weight: normal;
|
||||
speak: none;
|
||||
@@ -25,43 +25,43 @@
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
.icon-weibo:before {
|
||||
.aplayer .aplayer-icon-weibo:before {
|
||||
content: '\e805';
|
||||
}
|
||||
|
||||
.icon-play:before {
|
||||
.aplayer .aplayer-icon-play:before {
|
||||
content: '\e806';
|
||||
}
|
||||
|
||||
.icon-pause:before {
|
||||
.aplayer .aplayer-icon-pause:before {
|
||||
content: '\e807';
|
||||
}
|
||||
|
||||
.icon-to-start:before {
|
||||
.aplayer .aplayer-icon-to-start:before {
|
||||
content: '\e808';
|
||||
}
|
||||
|
||||
.icon-to-end:before {
|
||||
.aplayer .aplayer-icon-to-end:before {
|
||||
content: '\e809';
|
||||
}
|
||||
|
||||
.icon-list:before {
|
||||
.aplayer .aplayer-icon-list:before {
|
||||
content: '\e80a';
|
||||
}
|
||||
|
||||
.icon-menu:before {
|
||||
.aplayer .aplayer-icon-menu:before {
|
||||
content: '\e80b';
|
||||
}
|
||||
|
||||
.icon-volume-off:before {
|
||||
.aplayer .aplayer-icon-volume-off:before {
|
||||
content: '\e800';
|
||||
}
|
||||
|
||||
.icon-volume-down:before {
|
||||
.aplayer .aplayer-icon-volume-down:before {
|
||||
content: '\e801';
|
||||
}
|
||||
|
||||
.icon-volume-up:before {
|
||||
.aplayer .aplayer-icon-volume-up:before {
|
||||
content: '\e802';
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@
|
||||
}
|
||||
|
||||
.aplayer span {
|
||||
cursor: default;
|
||||
cursor: default !important;
|
||||
}
|
||||
|
||||
.aplayer .aplayer-pic {
|
||||
@@ -131,7 +131,7 @@
|
||||
margin: -15px 0 0 -15px;
|
||||
}
|
||||
|
||||
.aplayer .aplayer-play .icon-play {
|
||||
.aplayer .aplayer-play .aplayer-icon-play {
|
||||
position: absolute;
|
||||
top: 2px;
|
||||
left: 4px;
|
||||
@@ -146,9 +146,9 @@
|
||||
right: 4px;
|
||||
}
|
||||
|
||||
.aplayer .aplayer-pause .icon-pause {
|
||||
.aplayer .aplayer-pause .aplayer-icon-pause {
|
||||
position: absolute;
|
||||
top: 2px;
|
||||
top: 1px;
|
||||
left: 2px;
|
||||
font-size: 12px;
|
||||
}
|
||||
@@ -159,6 +159,9 @@
|
||||
}
|
||||
|
||||
.aplayer .aplayer-music {
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
margin-bottom: 17px;
|
||||
}
|
||||
|
||||
@@ -172,7 +175,7 @@
|
||||
}
|
||||
|
||||
.aplayer .aplayer-music a {
|
||||
margin-left: 20px;
|
||||
margin-right: 7px;
|
||||
font-size: 14px;
|
||||
color: #000;
|
||||
}
|
||||
@@ -194,7 +197,7 @@
|
||||
height: 2px;
|
||||
width: 100%;
|
||||
background: #cdcdcd;
|
||||
cursor: pointer;
|
||||
cursor: pointer !important;
|
||||
}
|
||||
|
||||
.aplayer .aplayer-loaded {
|
||||
@@ -227,7 +230,7 @@
|
||||
border: 1px solid #b7daff;
|
||||
border-radius: 50%;
|
||||
background: #fff;
|
||||
cursor: pointer;
|
||||
cursor: pointer !important;
|
||||
}
|
||||
|
||||
.aplayer .aplayer-thumb:hover {
|
||||
@@ -251,7 +254,7 @@
|
||||
.aplayer .aplayer-volume-wrap {
|
||||
display: inline-block;
|
||||
margin-left: 7px;
|
||||
cursor: pointer;
|
||||
cursor: pointer !important;
|
||||
}
|
||||
|
||||
.aplayer .aplayer-volume-wrap:hover .aplayer-volume-bar-wrap {
|
||||
|
||||
+23
-16
@@ -8,17 +8,17 @@ APlayer.prototype.init = function () {
|
||||
+ '<div class="aplayer-pic">'
|
||||
+ '<img src="' + this.option.music.pic + '">'
|
||||
+ '<div class="aplayer-button aplayer-pause aplayer-hide">'
|
||||
+ '<i class="demo-icon icon-pause"></i>'
|
||||
+ '<i class="demo-icon aplayer-icon-pause"></i>'
|
||||
+ '</div>'
|
||||
+ '<div class="aplayer-button aplayer-play">'
|
||||
+ '<i class="demo-icon icon-play"></i>'
|
||||
+ '<i class="demo-icon aplayer-icon-play"></i>'
|
||||
+ '</div>'
|
||||
+ '</div>'
|
||||
+ '<div class="aplayer-info">'
|
||||
+ '<div class="aplayer-music">'
|
||||
+ '<a href="javascript:void((function(s,d,e,r,l,p,t,z,c){var%20f=\'http://v.t.sina.com.cn/share/share.php?appkey=2992571369\',u=z||d.location,p=[\'&url=\',e(u),\'&title=\',e(t||d.title),\'&source=\',e(r),\'&sourceUrl=\',e(l),\'&content=\',c||\'gb2312\',\'&pic=\',e(p||\'\')].join(\'\');function%20a(){if(!window.open([f,p].join(\'\'),\'mb\',[\'toolbar=0,status=0,resizable=1,width=440,height=430,left=\',(s.width-440)/2,\',top=\',(s.height-430)/2].join(\'\')))u.href=[f,p].join(\'\');};if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else%20a();})(screen,document,encodeURIComponent,\'\',\'\',\'' + this.option.music.pic + '\',\'' + '#APlayer音乐分享# ' + this.option.music.title + ' - ' + this.option.music.author + ' \',\'\',\'\'));" title="分享至微博"><i class="demo-icon aplayer-icon-weibo"></i></a>'
|
||||
+ '<span class="aplayer-title">' + this.option.music.title + '</span>'
|
||||
+ '<span class="aplayer-author"> - ' + this.option.music.author + '</span>'
|
||||
+ '<a href="javascript:void((function(s,d,e,r,l,p,t,z,c){var%20f=\'http://v.t.sina.com.cn/share/share.php?appkey=2992571369\',u=z||d.location,p=[\'&url=\',e(u),\'&title=\',e(t||d.title),\'&source=\',e(r),\'&sourceUrl=\',e(l),\'&content=\',c||\'gb2312\',\'&pic=\',e(p||\'\')].join(\'\');function%20a(){if(!window.open([f,p].join(\'\'),\'mb\',[\'toolbar=0,status=0,resizable=1,width=440,height=430,left=\',(s.width-440)/2,\',top=\',(s.height-430)/2].join(\'\')))u.href=[f,p].join(\'\');};if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else%20a();})(screen,document,encodeURIComponent,\'\',\'\',\'' + this.option.music.pic + '\',\'' + '#APlayer音乐分享# ' + this.option.music.title + ' - ' + this.option.music.author + ' \',\'\',\'\'));" title="分享至微博"><i class="demo-icon icon-weibo"></i></a>'
|
||||
+ '</div>'
|
||||
+ '<div class="aplayer-controller">'
|
||||
+ '<div class="aplayer-bar-wrap">'
|
||||
@@ -32,7 +32,7 @@ APlayer.prototype.init = function () {
|
||||
+ '<span class="aplayer-time">'
|
||||
+ ' - <span class="aplayer-ptime">00:00</span> / <span class="aplayer-dtime">00:00</span>'
|
||||
+ '<div class="aplayer-volume-wrap">'
|
||||
+ '<i class="demo-icon icon-volume-down"></i>'
|
||||
+ '<i class="demo-icon aplayer-icon-volume-down"></i>'
|
||||
+ '<div class="aplayer-volume-bar-wrap">'
|
||||
+ '<div class="aplayer-volume-bar">'
|
||||
+ '<div class="aplayer-volume" style="height: 80%"></div>'
|
||||
@@ -84,7 +84,7 @@ APlayer.prototype.init = function () {
|
||||
this.bar.addEventListener('click', function (event) {
|
||||
var e = event || window.event;
|
||||
barWidth = _self.bar.clientWidth;
|
||||
var percentage = (e.clientX - getElementLeft(_self.bar)) / barWidth;
|
||||
var percentage = (e.clientX - getElementViewLeft(_self.bar)) / barWidth;
|
||||
_self.updateBar.call(_self, 'played', percentage, 'width');
|
||||
_self.option.element.getElementsByClassName('aplayer-ptime')[0].innerHTML = _self.secondToTime(percentage * _self.audio.duration);
|
||||
_self.audio.currentTime = parseFloat(_self.playedBar.style.width) / 100 * _self.audio.duration;
|
||||
@@ -99,7 +99,7 @@ APlayer.prototype.init = function () {
|
||||
|
||||
function thumbMove (event) {
|
||||
var e = event || window.event;
|
||||
var percentage = (e.clientX - getElementLeft(_self.bar)) / barWidth;
|
||||
var percentage = (e.clientX - getElementViewLeft(_self.bar)) / barWidth;
|
||||
percentage = percentage > 0 ? percentage : 0;
|
||||
percentage = percentage < 1 ? percentage : 1;
|
||||
_self.updateBar.call(_self, 'played', percentage, 'width');
|
||||
@@ -124,49 +124,56 @@ APlayer.prototype.init = function () {
|
||||
var barHeight = 35;
|
||||
this.option.element.getElementsByClassName('aplayer-volume-bar-wrap')[0].addEventListener('click', function (event) {
|
||||
var e = event || window.event;
|
||||
var percentage = (barHeight - e.clientY + getElementTop(volumeBarWrap)) / barHeight;
|
||||
var percentage = (barHeight - e.clientY + getElementViewTop(volumeBarWrap)) / barHeight;
|
||||
percentage = percentage > 0 ? percentage : 0;
|
||||
percentage = percentage < 1 ? percentage : 1;
|
||||
_self.updateBar.call(_self, 'volume', percentage, 'height');
|
||||
_self.audio.volume = percentage;
|
||||
if (_self.audio.muted) {
|
||||
_self.audio.muted = false;
|
||||
}
|
||||
if (percentage === 1) {
|
||||
volumeicon.className = 'demo-icon icon-volume-up';
|
||||
volumeicon.className = 'demo-icon aplayer-icon-volume-up';
|
||||
}
|
||||
else {
|
||||
volumeicon.className = 'demo-icon icon-volume-down';
|
||||
volumeicon.className = 'demo-icon aplayer-icon-volume-down';
|
||||
}
|
||||
});
|
||||
volumeicon.addEventListener('click', function () {
|
||||
if (_self.audio.muted) {
|
||||
_self.audio.muted = false;
|
||||
volumeicon.className = _self.audio.volume === 1 ? 'demo-icon icon-volume-up' : 'demo-icon icon-volume-down';
|
||||
volumeicon.className = _self.audio.volume === 1 ? 'demo-icon aplayer-icon-volume-up' : 'demo-icon aplayer-icon-volume-down';
|
||||
_self.updateBar.call(_self, 'volume', _self.audio.volume, 'height');
|
||||
}
|
||||
else {
|
||||
_self.audio.muted = true;
|
||||
volumeicon.className = 'demo-icon icon-volume-off';
|
||||
volumeicon.className = 'demo-icon aplayer-icon-volume-off';
|
||||
_self.updateBar.call(_self, 'volume', 0, 'height');
|
||||
}
|
||||
});
|
||||
|
||||
// 获取元素相对窗口位置
|
||||
function getElementLeft (element){
|
||||
function getElementViewLeft (element) {
|
||||
var actualLeft = element.offsetLeft;
|
||||
var current = element.offsetParent;
|
||||
var elementScrollLeft;
|
||||
while (current !== null){
|
||||
actualLeft += current.offsetLeft;
|
||||
current = current.offsetParent;
|
||||
}
|
||||
return actualLeft;
|
||||
elementScrollLeft = document.body.scrollLeft + document.documentElement.scrollLeft;
|
||||
return actualLeft - elementScrollLeft;
|
||||
}
|
||||
function getElementTop(element){
|
||||
function getElementViewTop (element) {
|
||||
var actualTop = element.offsetTop;
|
||||
var current = element.offsetParent;
|
||||
var elementScrollTop;
|
||||
while (current !== null){
|
||||
actualTop += current.offsetTop;
|
||||
actualTop += current. offsetTop;
|
||||
current = current.offsetParent;
|
||||
}
|
||||
return actualTop;
|
||||
elementScrollTop = document.body.scrollTop + document.documentElement.scrollTop;
|
||||
return actualTop - elementScrollTop;
|
||||
}
|
||||
|
||||
// 自动播放
|
||||
|
||||
@@ -76,7 +76,9 @@ API
|
||||
- [x] 播放进度拖拽控制
|
||||
- [x] 音量控制
|
||||
- [x] 分享到微博
|
||||
- [ ] 错误处理
|
||||
- [ ] 加载样式及错误处理
|
||||
- [ ] 窄样式
|
||||
- [ ] 宽度高度自定义
|
||||
- [ ] 播放列表
|
||||
- [ ] 歌词展示
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
Reference in New Issue
Block a user