Skip to content

Commit 99d8335

Browse files
committed
Add music player
1 parent f15a71e commit 99d8335

File tree

4 files changed

+233
-33
lines changed

4 files changed

+233
-33
lines changed

.vscode/settings.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"files.exclude": {
3+
"**/.git": true,
4+
"**/.svn": true,
5+
"**/.hg": true,
6+
"**/CVS": true,
7+
"**/.DS_Store": true,
8+
"**/Thumbs.db": true,
9+
"**/AdminScripts": true,
10+
"**/aspnet_client": true,
11+
"**/custerr": true,
12+
"**/ftproot": true,
13+
"**/history": true,
14+
"**/index": true,
15+
"**/logs": true,
16+
"**/node_modules": true,
17+
"**/temp": true,
18+
"**/.nuxt": true,
19+
}
20+
}

README.md

+33-33
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
1-
# Option
2-
3-
Navigation Optional for 217.
4-
5-
This is my personal webpage for school years, about what I seen and heard.
6-
Almost everything is full of local area jokes.
7-
8-
Hope it can interested you. Have fun!
9-
10-
![Badge](https://img.shields.io/badge/STATE-UPDATING-green?style=flat-square)
11-
![Badge](https://img.shields.io/badge/VERSION-3.11.1.0-orange?style=flat-square)
12-
13-
----
14-
15-
## Usage
16-
17-
* Enter the [mainpage](//otomad.github.io).
18-
* You may see that **your browser needs to be updated**!
19-
<span style="color: red;">It just a joke. </span>
20-
Just click the **"OK"** botton for **10 times**. Then you will see a close button
21-
on the **right-top corner** of the page. Just click it. Then you will see the
22-
main page.
23-
* Now it's easy to click the **three stripes** to toggle the menu.
24-
25-
## Update Logs
26-
27-
### Version 1.11 <small>(2020/11/11 15:26:03)</small>
28-
This is the **Single Update**!!!
29-
* Add lots of new tools.
30-
* Begin to use some **Bootstrap** styles.
31-
32-
### Version 1.0 <small>(2019/10/15 13:11:39)</small>
33-
* Plans to start building this website. And setup the first page.
1+
# Option
2+
3+
Navigation Optional for 217.
4+
5+
This is my personal webpage for school years, about what I seen and heard.
6+
Almost everything is full of local area jokes.
7+
8+
Hope it can interested you. Have fun!
9+
10+
![Badge](https://img.shields.io/badge/STATE-UPDATING-green?style=flat-square)
11+
![Badge](https://img.shields.io/badge/VERSION-4.1.23.0-orange?style=flat-square)
12+
13+
----
14+
15+
## Usage
16+
17+
* Enter the [mainpage](//otomad.github.io).
18+
* You may see that **your browser needs to be updated**!
19+
<span style="color: red;">It just a joke. </span>
20+
Just click the **"OK"** botton for **10 times**. Then you will see a close button
21+
on the **right-top corner** of the page. Just click it. Then you will see the
22+
main page.
23+
* Now it's easy to click the **three stripes** to toggle the menu.
24+
25+
## Update Logs
26+
27+
### Version 1.11 <small>(2020/11/11 15:26:03)</small>
28+
This is the **Single Update**!!!
29+
* Add lots of new tools.
30+
* Begin to use some **Bootstrap** styles.
31+
32+
### Version 1.0 <small>(2019/10/15 13:11:39)</small>
33+
* Plans to start building this website. And setup the first page.

cssc/music-player.html

+179
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
<!DOCTYPE html>
2+
<html lang="zh-cmn-Hans-CN">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
6+
<script src="https://cdn.staticfile.org/jquery/3.6.0/jquery.min.js"></script>
7+
<script src="https://cdn.staticfile.org/twitter-bootstrap/5.0.2/js/bootstrap.bundle.min.js"></script>
8+
<link rel="stylesheet" href="https://bootswatch.com/_vendor/bootstrap/dist/css/bootstrap.min.css" />
9+
<link id="css" data-theme="bootstrap" rel="stylesheet" crossorigin="anonymous" />
10+
<link rel="stylesheet" href="/basis/css/bootstrap-init.css" />
11+
<style>
12+
audio#audio {
13+
width: inherit;
14+
}
15+
16+
.range-form-control {
17+
display: flex;
18+
}
19+
20+
.after-range-text {
21+
min-width: 4.2em;
22+
text-align: center;
23+
display: block;
24+
}
25+
26+
* {
27+
user-select: none;
28+
}
29+
</style>
30+
</head>
31+
<body>
32+
<div class="container-fluid">
33+
<title class="h4">音乐播放器</title>
34+
<meta name="discription" class="h6" content="一个非常简陋的音乐播放器" class="mb-3" />
35+
<div class="row">
36+
<div class="mb-2">
37+
<input class="form-control" type="file" accept="audio/*,video/*,.mp3,.ogg,.flac,.wav,.ape,.aac,.m4a,.mp4,.mpg,.flv" id="music-file">
38+
</div>
39+
<div class="mb-2">
40+
<audio id="audio" controls loop></audio>
41+
</div>
42+
<div class="input-group mb-2">
43+
<label class="input-group-text" for="volume-range">音量</label>
44+
<div class="form-control range-form-control">
45+
<input type="range" class="form-range" id="volume-range" min="0" max="100" value="100" />
46+
</div>
47+
<span class="input-group-text after-range-text" for="volume-range" id="volume-label">100%</span>
48+
</div>
49+
<div class="input-group mb-2">
50+
<label class="input-group-text" for="speed-range">速度</label>
51+
<div class="form-control range-form-control">
52+
<input type="range" class="form-range" id="speed-range" min="-200" max="200" value="0" step="4" />
53+
</div>
54+
<span class="input-group-text after-range-text" for="speed-range" id="speed-label"></span>
55+
</div>
56+
<div class="btn-group mb-2" role="group" id="speed-group">
57+
<button type="button" class="btn btn-outline-secondary">0.25×</button>
58+
<button type="button" class="btn btn-outline-secondary">0.5×</button>
59+
<button type="button" class="btn btn-outline-secondary">0.75×</button>
60+
<button type="button" class="btn btn-outline-secondary"></button>
61+
<button type="button" class="btn btn-outline-secondary">1.25×</button>
62+
<button type="button" class="btn btn-outline-secondary">1.5×</button>
63+
<button type="button" class="btn btn-outline-secondary"></button>
64+
<button type="button" class="btn btn-outline-secondary"></button>
65+
<button type="button" class="btn btn-outline-secondary"></button>
66+
</div>
67+
<div class="input-group mb-2">
68+
<label class="input-group-text" for="preserves-pitch-check">速度保持音高</label>
69+
<div class="form-control" id="preserves-pitch-check-form-control">
70+
<div class="form-check form-switch">
71+
<input class="form-check-input" type="checkbox" role="switch" id="preserves-pitch-check" />
72+
<label class="form-check-label" id="preserves-pitch-label"></label>
73+
</div>
74+
</div>
75+
</div>
76+
<div class="input-group mb-2">
77+
<label class="input-group-text" for="loop-check">循环播放</label>
78+
<div class="form-control" id="loop-check-form-control">
79+
<div class="form-check form-switch">
80+
<input class="form-check-input" type="checkbox" role="switch" id="loop-check" checked />
81+
<label class="form-check-label" id="loop-label"></label>
82+
</div>
83+
</div>
84+
</div>
85+
</div>
86+
</div>
87+
<script>
88+
["preserves-pitch", "loop"].forEach(check => {
89+
$(`#${check}-check-form-control`).click(function (e) {
90+
if (e.target instanceof HTMLInputElement) return;
91+
const check = $(`#${check}-check`)[0];
92+
check.checked = !check.checked;
93+
check.dispatchEvent(new Event("change"));
94+
check.focus();
95+
});
96+
})
97+
98+
$("[for]").click(function () {
99+
$("#" + $(this).attr("for")).focus();
100+
});
101+
102+
const internalChange = {
103+
event: new Event("internalchange"),
104+
emit(el) {
105+
if (el instanceof jQuery)
106+
el = el[0];
107+
el.dispatchEvent(this.event);
108+
},
109+
is(event) {
110+
return event.type = this.event.type;
111+
},
112+
}
113+
114+
/** @type HTMLAudioElement */
115+
const audio = $("#audio")[0];
116+
audio.preservesPitch = false;
117+
118+
$("#volume-range").bind("input propertychange change", function (e) {
119+
console.log(e);
120+
const volume = +this.value;
121+
$("#volume-label").text(volume + "%");
122+
audio.volume = volume / 100;
123+
});
124+
125+
$("#speed-range").bind("input propertychange change", function (e) {
126+
const speed = 2 ** (+this.value / 100);
127+
audio.playbackRate = speed;
128+
});
129+
130+
$("#preserves-pitch-check").change(function () {
131+
const preserve = this.checked;
132+
$("#preserves-pitch-label").text(preserve ? "开" : "关");
133+
audio.preservesPitch = preserve;
134+
});
135+
136+
$("#loop-check").change(function () {
137+
const loop = this.checked;
138+
$("#loop-label").text(loop ? "开" : "关");
139+
audio.loop = loop;
140+
});
141+
142+
function removeTrailingZero(numberString) {
143+
return numberString.replace(/\.?0+$/, "");
144+
}
145+
146+
$("#speed-group button").click(function () {
147+
const speed = parseFloat(this.textContent);
148+
setPlaybackRate(speed);
149+
});
150+
151+
$(audio).on("volumechange", function () {
152+
const volume = this.volume * 100;
153+
$("#volume-range").val(volume).change();
154+
});
155+
156+
$(audio).on("ratechange", function () {
157+
const speed = this.playbackRate;
158+
setPlaybackRate(speed);
159+
});
160+
161+
function setPlaybackRate(rate) {
162+
const rangeValue = Math.log2(rate) * 100;
163+
$("#speed-range").val(rangeValue);
164+
$("#speed-label").text(removeTrailingZero(rate.toFixed(2)) + "×");
165+
audio.playbackRate = rate;
166+
}
167+
168+
$("#music-file").change(function () {
169+
/** @type HTMLInputElement */
170+
const thi = this;
171+
const file = thi.files[0];
172+
if (!file) return;
173+
const blob = URL.createObjectURL(file);
174+
audio.src = blob;
175+
});
176+
</script>
177+
<script src="/basis/NightTime.js"></script>
178+
</body>
179+
</html>

option.html

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
弹跳 DVD 屏保 | cssc/dvd/index.html
2828
3D 地球世界地图 | cssc/earth/index.html
2929
劲爆淋堂 | cssc/madden-hall/index.html
30+
音乐播放器 | cssc/music-player.html
3031
$莹你一笑 | phone
3132
乔碧萝来电 | hotkid/tel/来电.html
3233
让你的照片动起来 | hotkid/nod-to-the-rhythm/index.html

0 commit comments

Comments
 (0)