Skip to content

Commit 2573f9e

Browse files
committed
- remove equalizer and feature that saves playlist in the localstorage
1 parent ac0d2c3 commit 2573f9e

File tree

1 file changed

+3
-76
lines changed

1 file changed

+3
-76
lines changed

tools/online_music_player.html

Lines changed: 3 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -117,35 +117,6 @@
117117
padding: 20px;
118118
text-align: center;
119119
}
120-
121-
.eq-slider {
122-
-webkit-appearance: none;
123-
width: 100%;
124-
height: 5px;
125-
border-radius: 5px;
126-
background: #d3d3d3;
127-
outline: none;
128-
-webkit-transition: .2s;
129-
transition: opacity .2s;
130-
}
131-
132-
.eq-slider::-webkit-slider-thumb {
133-
-webkit-appearance: none;
134-
appearance: none;
135-
width: 15px;
136-
height: 15px;
137-
border-radius: 50%;
138-
background: #4CAF50;
139-
cursor: pointer;
140-
}
141-
142-
.eq-slider::-moz-range-thumb {
143-
width: 15px;
144-
height: 15px;
145-
border-radius: 50%;
146-
background: #4CAF50;
147-
cursor: pointer;
148-
}
149120
</style>
150121
</head>
151122
<body class="flex flex-col md:flex-row h-screen bg-gray-100 dark:bg-gray-800 dark:text-white font-sans">
@@ -203,14 +174,6 @@ <h2 class="text-2xl font-bold mb-4 text-indigo-600 dark:text-indigo-400">Add to
203174
<p>Drag and drop audio files here</p>
204175
</div>
205176
</div>
206-
<div class="bg-white dark:bg-gray-700 rounded-lg shadow-xl p-4 md:p-6 max-w-3xl mx-auto">
207-
<h2 class="text-2xl font-bold mb-4 text-indigo-600 dark:text-indigo-400">Equalizer</h2>
208-
<div id="equalizer" class="flex justify-between">
209-
<input type="range" min="-10" max="10" value="0" class="eq-slider" id="lowEQ">
210-
<input type="range" min="-10" max="10" value="0" class="eq-slider" id="midEQ">
211-
<input type="range" min="-10" max="10" value="0" class="eq-slider" id="highEQ">
212-
</div>
213-
</div>
214177
</main>
215178
<div id="loader"
216179
class="fixed top-0 left-0 w-full h-full bg-black bg-opacity-50 flex justify-center items-center z-50 hidden">
@@ -237,34 +200,19 @@ <h2 class="text-2xl font-bold mb-4 text-indigo-600 dark:text-indigo-400">Equaliz
237200
const clearPlaylist = document.getElementById('clearPlaylist');
238201
const dropZone = document.getElementById('dropZone');
239202
const loader = document.getElementById('loader');
240-
const lowEQ = document.getElementById('lowEQ');
241-
const midEQ = document.getElementById('midEQ');
242-
const highEQ = document.getElementById('highEQ');
243-
let songs = JSON.parse(localStorage.getItem('playlist')) || [];
203+
let songs = [];
244204
let currentSongIndex = 0;
245205
let isShuffled = false;
246206
let isRepeating = false;
247207
let audioContext;
248208
let analyser;
249-
let lowpass;
250-
let bandpass;
251-
let highpass;
252209

253210
function initAudioContext() {
254211
if (!audioContext) {
255212
audioContext = new (window.AudioContext || window.webkitAudioContext)();
256213
analyser = audioContext.createAnalyser();
257214
const source = audioContext.createMediaElementSource(audio);
258-
lowpass = audioContext.createBiquadFilter();
259-
bandpass = audioContext.createBiquadFilter();
260-
highpass = audioContext.createBiquadFilter();
261-
lowpass.type = "lowshelf";
262-
bandpass.type = "peaking";
263-
highpass.type = "highshelf";
264-
source.connect(lowpass);
265-
lowpass.connect(bandpass);
266-
bandpass.connect(highpass);
267-
highpass.connect(analyser);
215+
source.connect(analyser);
268216
analyser.connect(audioContext.destination);
269217
analyser.fftSize = 256;
270218
}
@@ -293,21 +241,14 @@ <h2 class="text-2xl font-bold mb-4 text-indigo-600 dark:text-indigo-400">Equaliz
293241
li.appendChild(removeBtn);
294242
playlist.appendChild(li);
295243
});
296-
savePlaylist();
297244
}
298245

299246
async function playSong(index) {
300247
try {
301248
currentSongIndex = index;
302249
const song = songs[index];
303250
showLoader();
304-
if (song.file instanceof File) {
305-
audio.src = URL.createObjectURL(song.file);
306-
} else {
307-
const response = await fetch(song.url);
308-
const blob = await response.blob();
309-
audio.src = URL.createObjectURL(blob);
310-
}
251+
audio.src = URL.createObjectURL(song.file);
311252
await audio.play();
312253
playPause.innerHTML = '<i class="fas fa-pause"></i>';
313254
nowPlaying.textContent = `Now Playing: ${song.name}`;
@@ -499,10 +440,6 @@ <h2 class="text-2xl font-bold mb-4 text-indigo-600 dark:text-indigo-400">Equaliz
499440
alert(message);
500441
}
501442

502-
function savePlaylist() {
503-
localStorage.setItem('playlist', JSON.stringify(songs.map(s => ({name: s.name, url: s.url}))));
504-
}
505-
506443
function addSongsToPlaylist(files) {
507444
for (let i = 0; i < files.length; i++) {
508445
const file = files[i];
@@ -532,16 +469,6 @@ <h2 class="text-2xl font-bold mb-4 text-indigo-600 dark:text-indigo-400">Equaliz
532469
const files = e.dataTransfer.files;
533470
addSongsToPlaylist(files);
534471
};
535-
lowEQ.oninput = () => {
536-
if (lowpass) lowpass.gain.setValueAtTime(lowEQ.value, audioContext.currentTime);
537-
};
538-
midEQ.oninput = () => {
539-
if (bandpass) bandpass.gain.setValueAtTime(midEQ.value, audioContext.currentTime);
540-
};
541-
highEQ.oninput = () => {
542-
if (highpass) highpass.gain.setValueAtTime(highEQ.value, audioContext.currentTime);
543-
};
544-
updatePlaylist();
545472
</script>
546473
</body>
547474
</html>

0 commit comments

Comments
 (0)