lint: fix JS errors and duplicate CSS selectors
This commit is contained in:
parent
6651136e5b
commit
c73572e195
3 changed files with 45 additions and 33 deletions
|
|
@ -500,7 +500,7 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||||
// Initialize tracker
|
// Initialize tracker
|
||||||
initTracker().catch(console.error);
|
initTracker().catch(console.error);
|
||||||
|
|
||||||
fetchcontributors();
|
await fetchcontributors();
|
||||||
const castBtn = document.getElementById('cast-btn');
|
const castBtn = document.getElementById('cast-btn');
|
||||||
initializeCasting(audioPlayer, castBtn);
|
initializeCasting(audioPlayer, castBtn);
|
||||||
|
|
||||||
|
|
|
||||||
55
js/player.js
55
js/player.js
|
|
@ -487,7 +487,7 @@ export class Player {
|
||||||
const timeRemaining = duration - currentTime;
|
const timeRemaining = duration - currentTime;
|
||||||
|
|
||||||
// Preload if we are in last 30 seconds of song
|
// Preload if we are in last 30 seconds of song
|
||||||
const shouldPreload = (duration > 0 && timeRemaining <= 30);
|
const shouldPreload = duration > 0 && timeRemaining <= 30;
|
||||||
|
|
||||||
if (shouldPreload) {
|
if (shouldPreload) {
|
||||||
this._pendingPreload = false;
|
this._pendingPreload = false;
|
||||||
|
|
@ -537,7 +537,7 @@ export class Player {
|
||||||
albumPeakAmplitude: trackData.info.albumPeakAmplitude,
|
albumPeakAmplitude: trackData.info.albumPeakAmplitude,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} catch(e) {} // Fail silently
|
} catch (_e) {} // Fail silently
|
||||||
}
|
}
|
||||||
|
|
||||||
this.preloadCache.set(track.id, streamInfo);
|
this.preloadCache.set(track.id, streamInfo);
|
||||||
|
|
@ -546,30 +546,45 @@ export class Player {
|
||||||
// Warm connection and pre-fetch
|
// Warm connection and pre-fetch
|
||||||
if (!streamUrl.startsWith('blob:')) {
|
if (!streamUrl.startsWith('blob:')) {
|
||||||
if (streamUrl.includes('.mpd') || streamUrl.includes('.m3u8')) {
|
if (streamUrl.includes('.mpd') || streamUrl.includes('.m3u8')) {
|
||||||
if (this.shakaInitialized && this.shakaPlayer && typeof this.shakaPlayer.preload === 'function') {
|
if (
|
||||||
|
this.shakaInitialized &&
|
||||||
|
this.shakaPlayer &&
|
||||||
|
typeof this.shakaPlayer.preload === 'function'
|
||||||
|
) {
|
||||||
try {
|
try {
|
||||||
let preloadConfig = undefined;
|
let preloadConfig = undefined;
|
||||||
if (typeof this.shakaPlayer.getConfiguration === 'function') {
|
if (typeof this.shakaPlayer.getConfiguration === 'function') {
|
||||||
preloadConfig = this.shakaPlayer.getConfiguration();
|
preloadConfig = this.shakaPlayer.getConfiguration();
|
||||||
const stats = typeof this.shakaPlayer.getStats === 'function' ? this.shakaPlayer.getStats() : null;
|
const stats =
|
||||||
|
typeof this.shakaPlayer.getStats === 'function'
|
||||||
|
? this.shakaPlayer.getStats()
|
||||||
|
: null;
|
||||||
if (stats && stats.estimatedBandwidth) {
|
if (stats && stats.estimatedBandwidth) {
|
||||||
preloadConfig.abr.defaultBandwidthEstimate = stats.estimatedBandwidth;
|
preloadConfig.abr.defaultBandwidthEstimate = stats.estimatedBandwidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lock the preload to the exact current audio codec to prevent ABR mismatch,
|
// Lock the preload to the exact current audio codec to prevent ABR mismatch,
|
||||||
// which forces the player to discard and re-fetch chunks on slow connections.
|
// which forces the player to discard and re-fetch chunks on slow connections.
|
||||||
preloadConfig.abr.enabled = false;
|
preloadConfig.abr.enabled = false;
|
||||||
try {
|
try {
|
||||||
const variants = typeof this.shakaPlayer.getVariantTracks === 'function' ? this.shakaPlayer.getVariantTracks() : [];
|
const variants =
|
||||||
const activeVariant = variants.find(v => v.active);
|
typeof this.shakaPlayer.getVariantTracks === 'function'
|
||||||
|
? this.shakaPlayer.getVariantTracks()
|
||||||
|
: [];
|
||||||
|
const activeVariant = variants.find((v) => v.active);
|
||||||
if (activeVariant && activeVariant.audioCodec) {
|
if (activeVariant && activeVariant.audioCodec) {
|
||||||
preloadConfig.preferredAudioCodecs = [activeVariant.audioCodec];
|
preloadConfig.preferredAudioCodecs = [activeVariant.audioCodec];
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
} catch (_e) {}
|
||||||
}
|
}
|
||||||
const preloadManager = await this.shakaPlayer.preload(streamUrl, null, null, preloadConfig);
|
const preloadManager = await this.shakaPlayer.preload(
|
||||||
|
streamUrl,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
preloadConfig
|
||||||
|
);
|
||||||
streamInfo.preloadManager = preloadManager;
|
streamInfo.preloadManager = preloadManager;
|
||||||
} catch (e) {
|
} catch (_e) {
|
||||||
// Ignore preload errors, will just load fresh
|
// Ignore preload errors, will just load fresh
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -801,7 +816,7 @@ export class Player {
|
||||||
this.hls.destroy();
|
this.hls.destroy();
|
||||||
this.hls = null;
|
this.hls = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retain the initialized Shaka player if we are remaining on the same HTMLMediaElement
|
// Retain the initialized Shaka player if we are remaining on the same HTMLMediaElement
|
||||||
if (this.shakaInitialized && this.shakaPlayer) {
|
if (this.shakaInitialized && this.shakaPlayer) {
|
||||||
if (this.shakaPlayer.getMediaElement() !== activeElement) {
|
if (this.shakaPlayer.getMediaElement() !== activeElement) {
|
||||||
|
|
@ -1015,14 +1030,17 @@ export class Player {
|
||||||
} else if (streamUrl.startsWith('blob:') || streamUrl.includes('.mpd')) {
|
} else if (streamUrl.startsWith('blob:') || streamUrl.includes('.mpd')) {
|
||||||
await this.shakaPlayer.attach(activeElement);
|
await this.shakaPlayer.attach(activeElement);
|
||||||
|
|
||||||
const loadTarget = track.type == 'video' && this.preloadCache.has(track.id) ?
|
const loadTarget =
|
||||||
(this.preloadCache.get(track.id).preloadManager || streamUrl) : streamUrl;
|
track.type == 'video' && this.preloadCache.has(track.id)
|
||||||
|
? this.preloadCache.get(track.id).preloadManager || streamUrl
|
||||||
|
: streamUrl;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await this.shakaPlayer.load(loadTarget);
|
await this.shakaPlayer.load(loadTarget);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("PreloadManager load Error:", e); if (loadTarget !== streamUrl) await this.shakaPlayer.load(streamUrl);
|
console.error('PreloadManager load Error:', e);
|
||||||
else throw e;
|
if (loadTarget !== streamUrl) await this.shakaPlayer.load(streamUrl);
|
||||||
|
else throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.shakaInitialized = true;
|
this.shakaInitialized = true;
|
||||||
|
|
@ -1097,8 +1115,9 @@ export class Player {
|
||||||
await this.shakaPlayer.load(loadTarget);
|
await this.shakaPlayer.load(loadTarget);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("PreloadManager load Error:", e); if (loadTarget !== streamUrl) await this.shakaPlayer.load(streamUrl);
|
console.error('PreloadManager load Error:', e);
|
||||||
else throw e;
|
if (loadTarget !== streamUrl) await this.shakaPlayer.load(streamUrl);
|
||||||
|
else throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.shakaInitialized = true;
|
this.shakaInitialized = true;
|
||||||
|
|
@ -1109,7 +1128,7 @@ export class Player {
|
||||||
|
|
||||||
this.updateAdaptiveQualityBadge();
|
this.updateAdaptiveQualityBadge();
|
||||||
|
|
||||||
// Instantly trigger playback rather than explicitly waiting for 'canplay'
|
// Instantly trigger playback rather than explicitly waiting for 'canplay'
|
||||||
// which delays the event loop and natively adds gap/latency
|
// which delays the event loop and natively adds gap/latency
|
||||||
await this.safePlay(activeElement);
|
await this.safePlay(activeElement);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
21
styles.css
21
styles.css
|
|
@ -1763,6 +1763,10 @@ input[type='search']::-webkit-search-cancel-button {
|
||||||
|
|
||||||
.settings-tab-content {
|
.settings-tab-content {
|
||||||
display: none;
|
display: none;
|
||||||
|
max-width: 100%;
|
||||||
|
min-width: 0;
|
||||||
|
overflow-x: auto;
|
||||||
|
overflow-y: visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
.settings-tab-content.active {
|
.settings-tab-content.active {
|
||||||
|
|
@ -1770,14 +1774,6 @@ input[type='search']::-webkit-search-cancel-button {
|
||||||
animation: fade-in-slide-up 0.4s var(--ease-out-back);
|
animation: fade-in-slide-up 0.4s var(--ease-out-back);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Prevent settings tab content from overflowing on small displays (fixes #313) */
|
|
||||||
.settings-tab-content {
|
|
||||||
max-width: 100%;
|
|
||||||
min-width: 0;
|
|
||||||
overflow-x: auto;
|
|
||||||
overflow-y: visible;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-grid {
|
.card-grid {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
|
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
|
||||||
|
|
@ -4301,6 +4297,7 @@ input:checked + .slider::before {
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
gap: 1rem;
|
gap: 1rem;
|
||||||
margin-top: 1rem;
|
margin-top: 1rem;
|
||||||
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.fs-volume-btn {
|
.fs-volume-btn {
|
||||||
|
|
@ -5910,10 +5907,6 @@ img[src=''] {
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
#fullscreen-cover-overlay.is-video-mode .fullscreen-volume-container {
|
|
||||||
margin-top: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
#fullscreen-cover-overlay.ui-hidden .fullscreen-main-view,
|
#fullscreen-cover-overlay.ui-hidden .fullscreen-main-view,
|
||||||
#fullscreen-cover-overlay.ui-hidden .fullscreen-controls,
|
#fullscreen-cover-overlay.ui-hidden .fullscreen-controls,
|
||||||
#fullscreen-cover-overlay.ui-hidden #fullscreen-next-track,
|
#fullscreen-cover-overlay.ui-hidden #fullscreen-next-track,
|
||||||
|
|
@ -9881,10 +9874,10 @@ body:has(#side-panel.active) #close-fullscreen-cover-btn {
|
||||||
|
|
||||||
.chat-msg {
|
.chat-msg {
|
||||||
margin-bottom: 0.5rem;
|
margin-bottom: 0.5rem;
|
||||||
animation: fadeIn 0.2s ease-out;
|
animation: fade-in 0.2s ease-out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes fadeIn {
|
@keyframes fade-in {
|
||||||
from {
|
from {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transform: translateY(5px);
|
transform: translateY(5px);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue