From 2d789147c058956458aa0e23df2b7edf9a2f5833 Mon Sep 17 00:00:00 2001
From: koolskateguy89 <61889617+koolskateguy89@users.noreply.github.com>
Date: Sat, 20 Aug 2022 17:09:41 +0100
Subject: [PATCH] :bookmark: V13
---
.../extension.js | 9 +
.../mediaPlayer.js | 227 +++++++++---------
.../metadata.json | 2 +-
3 files changed, 126 insertions(+), 112 deletions(-)
diff --git a/spotify-controller@koolskateguy89/extension.js b/spotify-controller@koolskateguy89/extension.js
index ac74268..8bb87ab 100644
--- a/spotify-controller@koolskateguy89/extension.js
+++ b/spotify-controller@koolskateguy89/extension.js
@@ -161,6 +161,12 @@ class Toggle extends St.Icon {
const ControlBar = GObject.registerClass(
class ControlBar extends PanelMenu.Button {
+ previous;
+ next;
+ toggle;
+ buttons;
+ bar;
+
_init(spotify) {
super._init();
@@ -214,6 +220,9 @@ class ControlBar extends PanelMenu.Button {
});
class Extension {
+ spotify;
+ controlBar;
+
constructor() {
}
diff --git a/spotify-controller@koolskateguy89/mediaPlayer.js b/spotify-controller@koolskateguy89/mediaPlayer.js
index 4eb01bc..8148c99 100644
--- a/spotify-controller@koolskateguy89/mediaPlayer.js
+++ b/spotify-controller@koolskateguy89/mediaPlayer.js
@@ -1,111 +1,116 @@
-const { Gio } = imports.gi;
-
-// thanks esenliyim - https://github.com/esenliyim/sp-tray/blob/master/panelButton.js
-// https://wiki.gnome.org/Gjs/Examples/DBusClient
-// https://www.andyholmes.ca/articles/dbus-in-gjs.html#high-level-proxies
-const path = '/org/mpris/MediaPlayer2';
-const playerInterface = `
-
-
-
-
-
-
-
-
-`;
-
-// Declare the proxy class based on the interface
-const PlayerProxy = Gio.DBusProxy.makeProxyWrapper(playerInterface);
-
-/**
- * A Gio.DBuxProxy of the `org.mpris.MediaPlayer2.Player` interface.
- * @typedef {Object} MediaPlayerProxy
- * @property {string} PlaybackStatus
- */
-
-/**
- * @callback playerConsumer
- * @param {MediaPlayer} player
- */
-
-/**
- * A non-player specific wrapper of a proxy for a media player.
- * @todo Write the documentation.
- */
-class MediaPlayer {
- /**
- * @param {playerConsumer=} onAppeared
- * @param {playerConsumer=} onVanished
- * @param {playerConsumer=} onPropertiesChanged
- */
- constructor(onAppeared, onVanished, onPropertiesChanged) {
- this.onAppeared = onAppeared;
- this.onVanished = onVanished;
- this.onPropertiesChanged = onPropertiesChanged;
-
- this.proxy = null;
- this.proxySignals = [];
- }
-
- /**
- * @param {string} dest - The well-known name
- */
- setupProxy(dest = 'org.mpris.MediaPlayer2.spotify') {
- if (this.proxy)
- return;
-
- try {
- // Get the MediaPlayer instance from the bus
- this.proxy = new PlayerProxy(Gio.DBus.session, dest, path);
- } catch (e) {
- logError(e);
- return;
- }
-
- this.proxySignals.push(this.proxy.connect(
- "g-properties-changed",
- (proxy, changed, invalidated) => {
- this.onPropertiesChanged?.(this);
- }
- ));
-
- // https://www.andyholmes.ca/articles/dbus-in-gjs.html#low-level-proxies
- this.proxySignals.push(this.proxy.connect(
- "notify::g-name-owner",
- (proxy, pspec) => {
- if (proxy.g_name_owner === null) {
- log(`${proxy.g_name} has vanished`);
- this.onVanished?.(this);
- } else {
- log(`${proxy.g_name} has appeared`);
- this.onAppeared?.(this);
- }
- }
- ));
- }
-
- destroy() {
- this.proxySignals.forEach(signal => this.proxy.disconnect(signal));
- }
-
- get isActive() {
- return this.proxy.g_name_owner !== null;
- }
-
- get isPlaying() {
- return this.isActive && this.proxy.PlaybackStatus === 'Playing';
- }
-
- next() {
- this.proxy.NextSync();
- }
-
- previous() {
- this.proxy.PreviousSync();
- }
-
- playPause() {
- this.proxy.PlayPauseSync();
- }
-}
+const { Gio } = imports.gi;
+
+// thanks esenliyim - https://github.com/esenliyim/sp-tray/blob/master/panelButton.js
+// https://wiki.gnome.org/Gjs/Examples/DBusClient
+// https://www.andyholmes.ca/articles/dbus-in-gjs.html#high-level-proxies
+const path = '/org/mpris/MediaPlayer2';
+const playerInterface = `
+
+
+
+
+
+
+
+
+`;
+
+// Declare the proxy class based on the interface
+const PlayerProxy = Gio.DBusProxy.makeProxyWrapper(playerInterface);
+
+/**
+ * A Gio.DBuxProxy of the `org.mpris.MediaPlayer2.Player` interface.
+ * @typedef {Object} MediaPlayerProxy
+ * @property {string} PlaybackStatus
+ */
+
+/**
+ * @callback playerConsumer
+ * @param {MediaPlayer} player
+ */
+
+/**
+ * A non-player specific wrapper of a proxy for a media player.
+ * @todo Write the documentation.
+ */
+class MediaPlayer {
+ // this.onAppeared = onAppeared;
+ // this.onVanished = onVanished;
+ // this.onPropertiesChanged = onPropertiesChanged;
+
+
+ /**
+ * @param {playerConsumer=} onAppeared
+ * @param {playerConsumer=} onVanished
+ * @param {playerConsumer=} onPropertiesChanged
+ */
+ constructor(onAppeared, onVanished, onPropertiesChanged) {
+ this.onAppeared = onAppeared;
+ this.onVanished = onVanished;
+ this.onPropertiesChanged = onPropertiesChanged;
+
+ this.proxy = null;
+ this.proxySignals = [];
+ }
+
+ /**
+ * @param {string} dest - The well-known name
+ */
+ setupProxy(dest = 'org.mpris.MediaPlayer2.spotify') {
+ if (this.proxy)
+ return;
+
+ try {
+ // Get the MediaPlayer instance from the bus
+ this.proxy = new PlayerProxy(Gio.DBus.session, dest, path);
+ } catch (e) {
+ logError(e);
+ return;
+ }
+
+ this.proxySignals.push(this.proxy.connect(
+ "g-properties-changed",
+ (proxy, changed, invalidated) => {
+ this.onPropertiesChanged?.(this);
+ }
+ ));
+
+ // https://www.andyholmes.ca/articles/dbus-in-gjs.html#low-level-proxies
+ this.proxySignals.push(this.proxy.connect(
+ "notify::g-name-owner",
+ (proxy, pspec) => {
+ if (proxy.g_name_owner === null) {
+ log(`${proxy.g_name} has vanished`);
+ this.onVanished?.(this);
+ } else {
+ log(`${proxy.g_name} has appeared`);
+ this.onAppeared?.(this);
+ }
+ }
+ ));
+ }
+
+ destroy() {
+ this.proxySignals.forEach(signal => this.proxy.disconnect(signal));
+ }
+
+ get isActive() {
+ return this.proxy.g_name_owner !== null;
+ }
+
+ get isPlaying() {
+ return this.isActive && this.proxy.PlaybackStatus === 'Playing';
+ }
+
+ next() {
+ this.proxy.NextSync();
+ }
+
+ previous() {
+ this.proxy.PreviousSync();
+ }
+
+ playPause() {
+ this.proxy.PlayPauseSync();
+ }
+}
diff --git a/spotify-controller@koolskateguy89/metadata.json b/spotify-controller@koolskateguy89/metadata.json
index 4ec50f9..cf78a7b 100644
--- a/spotify-controller@koolskateguy89/metadata.json
+++ b/spotify-controller@koolskateguy89/metadata.json
@@ -11,5 +11,5 @@
"settings-schema": "org.gnome.shell.extensions.spotify-controller",
"url": "https://github.com/koolskateguy89/gnome-shell-extension-spotify-controller",
"uuid": "spotify-controller@koolskateguy89",
- "version": 12
+ "version": 13
}