-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.html
131 lines (128 loc) · 3.93 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>audioPlugin Demo</title>
<style type="text/css">
.circleProgress_wrapper{
margin: auto;
position: relative;
width: 200px;
height: 200px;
overflow: hidden;
border-radius: 50%;
box-sizing: border-box;
cursor: pointer;
}
.circleProgress_wrapper:before{
position: absolute;
content: "";
width: 100%;
height: 100%;
background:rgba(0,0,0,0.1) url("images/viweImg.png");
background-size: cover;
border-radius: 50%;
}
.circleProgress_wrapper.rotate:before{
animation:audioLogoRotate 10s linear infinite;
}
@keyframes audioLogoRotate{
0%{
transform: rotate(0deg)
}
100%{
transform: rotate(360deg);
}
}
.circleProgress_wrapper:after{
position: absolute;
top:4px;
left: 4px;
content: "";
width: 192px;
height: 192px;
border-radius: 50%;
background-color:rgba(0,0,0,0.3);
background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAAoCAMAAACl6XjsAAAAaVBMVEX///8AAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////9ThU/0AAAAI3RSTlPMAJDBnhcQxrqzemtSOiMGAoZfLKqkjXBECoiFhGJIRi4MC3M9axoAAACkSURBVDjLrZRLDoMwDERdwKGkTSkt/X/h/ocEsZmdPVJ46ydFGdsj4VpWaeMhN5kpDp5WyEIMlCblqXW1heZnaqA6mxrolNKk3o2WBrb7o6WBPhEa4nY1qWNwNMRtaaC5exrihmbxVltD3A9HQ9zQLC5KadKRGv0o/4X8QF5KDosfff4ixbDWkvcp9wAR50Cc81OZqvkzxfVlavDTkqWaX9Fk4U9wrwfK2T44TgAAAABJRU5ErkJggg==');
background-repeat:no-repeat;
background-position:center;
background-size:38px 40px;
}
.circleProgress_wrapper.rotate:after{
background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAiCAMAAAAJbCvNAAAAM1BMVEX///8AAAD///////////////////////////////////////////////////////////+Q8lQ3AAAAEXRSTlPmAOEXHcLcvrtvZlER1IyHDEwQIaQAAABJSURBVDjL7ctbEoAgDEPRBLWK4mP/q/XDIGUJzPT+NXOKY1u+1p2qm2D4ewTONhXCNQmkNs0BAgQYFrirCJj/Qa4i3VTZ6nSRL9xqAzIch8kgAAAAAElFTkSuQmCC');
background-size:32px 34px;
}
.slice{
position: absolute;
width: 100%;
height: 100%;
clip:rect(0,200px,200px,100px);
}
.slice.gt50{
clip:rect(auto,auto,auto,auto);
}
.bar,.fill{
position: absolute;
width: 100%;
height: 100%;
border: 4px rgba(255, 249, 0, 0.77) solid;
box-sizing: border-box;
border-radius: 50%;
clip: rect(0,100px,200px,0);
}
.slice.gt50 .fill{
transform: rotate(180deg);
}
</style>
</head>
<body>
<div class="circleProgress_wrapper">
<div id="slice_wrapper" class="slice">
<div class="bar pre50"></div>
<div class="fill"></div>
</div>
</div>
<script type="text/javascript" src="src/audioPlayPlugin.js"></script>
<script>
var bar=document.querySelector(".slice>.bar"),
process=0,
circleProgress=document.querySelector(".circleProgress_wrapper"),
slice=document.getElementById("slice_wrapper");
var audio=new audioController({
src:"file/test1.mp3",
events:{
"play":function(){
addClass(circleProgress,"rotate");
},
"timeupdate":function(){
process=audio.getAttr("currentTime")/audio.getAttr("duration")*360;
parseInt(process)===180&&addClass(slice,"gt50");
bar.style="transform:rotate("+(process)+"deg)";
},
"pause":function(){
removeClass(circleProgress,"rotate");
},
"ended":function(){
removeClass(circleProgress,"rotate");
removeClass(slice,"gt50");
bar.style="transform:rotate(0deg)";
}
}
});
circleProgress.addEventListener("click",function(){
if(audio.getAttr("paused")){
audio.play()
}else{
audio.pause()
}
});
function addClass(element,className){
var oldClass=element.className;
oldClass.indexOf(className)<0&&(element.className=oldClass+" "+className);
}
function removeClass(element,className){
element.className=element.className.replace(new RegExp("\\s"+className),"");
}
</script>
</body>
</html>