mirror of
https://github.com/pvrzz/atmosphere.git
synced 2026-11-29 05:22:26 +00:00
Music videos: keep video and audio, switch between them at the same moment
- Save as Video can also keep a matching audio file (on by default, recommended), copied losslessly from the video where possible - Songs with a video beside them get a video badge; video-only files play as songs - Video button (V) shows the music video in TV mode, kept in sync with the song, so switching between the cover and the video never interrupts playback
This commit is contained in:
@@ -1116,7 +1116,9 @@ function renderSaveMenu() {
|
||||
const heights = caps.heights.length ? caps.heights.filter((x) => x >= 360) : [2160, 1440, 1080, 720, 480];
|
||||
const vid = h("div", {},
|
||||
h("div", { class: "chips" }, h("button", { class: "chip", "aria-pressed": String(s.videoHeight === 0), onclick: () => patchSave({ videoHeight: 0 }) }, "Best"), ...heights.map((x) => h("button", { class: "chip", "aria-pressed": String(s.videoHeight === x), onclick: () => patchSave({ videoHeight: x }) }, `${x}p`))),
|
||||
h("div", { class: "chips" }, ...["mp4", "mkv"].map((k) => h("button", { class: "chip", "aria-pressed": String(s.videoContainer === k), onclick: () => patchSave({ videoContainer: k }) }, k.toUpperCase())))
|
||||
h("div", { class: "chips" }, ...["mp4", "mkv"].map((k) => h("button", { class: "chip", "aria-pressed": String(s.videoContainer === k), onclick: () => patchSave({ videoContainer: k }) }, k.toUpperCase()))),
|
||||
h("label", { class: "keep-audio" }, h("input", { type: "checkbox", class: "switch", checked: s.videoKeepAudio !== false, onchange: (e) => patchSave({ videoKeepAudio: e.target.checked }) }),
|
||||
h("span", {}, h("strong", {}, "Also keep an audio file"), h("small", {}, "Recommended. Play it as a song, and switch to the video at the same moment any time.")))
|
||||
);
|
||||
const lossless = h("div", { class: "chips" }, ...["flac", "wav"].map((k) => h("button", { class: "chip", "aria-pressed": String(s.saveAs === k), onclick: () => patchSave({ saveAs: k }) }, k.toUpperCase())));
|
||||
const noFf = !state.tools?.ffmpeg.path;
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
@@ -342,6 +342,7 @@
|
||||
<button class="icon-btn" id="lyricsBtn" aria-label="Lyrics" aria-pressed="false" title="Lyrics (L)"><span class="i" data-icon="microphone"></span></button>
|
||||
<button class="icon-btn" id="queueBtn" aria-label="Queue" aria-pressed="false" title="Queue (Q)"><span class="i" data-icon="list"></span></button>
|
||||
<button class="icon-btn" id="sleepBtn" aria-label="Sleep timer" aria-pressed="false" title="Sleep timer" aria-haspopup="menu"><span class="i" data-icon="moon"></span></button>
|
||||
<button class="icon-btn" id="videoBtn" aria-label="Show the music video" aria-pressed="false" title="Music video (V)" hidden><span class="i" data-icon="video"></span></button>
|
||||
<button class="icon-btn" id="miniBtn" aria-label="Mini player" title="Mini player (P)"><span class="i" data-icon="picture-in-picture"></span></button>
|
||||
<button class="icon-btn" id="tvBtn" aria-label="TV mode" title="TV mode (F)"><span class="i" data-icon="device-tv"></span></button>
|
||||
<button class="icon-btn" id="muteBtn" aria-label="Mute"></button>
|
||||
|
||||
+1
-1
@@ -202,7 +202,7 @@ function trackRow(t, i, ctx) {
|
||||
h("span", { class: "lt-num" }, playing ? eqBars() : label,
|
||||
h("button", { class: "lt-play", "aria-label": `Play ${t.title}`, onclick: (e) => { e.stopPropagation(); playList(ctx.list, i); } }, icon("player-play-filled"))),
|
||||
ctx.cover ? cover(t.art, "lt-cover") : null,
|
||||
h("div", { class: "lt-main" }, h("span", { class: "lt-title" }, t.title), ctx.hideArtist && !ctx.showArtistFor?.(t) ? null : h("span", { class: "lt-sub" }, artistLinks(t))),
|
||||
h("div", { class: "lt-main" }, h("span", { class: "lt-title" }, t.title, t.video ? h("span", { class: "badge-video", title: "Has a music video" }, icon("video")) : null), ctx.hideArtist && !ctx.showArtistFor?.(t) ? null : h("span", { class: "lt-sub" }, artistLinks(t))),
|
||||
ctx.hideAlbum ? h("span") : h("span", { class: "lt-album" }, t.album ? h("button", { class: "link", onclick: (e) => { e.stopPropagation(); openLib("album", `${lnorm(t.albumArtist || primaryArtist(t.artist))}|${lnorm(t.album)}`); } }, t.album) : ""),
|
||||
likeBtn(t),
|
||||
h("span", { class: "lt-dur" }, fmtDur(t.durationMs)),
|
||||
|
||||
+33
-1
@@ -206,9 +206,14 @@ function renderTv() {
|
||||
tv.classList.toggle("no-lyrics", !showCol);
|
||||
const note = !t ? null : Lyr.loading ? null : l?.instrumental ? "Instrumental" : !hasLyrics ? (Lyr.error ? "Lyrics sources unreachable" : "No lyrics found for this song") : `Lyrics · ${l.provider}`;
|
||||
const bg = t?.art ? `background-image:url("${artUrl(t.art)}")` : "";
|
||||
const withVideo = !!(t?.video && Player.showVideo);
|
||||
tv.classList.toggle("video", withVideo);
|
||||
const layer = withVideo ? h("video", { class: "tv-video", id: "tvVideo", src: mediaUrl("v", t.id), playsinline: true, preload: "auto" }) : h("div", { class: "tv-bg", style: bg });
|
||||
if (withVideo) layer.muted = true;
|
||||
tv.replaceChildren(
|
||||
h("div", { class: "tv-bg", style: bg }),
|
||||
layer,
|
||||
h("button", { class: "icon-btn tv-close", "aria-label": "Exit TV mode", onclick: closeTv }, icon("minimize")),
|
||||
t?.video ? h("button", { class: `btn small tv-video-btn ${withVideo ? "on" : ""}`, onclick: () => { Player.showVideo = !Player.showVideo; renderTv(); updatePlayerBar(); } }, icon(withVideo ? "photo" : "video"), withVideo ? "Show cover" : "Show video") : null,
|
||||
h("div", { class: "tv-stage" },
|
||||
h("div", { class: "tv-now" },
|
||||
t ? cover(t.art, "tv-cover", t.album || t.title) : h("div", { class: "tv-cover ph" }, icon("music")),
|
||||
@@ -225,6 +230,33 @@ function renderTv() {
|
||||
);
|
||||
Lyr.active = -1;
|
||||
startTick();
|
||||
if (withVideo) {
|
||||
layer.addEventListener("loadedmetadata", syncVideo, { once: true });
|
||||
syncVideo();
|
||||
}
|
||||
}
|
||||
|
||||
function syncVideo() {
|
||||
const v = $("#tvVideo");
|
||||
if (!v) return;
|
||||
const a = Player.audio;
|
||||
v.playbackRate = a.playbackRate || 1;
|
||||
if (v.readyState >= 1 && Math.abs(v.currentTime - a.currentTime) > 0.25) v.currentTime = Math.min(a.currentTime, Math.max(0, (v.duration || a.currentTime) - 0.05));
|
||||
if (a.paused && !v.paused) v.pause();
|
||||
else if (!a.paused && v.paused) v.play().catch(() => {});
|
||||
}
|
||||
|
||||
function toggleVideo() {
|
||||
if (!Player.current?.video) return;
|
||||
if (Lyr.tv && Player.showVideo) {
|
||||
Player.showVideo = false;
|
||||
renderTv();
|
||||
} else {
|
||||
Player.showVideo = true;
|
||||
if (Lyr.tv) renderTv();
|
||||
else openTv();
|
||||
}
|
||||
updatePlayerBar();
|
||||
}
|
||||
|
||||
function drawViz() {
|
||||
|
||||
@@ -11,6 +11,8 @@ function rangeFill(el) {
|
||||
function updatePlayerBar() {
|
||||
const t = Player.current;
|
||||
$("#player").classList.toggle("idle", !t);
|
||||
$("#videoBtn").hidden = !t?.video;
|
||||
$("#videoBtn").setAttribute("aria-pressed", String(!!(t?.video && Player.showVideo && Lyr.tv)));
|
||||
$("#npArt").replaceChildren(t ? cover(t.art, "np-cover", t.album || t.title) : h("div", { class: "np-cover ph" }, icon("music")));
|
||||
$("#npTitle").textContent = t ? t.title : "Nothing playing";
|
||||
$("#npArtist").replaceChildren(t ? artistLinks(t) : h("span", { class: "muted" }, "Pick something from your library"));
|
||||
@@ -301,9 +303,11 @@ function bindPlayer() {
|
||||
$("#queueBtn").addEventListener("click", () => toggleDrawer("#queuePanel", "#queueBtn", renderQueue));
|
||||
$("#lyricsBtn").addEventListener("click", () => toggleDrawer("#lyricsPanel", "#lyricsBtn", renderLyricsPanel));
|
||||
$("#tvBtn").addEventListener("click", (e) => chooseTvScreen(e.currentTarget));
|
||||
$("#videoBtn").addEventListener("click", toggleVideo);
|
||||
document.addEventListener("click", (e) => { if (e.target.isConnected && !$("#fxPanel").hidden && !e.target.closest("#fxPanel, #fxBtn, .modal-wrap")) closeFx(); });
|
||||
window.addEventListener("player", (e) => {
|
||||
const type = e.detail.type;
|
||||
if (Lyr.tv && type !== "volume" && type !== "fx") syncVideo();
|
||||
if (type === "time") return updateTime();
|
||||
if (type === "volume") return updateVolume();
|
||||
if (type === "fx") return $("#fxBtn").setAttribute("aria-pressed", String(fxActive()));
|
||||
@@ -325,6 +329,7 @@ function bindPlayer() {
|
||||
else if (k.toLowerCase() === "l" && !mod) $("#lyricsBtn").click();
|
||||
else if (k.toLowerCase() === "q" && !mod) $("#queueBtn").click();
|
||||
else if (k.toLowerCase() === "f" && !mod) openTv();
|
||||
else if (k.toLowerCase() === "v" && !mod && Player.current?.video) toggleVideo();
|
||||
});
|
||||
updatePlayerBar();
|
||||
updateTime();
|
||||
|
||||
@@ -1170,3 +1170,16 @@ body.mini-mode > *:not(#mini):not(.toasts):not(.modal-wrap):not(script) { displa
|
||||
.move-paths { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: var(--s2); align-items: center; }
|
||||
.move-paths code { font-size: 12px; padding: 6px 8px; border-radius: 8px; background: var(--surface-2, var(--surface)); border: 1px solid var(--hairline); overflow-wrap: anywhere; }
|
||||
.move-paths .i { color: var(--text-3); }
|
||||
|
||||
/* music videos */
|
||||
.tv-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; z-index: 0; }
|
||||
.tv.video .tv-stage { background: linear-gradient(90deg, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.15) 45%, rgba(0, 0, 0, 0)); }
|
||||
.tv.video .tv-now .tv-cover { display: none; }
|
||||
.tv-video-btn { position: absolute; top: 18px; right: 64px; z-index: 3; background: rgba(10, 12, 18, 0.55); color: #fff; border-color: rgba(255, 255, 255, 0.18); }
|
||||
.tv-video-btn.on { background: rgba(255, 255, 255, 0.16); }
|
||||
.badge-video { display: inline-grid; place-items: center; margin-left: 6px; vertical-align: -2px; color: var(--text-3); }
|
||||
.badge-video .i svg { width: 14px; height: 14px; }
|
||||
#videoBtn[aria-pressed="true"] { color: var(--accent); }
|
||||
.keep-audio { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s3); align-items: start; margin-top: var(--s3); cursor: pointer; }
|
||||
.keep-audio span { display: grid; gap: 2px; }
|
||||
.keep-audio small { color: var(--text-3); font-size: 11.5px; line-height: 1.4; }
|
||||
|
||||
Reference in New Issue
Block a user