Plugin 1.2.0: Taste 'Gefaellt mir nicht', Fortschrittsbalken auf 'Aktueller Titel'
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
+16
-1
@@ -19,6 +19,7 @@ const DEFAULTS = Object.freeze({
|
||||
playlistTitle: '',
|
||||
playlistCover: '', // Cover-Adresse, von Playtube geholt (Befehl "playlist_cover")
|
||||
playlistCoverId: '', // zu welcher Playlist das gespeicherte Cover gehoert
|
||||
showProgress: true, // "Aktueller Titel": Fortschrittsbalken ueber dem Cover
|
||||
});
|
||||
|
||||
const TARGETS = ['auto', 'youtube', 'music'];
|
||||
@@ -40,6 +41,8 @@ function normalizeSettings(raw, titleDefault = false) {
|
||||
settings.seconds = clampInt(settings.seconds, 1, 300, DEFAULTS.seconds);
|
||||
const show = raw && raw.showTitle !== undefined ? raw.showTitle : titleDefault;
|
||||
settings.showTitle = show === true || show === 'true';
|
||||
const progress = raw && raw.showProgress !== undefined ? 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 : '';
|
||||
// Ein gespeichertes Cover gilt nur fuer die Playlist, fuer die es geholt wurde.
|
||||
@@ -104,7 +107,7 @@ const OFFLINE_TITLE = 'Playtube\noffline';
|
||||
/**
|
||||
* Definition pro Aktion. `id` = letzter Teil der UUID (siehe manifest.json).
|
||||
* - request(settings): {cmd, fields} oder null (Taste tut dann nichts, zeigt Alarm)
|
||||
* - render(settings, state, connected): {state?, title?, coverUrl?}
|
||||
* - render(settings, state, connected): {state?, title?, coverUrl?, progress?}
|
||||
* - press: "up" (Standard, beim Loslassen) oder "down" (sofort; mit repeat = Dauerdruck)
|
||||
*/
|
||||
const DEFINITIONS = {
|
||||
@@ -160,9 +163,14 @@ const DEFINITIONS = {
|
||||
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) : '',
|
||||
// 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,
|
||||
};
|
||||
},
|
||||
},
|
||||
@@ -173,6 +181,13 @@ const DEFINITIONS = {
|
||||
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 } }),
|
||||
|
||||
Reference in New Issue
Block a user