diff --git a/README.md b/README.md index b637d3e..a8443c5 100644 --- a/README.md +++ b/README.md @@ -31,8 +31,8 @@ findest du in der Kategorie **Playtube**. Das Skript installiert auch das Icon-P | Lauter / Leiser | Schrittweite einstellbar, gedrückt halten wiederholt | | Lautstärke setzen | Feste Lautstärke | | Stumm | Ton aus/ein, zeigt die Lautstärke | -| Aktueller Titel | Cover und Titel; auf dem Info-Display eine große Karte mit Interpret und Fortschritt | -| Gefällt mir, Zufall, Wiederholen | Umschalten, Symbol zeigt den Zustand | +| Aktueller Titel | Cover und Titel, oben ein Fortschrittsbalken (abschaltbar); auf dem Info-Display eine große Karte mit Interpret und Fortschritt | +| Gefällt mir, Gefällt mir nicht, Zufall, Wiederholen | Umschalten, Symbol zeigt den Zustand | | Playlist abspielen | Playlist aus YouTube Music wählen (Liste wird von Playtube geladen); die Taste zeigt das Cover der Playlist (ab Playtube 2.12.0, sonst den Namen) | | Tab wechseln / Playtube anzeigen | YouTube ↔ YouTube Music, Fenster nach vorn | diff --git a/com.fojadrachi.playtube.sdPlugin/de.json b/com.fojadrachi.playtube.sdPlugin/de.json index 2723b4d..324942c 100644 --- a/com.fojadrachi.playtube.sdPlugin/de.json +++ b/com.fojadrachi.playtube.sdPlugin/de.json @@ -46,6 +46,10 @@ "Name": "Gefällt mir", "Tooltip": "Aktuellen Titel mit „Gefällt mir“ markieren" }, + "com.fojadrachi.playtube.dislike": { + "Name": "Gefällt mir nicht", + "Tooltip": "Aktuellen Titel mit „Gefällt mir nicht“ markieren" + }, "com.fojadrachi.playtube.shuffle": { "Name": "Zufallswiedergabe", "Tooltip": "Zufallswiedergabe umschalten" diff --git a/com.fojadrachi.playtube.sdPlugin/en.json b/com.fojadrachi.playtube.sdPlugin/en.json index 1c485e2..218bc51 100644 --- a/com.fojadrachi.playtube.sdPlugin/en.json +++ b/com.fojadrachi.playtube.sdPlugin/en.json @@ -46,6 +46,10 @@ "Name": "Like", "Tooltip": "Like the current track" }, + "com.fojadrachi.playtube.dislike": { + "Name": "Dislike", + "Tooltip": "Dislike the current track" + }, "com.fojadrachi.playtube.shuffle": { "Name": "Shuffle", "Tooltip": "Toggle shuffle" diff --git a/com.fojadrachi.playtube.sdPlugin/manifest.json b/com.fojadrachi.playtube.sdPlugin/manifest.json index ba7a727..ae36270 100644 --- a/com.fojadrachi.playtube.sdPlugin/manifest.json +++ b/com.fojadrachi.playtube.sdPlugin/manifest.json @@ -285,6 +285,37 @@ "UUID": "com.fojadrachi.playtube.like", "PropertyInspectorPath": "propertyInspector/index.html" }, + { + "Icon": "static/icon/dislike@2x.png", + "Name": "Dislike", + "DisableAutomaticStates": true, + "States": [ + { + "Image": "static/btn/dislike_0.png", + "TitleAlignment": "bottom", + "FontSize": "11", + "FontStyle": "Bold", + "TitleColor": "#ffffff" + }, + { + "Image": "static/btn/dislike_1.png", + "TitleAlignment": "bottom", + "FontSize": "11", + "FontStyle": "Bold", + "TitleColor": "#ffffff" + } + ], + "Settings": {}, + "Controllers": [ + "Keypad", + "Information" + ], + "UserTitleEnabled": false, + "SupportedInMultiActions": true, + "Tooltip": "Dislike the current track", + "UUID": "com.fojadrachi.playtube.dislike", + "PropertyInspectorPath": "propertyInspector/index.html" + }, { "Icon": "static/icon/shuffle@2x.png", "Name": "Shuffle", @@ -428,7 +459,7 @@ "Description": "Control Playtube (YouTube / YouTube Music) from your Stream Dock", "Category": "Playtube", "CategoryIcon": "static/icon/icon@2x.png", - "Version": "1.1.0", + "Version": "1.2.0", "OS": [ { "Platform": "windows", diff --git a/com.fojadrachi.playtube.sdPlugin/plugin/index.js b/com.fojadrachi.playtube.sdPlugin/plugin/index.js index e47cc8e..bb20e74 100644 --- a/com.fojadrachi.playtube.sdPlugin/plugin/index.js +++ b/com.fojadrachi.playtube.sdPlugin/plugin/index.js @@ -4030,8 +4030,10 @@ var require_actions = __commonJS({ playlistTitle: "", playlistCover: "", // Cover-Adresse, von Playtube geholt (Befehl "playlist_cover") - playlistCoverId: "" + playlistCoverId: "", // zu welcher Playlist das gespeicherte Cover gehoert + showProgress: true + // "Aktueller Titel": Fortschrittsbalken ueber dem Cover }); var TARGETS = ["auto", "youtube", "music"]; var TABS = ["toggle", "youtube", "music"]; @@ -4049,6 +4051,8 @@ var require_actions = __commonJS({ settings.seconds = clampInt(settings.seconds, 1, 300, DEFAULTS.seconds); const show = raw && raw.showTitle !== void 0 ? raw.showTitle : titleDefault; settings.showTitle = show === true || show === "true"; + const progress = raw && raw.showProgress !== void 0 ? raw.showProgress : DEFAULTS.showProgress; + settings.showProgress = progress === true || progress === "true"; settings.playlistId = typeof settings.playlistId === "string" ? settings.playlistId.trim() : ""; settings.playlistTitle = typeof settings.playlistTitle === "string" ? settings.playlistTitle : ""; const cover = typeof settings.playlistCover === "string" ? settings.playlistCover : ""; @@ -4153,9 +4157,13 @@ var require_actions = __commonJS({ if (!connected) return { coverUrl: null, title: s.showTitle ? OFFLINE_TITLE : "" }; const tab = pickTab(state, s.target); const info = tab && tab.info; + const duration = info && Number(info.duration); + const current = info && Number(info.currentTime); return { coverUrl: info && info.hasVideo && info.thumbnail ? info.thumbnail : null, - title: s.showTitle && info && info.title ? wrapTitle(info.title) : "" + title: s.showTitle && info && info.title ? wrapTitle(info.title) : "", + // Anteil 0..1 (auf Prozent gerundet, damit nicht jede Sekunde ein neues Bild noetig ist). + progress: s.showProgress && duration > 0 && Number.isFinite(current) ? Math.round(Math.max(0, Math.min(1, current / duration)) * 100) / 100 : null }; } }, @@ -4166,6 +4174,13 @@ var require_actions = __commonJS({ return { state: tab && tab.info.likeStatus === "like" ? 1 : 0 }; } }, + dislike: { + request: (s) => ({ cmd: "dislike", fields: { target: s.target } }), + render: (s, state, connected) => { + const tab = connected ? pickTab(state, s.target) : null; + return { state: tab && tab.info.likeStatus === "dislike" ? 1 : 0 }; + } + }, shuffle: { request: (s) => ({ cmd: "shuffle", fields: { target: s.target } }) }, repeat: { request: (s) => ({ cmd: "repeat", fields: { target: s.target } }), @@ -4300,10 +4315,14 @@ var require_infoPanel = __commonJS({ parts.push(``); return `${head}${parts.join("")}`; } + function buildCoverProgressSvg(coverDataUri, ratio) { + const clamped = Math.max(0, Math.min(1, Number(ratio) || 0)); + return ``; + } function svgToDataUri(svg) { return `data:image/svg+xml;base64,${Buffer.from(svg, "utf8").toString("base64")}`; } - module2.exports = { buildInfoSvg, svgToDataUri, formatTime, SIZE }; + module2.exports = { buildInfoSvg, buildCoverProgressSvg, svgToDataUri, formatTime, SIZE }; } }); @@ -4320,7 +4339,7 @@ var require_controller = __commonJS({ pickTab, renderAction } = require_actions(); - var { buildInfoSvg, svgToDataUri } = require_infoPanel(); + var { buildInfoSvg, buildCoverProgressSvg, svgToDataUri } = require_infoPanel(); var POLL_INTERVAL_MS = 1e3; var REFRESH_AFTER_COMMAND_MS = 350; var COVER_CACHE_LIMIT = 24; @@ -4532,13 +4551,17 @@ var require_controller = __commonJS({ const coverUrl = view.coverUrl ? sharpCoverUrl(view.coverUrl) : null; const cover = coverUrl ? this.covers.get(coverUrl) || null : null; if (coverUrl && !cover) this.loadCover(coverUrl); - const next = { state: view.state, title: view.title, cover: cover ? coverUrl : null }; + const progress = cover && typeof view.progress === "number" ? view.progress : null; + const next = { state: view.state, title: view.title, cover: cover ? coverUrl : null, progress }; const previous = key.last || {}; const changed = (name) => previous[name] !== next[name]; key.last = next; if (view.state !== void 0 && changed("state")) this.host.setState(context, view.state); if (view.title !== void 0 && changed("title")) this.host.setTitle(context, view.title); - if (view.coverUrl !== void 0 && changed("cover")) this.host.setImage(context, cover); + if (view.coverUrl !== void 0 && (changed("cover") || changed("progress"))) { + const image = cover && progress !== null ? svgToDataUri(buildCoverProgressSvg(cover, progress)) : cover; + this.host.setImage(context, image); + } } /** Hohes Info-Display: komplette "Aktueller Titel"-Karte als SVG-Bild. */ renderInfo(context, key) { diff --git a/com.fojadrachi.playtube.sdPlugin/propertyInspector/index.html b/com.fojadrachi.playtube.sdPlugin/propertyInspector/index.html index 5d29eb5..519c1d7 100644 --- a/com.fojadrachi.playtube.sdPlugin/propertyInspector/index.html +++ b/com.fojadrachi.playtube.sdPlugin/propertyInspector/index.html @@ -74,6 +74,10 @@ +