style: auto-fix linting issues
This commit is contained in:
parent
ce4979bdb2
commit
4cb8b84f91
5 changed files with 65 additions and 41 deletions
36
index.html
36
index.html
|
|
@ -2218,23 +2218,39 @@
|
||||||
<section class="content-section">
|
<section class="content-section">
|
||||||
<div class="header-actions">
|
<div class="header-actions">
|
||||||
<h2 class="section-title">Recommended Songs</h2>
|
<h2 class="section-title">Recommended Songs</h2>
|
||||||
<div style="display: flex; gap: 8px;">
|
<div style="display: flex; gap: 8px">
|
||||||
<button
|
<button
|
||||||
class="btn-primary"
|
class="btn-primary"
|
||||||
id="home-start-infinite-radio-btn"
|
id="home-start-infinite-radio-btn"
|
||||||
title="Start Infinite Radio"
|
title="Start Infinite Radio"
|
||||||
style="display: flex; align-items: center; gap: 8px; padding: 6px 12px; font-size: 0.85rem;"
|
style="
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 6px 12px;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
"
|
||||||
>
|
>
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
|
<svg
|
||||||
<path d="M4.9 19.1C1 15.2 1 8.8 4.9 4.9"/><path d="M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.4"/><circle cx="12" cy="12" r="2"/><path d="M16.2 7.8c2.3 2.3 2.3 6.1 0 8.4"/><path d="M19.1 4.9C23 8.8 23 15.2 19.1 19.1"/>
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="16"
|
||||||
|
height="16"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-width="2.5"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
>
|
||||||
|
<path d="M4.9 19.1C1 15.2 1 8.8 4.9 4.9" />
|
||||||
|
<path d="M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.4" />
|
||||||
|
<circle cx="12" cy="12" r="2" />
|
||||||
|
<path d="M16.2 7.8c2.3 2.3 2.3 6.1 0 8.4" />
|
||||||
|
<path d="M19.1 4.9C23 8.8 23 15.2 19.1 19.1" />
|
||||||
</svg>
|
</svg>
|
||||||
Start Infinite Radio
|
Start Infinite Radio
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button class="btn-secondary" id="refresh-songs-btn" title="Refresh">
|
||||||
class="btn-secondary"
|
|
||||||
id="refresh-songs-btn"
|
|
||||||
title="Refresh"
|
|
||||||
>
|
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
width="16"
|
width="16"
|
||||||
|
|
@ -5627,7 +5643,7 @@
|
||||||
<div id="radio-loading-indicator">
|
<div id="radio-loading-indicator">
|
||||||
<div class="animate-spin"></div>
|
<div class="animate-spin"></div>
|
||||||
<span>Finding more songs for you...</span>
|
<span>Finding more songs for you...</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
<button id="shuffle-btn" title="Shuffle">
|
<button id="shuffle-btn" title="Shuffle">
|
||||||
<svg
|
<svg
|
||||||
|
|
|
||||||
|
|
@ -348,7 +348,6 @@ class AudioContextManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
changeSource(audioElement) {
|
changeSource(audioElement) {
|
||||||
if (!this.audioContext) {
|
if (!this.audioContext) {
|
||||||
this.init(audioElement);
|
this.init(audioElement);
|
||||||
|
|
@ -360,8 +359,7 @@ class AudioContextManager {
|
||||||
if (this.source) {
|
if (this.source) {
|
||||||
try {
|
try {
|
||||||
this.source.disconnect();
|
this.source.disconnect();
|
||||||
} catch (e) {
|
} catch (e) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.audio = audioElement;
|
this.audio = audioElement;
|
||||||
|
|
@ -389,8 +387,7 @@ class AudioContextManager {
|
||||||
// Disconnect everything first
|
// Disconnect everything first
|
||||||
try {
|
try {
|
||||||
this.source.disconnect();
|
this.source.disconnect();
|
||||||
} catch (e) {
|
} catch (e) {}
|
||||||
}
|
|
||||||
this.outputNode.disconnect();
|
this.outputNode.disconnect();
|
||||||
if (this.volumeNode) {
|
if (this.volumeNode) {
|
||||||
this.volumeNode.disconnect();
|
this.volumeNode.disconnect();
|
||||||
|
|
|
||||||
33
js/events.js
33
js/events.js
|
|
@ -176,17 +176,25 @@ export function initializePlayerEvents(player, audioPlayer, scrobbler, ui) {
|
||||||
|
|
||||||
element.addEventListener('error', (e) => {
|
element.addEventListener('error', (e) => {
|
||||||
if (player.activeElement !== element) return;
|
if (player.activeElement !== element) return;
|
||||||
|
|
||||||
if (!element.src) return;
|
if (!element.src) return;
|
||||||
|
|
||||||
const error = element.error;
|
const error = element.error;
|
||||||
let errorMsg = 'Unknown error';
|
let errorMsg = 'Unknown error';
|
||||||
if (error) {
|
if (error) {
|
||||||
switch (error.code) {
|
switch (error.code) {
|
||||||
case 1: errorMsg = 'Playback aborted'; break;
|
case 1:
|
||||||
case 2: errorMsg = 'Network error'; break;
|
errorMsg = 'Playback aborted';
|
||||||
case 3: errorMsg = 'Decoding error'; break;
|
break;
|
||||||
case 4: errorMsg = 'Source not supported'; break;
|
case 2:
|
||||||
|
errorMsg = 'Network error';
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
errorMsg = 'Decoding error';
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
errorMsg = 'Source not supported';
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (error.message) errorMsg += `: ${error.message}`;
|
if (error.message) errorMsg += `: ${error.message}`;
|
||||||
}
|
}
|
||||||
|
|
@ -270,7 +278,6 @@ export function initializePlayerEvents(player, audioPlayer, scrobbler, ui) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Waveform Masking Logic
|
// Waveform Masking Logic
|
||||||
const updateWaveform = async () => {
|
const updateWaveform = async () => {
|
||||||
const progressBar = document.getElementById('progress-bar');
|
const progressBar = document.getElementById('progress-bar');
|
||||||
|
|
@ -452,7 +459,7 @@ function initializeSmoothSliders(player) {
|
||||||
if (activeEl.muted) {
|
if (activeEl.muted) {
|
||||||
activeEl.muted = false;
|
activeEl.muted = false;
|
||||||
localStorage.setItem('muted', false);
|
localStorage.setItem('muted', false);
|
||||||
|
|
||||||
const inactiveEl = player.currentTrack?.type === 'video' ? player.audio : player.video;
|
const inactiveEl = player.currentTrack?.type === 'video' ? player.audio : player.video;
|
||||||
if (inactiveEl) inactiveEl.muted = false;
|
if (inactiveEl) inactiveEl.muted = false;
|
||||||
}
|
}
|
||||||
|
|
@ -481,7 +488,7 @@ function initializeSmoothSliders(player) {
|
||||||
if (activeEl.muted) {
|
if (activeEl.muted) {
|
||||||
activeEl.muted = false;
|
activeEl.muted = false;
|
||||||
localStorage.setItem('muted', false);
|
localStorage.setItem('muted', false);
|
||||||
|
|
||||||
const inactiveEl = player.currentTrack?.type === 'video' ? player.audio : player.video;
|
const inactiveEl = player.currentTrack?.type === 'video' ? player.audio : player.video;
|
||||||
if (inactiveEl) inactiveEl.muted = false;
|
if (inactiveEl) inactiveEl.muted = false;
|
||||||
}
|
}
|
||||||
|
|
@ -549,7 +556,7 @@ function initializeSmoothSliders(player) {
|
||||||
if (activeEl.muted) {
|
if (activeEl.muted) {
|
||||||
activeEl.muted = false;
|
activeEl.muted = false;
|
||||||
localStorage.setItem('muted', false);
|
localStorage.setItem('muted', false);
|
||||||
|
|
||||||
const inactiveEl = player.currentTrack?.type === 'video' ? player.audio : player.video;
|
const inactiveEl = player.currentTrack?.type === 'video' ? player.audio : player.video;
|
||||||
if (inactiveEl) inactiveEl.muted = false;
|
if (inactiveEl) inactiveEl.muted = false;
|
||||||
}
|
}
|
||||||
|
|
@ -569,7 +576,7 @@ function initializeSmoothSliders(player) {
|
||||||
if (activeEl.muted) {
|
if (activeEl.muted) {
|
||||||
activeEl.muted = false;
|
activeEl.muted = false;
|
||||||
localStorage.setItem('muted', false);
|
localStorage.setItem('muted', false);
|
||||||
|
|
||||||
const inactiveEl = player.currentTrack?.type === 'video' ? player.audio : player.video;
|
const inactiveEl = player.currentTrack?.type === 'video' ? player.audio : player.video;
|
||||||
if (inactiveEl) inactiveEl.muted = false;
|
if (inactiveEl) inactiveEl.muted = false;
|
||||||
}
|
}
|
||||||
|
|
@ -585,7 +592,7 @@ function initializeSmoothSliders(player) {
|
||||||
if (activeEl.muted) {
|
if (activeEl.muted) {
|
||||||
activeEl.muted = false;
|
activeEl.muted = false;
|
||||||
localStorage.setItem('muted', false);
|
localStorage.setItem('muted', false);
|
||||||
|
|
||||||
const inactiveEl = player.currentTrack?.type === 'video' ? player.audio : player.video;
|
const inactiveEl = player.currentTrack?.type === 'video' ? player.audio : player.video;
|
||||||
if (inactiveEl) inactiveEl.muted = false;
|
if (inactiveEl) inactiveEl.muted = false;
|
||||||
}
|
}
|
||||||
|
|
@ -606,7 +613,7 @@ function initializeSmoothSliders(player) {
|
||||||
if (delta > 0 && activeEl.muted) {
|
if (delta > 0 && activeEl.muted) {
|
||||||
activeEl.muted = false;
|
activeEl.muted = false;
|
||||||
localStorage.setItem('muted', false);
|
localStorage.setItem('muted', false);
|
||||||
|
|
||||||
const inactiveEl = player.currentTrack?.type === 'video' ? player.audio : player.video;
|
const inactiveEl = player.currentTrack?.type === 'video' ? player.audio : player.video;
|
||||||
if (inactiveEl) inactiveEl.muted = false;
|
if (inactiveEl) inactiveEl.muted = false;
|
||||||
}
|
}
|
||||||
|
|
@ -629,7 +636,7 @@ function initializeSmoothSliders(player) {
|
||||||
if (delta > 0 && activeEl.muted) {
|
if (delta > 0 && activeEl.muted) {
|
||||||
activeEl.muted = false;
|
activeEl.muted = false;
|
||||||
localStorage.setItem('muted', false);
|
localStorage.setItem('muted', false);
|
||||||
|
|
||||||
const inactiveEl = player.currentTrack?.type === 'video' ? player.audio : player.video;
|
const inactiveEl = player.currentTrack?.type === 'video' ? player.audio : player.video;
|
||||||
if (inactiveEl) inactiveEl.muted = false;
|
if (inactiveEl) inactiveEl.muted = false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
29
js/player.js
29
js/player.js
|
|
@ -103,7 +103,6 @@ export class Player {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
this._setupVideoSync();
|
this._setupVideoSync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -119,8 +118,7 @@ export class Player {
|
||||||
if (this.video.readyState >= 2 && (this.audio.readyState > 0 || this.audio.src)) {
|
if (this.video.readyState >= 2 && (this.audio.readyState > 0 || this.audio.src)) {
|
||||||
this.audio.currentTime = this.video.currentTime;
|
this.audio.currentTime = this.video.currentTime;
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const syncedEvent = new Event(eventName, { bubbles: e.bubbles, cancelable: e.cancelable });
|
const syncedEvent = new Event(eventName, { bubbles: e.bubbles, cancelable: e.cancelable });
|
||||||
|
|
@ -467,8 +465,7 @@ export class Player {
|
||||||
this.hls = new Hls();
|
this.hls = new Hls();
|
||||||
this.hls.loadSource(url);
|
this.hls.loadSource(url);
|
||||||
this.hls.attachMedia(video);
|
this.hls.attachMedia(video);
|
||||||
this.hls.on(Hls.Events.MANIFEST_PARSED, () => {
|
this.hls.on(Hls.Events.MANIFEST_PARSED, () => {});
|
||||||
});
|
|
||||||
this.hls.on(Hls.Events.ERROR, (event, data) => {
|
this.hls.on(Hls.Events.ERROR, (event, data) => {
|
||||||
if (data.fatal) {
|
if (data.fatal) {
|
||||||
console.warn('HLS fatal error:', data.type);
|
console.warn('HLS fatal error:', data.type);
|
||||||
|
|
@ -706,10 +703,16 @@ export class Player {
|
||||||
if (!played) return;
|
if (!played) return;
|
||||||
} else if (track.type === 'video') {
|
} else if (track.type === 'video') {
|
||||||
if (window.monochromeUi) {
|
if (window.monochromeUi) {
|
||||||
const isInFullscreen = document.getElementById('fullscreen-cover-overlay')?.style.display === 'flex';
|
const isInFullscreen =
|
||||||
|
document.getElementById('fullscreen-cover-overlay')?.style.display === 'flex';
|
||||||
if (!isInFullscreen) {
|
if (!isInFullscreen) {
|
||||||
const lyricsManager = window.monochromeUi.lyricsManager;
|
const lyricsManager = window.monochromeUi.lyricsManager;
|
||||||
window.monochromeUi.showFullscreenCover(track, this.getNextTrack(), lyricsManager, activeElement);
|
window.monochromeUi.showFullscreenCover(
|
||||||
|
track,
|
||||||
|
this.getNextTrack(),
|
||||||
|
lyricsManager,
|
||||||
|
activeElement
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -948,24 +951,24 @@ export class Player {
|
||||||
const recommendations = await this.api.getRecommendedTracksForPlaylist(seeds, 10);
|
const recommendations = await this.api.getRecommendedTracksForPlaylist(seeds, 10);
|
||||||
if (recommendations && recommendations.length > 0) {
|
if (recommendations && recommendations.length > 0) {
|
||||||
const currentQueueIds = new Set(this.getCurrentQueue().map((t) => t.id));
|
const currentQueueIds = new Set(this.getCurrentQueue().map((t) => t.id));
|
||||||
|
|
||||||
const [favorites, userPlaylists] = await Promise.all([
|
const [favorites, userPlaylists] = await Promise.all([
|
||||||
db.getFavorites('track'),
|
db.getFavorites('track'),
|
||||||
db.getAll('user_playlists'),
|
db.getAll('user_playlists'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const knownTrackIds = new Set([
|
const knownTrackIds = new Set([
|
||||||
...favorites.map(t => t.id),
|
...favorites.map((t) => t.id),
|
||||||
...userPlaylists.flatMap(p => (p.tracks || []).map(t => t.id))
|
...userPlaylists.flatMap((p) => (p.tracks || []).map((t) => t.id)),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const newTracks = recommendations.filter((t) => {
|
const newTracks = recommendations.filter((t) => {
|
||||||
if (currentQueueIds.has(t.id)) return false;
|
if (currentQueueIds.has(t.id)) return false;
|
||||||
|
|
||||||
if (knownTrackIds.has(t.id)) {
|
if (knownTrackIds.has(t.id)) {
|
||||||
return Math.random() < 0.2;
|
return Math.random() < 0.2;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3168,6 +3168,7 @@ input:checked + .slider::before {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transform: translate(-50%, 10px);
|
transform: translate(-50%, 10px);
|
||||||
}
|
}
|
||||||
|
|
||||||
to {
|
to {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
transform: translate(-50%, 0);
|
transform: translate(-50%, 0);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue