Merge branch 'ciderapp:develop' into develop
|
@ -101,7 +101,7 @@ export default class Thumbar {
|
||||||
{
|
{
|
||||||
label: 'Pause / Play',
|
label: 'Pause / Play',
|
||||||
accelerator: 'Space',
|
accelerator: 'Space',
|
||||||
click: () => this._win.webContents.executeJavaScript(`MusicKitInterop.playPause()`)
|
click: () => this._win.webContents.executeJavaScript(`app.SpacePause()`)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Next',
|
label: 'Next',
|
||||||
|
|
|
@ -28,13 +28,13 @@ export default class WebNowPlaying {
|
||||||
*/
|
*/
|
||||||
public name: string = 'WebNowPlaying';
|
public name: string = 'WebNowPlaying';
|
||||||
public description: string = 'Song info and playback control for the Rainmeter WebNowPlaying plugin.';
|
public description: string = 'Song info and playback control for the Rainmeter WebNowPlaying plugin.';
|
||||||
public version: string = '1.0.0';
|
public version: string = '1.0.1';
|
||||||
public author: string = 'Zennn <me@jozen.blue>';
|
public author: string = 'Zennn <me@jozen.blue>';
|
||||||
|
|
||||||
private _win: any;
|
private _win: any;
|
||||||
private ws: any = null;
|
private ws?: WebSocket;
|
||||||
private wsapiConn: any = null;
|
private wsapiConn?: WebSocket;
|
||||||
private playerName: string = 'Cider'/* Apple Music */;
|
private playerName: string = 'Cider';
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
console.debug(`[Plugin][${this.name}] Loading Complete.`);
|
console.debug(`[Plugin][${this.name}] Loading Complete.`);
|
||||||
|
@ -47,9 +47,7 @@ export default class WebNowPlaying {
|
||||||
*/
|
*/
|
||||||
private static windowsOnly(_target: any, _propertyKey: string, descriptor: PropertyDescriptor) {
|
private static windowsOnly(_target: any, _propertyKey: string, descriptor: PropertyDescriptor) {
|
||||||
if (process.platform !== 'win32') {
|
if (process.platform !== 'win32') {
|
||||||
descriptor.value = function () {
|
descriptor.value = () => void 0;
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,22 +90,25 @@ export default class WebNowPlaying {
|
||||||
value = attributes.shuffleMode;
|
value = attributes.shuffleMode;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
this.ws.send(`${field}:${value}`);
|
this.ws?.send(`${field}:${value}`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (this.ws.readyState === WebSocket.OPEN) {
|
if (this.ws?.readyState === WebSocket.OPEN) {
|
||||||
this.ws.send(`Error:Error updating ${field} for ${this.playerName}`);
|
this.ws.send(`Error:Error updating ${field} for ${this.playerName}`);
|
||||||
this.ws.send(`ErrorD:${error}`);
|
this.ws.send(`ErrorD:${error}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
private fireEvent(evt: any) {
|
|
||||||
|
private fireEvent(evt: WebSocket.MessageEvent) {
|
||||||
if (!evt.data) return;
|
if (!evt.data) return;
|
||||||
let value = '';
|
const data = <string>evt.data;
|
||||||
if (evt.data.split(/ (.+)/).length > 1) {
|
|
||||||
value = evt.data.split(/ (.+)/)[1];
|
let value: string = '';
|
||||||
|
if (data.split(/ (.+)/).length > 1) {
|
||||||
|
value = data.split(/ (.+)/)[1];
|
||||||
}
|
}
|
||||||
const eventName = evt.data.split(' ')[0].toLowerCase();
|
const eventName = data.split(' ')[0].toLowerCase();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
switch (eventName) {
|
switch (eventName) {
|
||||||
|
@ -144,7 +145,7 @@ export default class WebNowPlaying {
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.debug(error);
|
console.debug(error);
|
||||||
if (this.ws.readyState === WebSocket.OPEN) {
|
if (this.ws?.readyState === WebSocket.OPEN) {
|
||||||
this.ws.send(`Error:Error sending event to ${this.playerName}`);
|
this.ws.send(`Error:Error sending event to ${this.playerName}`);
|
||||||
this.ws.send(`ErrorD:${error}`);
|
this.ws.send(`ErrorD:${error}`);
|
||||||
}
|
}
|
||||||
|
@ -163,10 +164,10 @@ export default class WebNowPlaying {
|
||||||
try {
|
try {
|
||||||
this.ws = new WebSocket('ws://127.0.0.1:8974/');
|
this.ws = new WebSocket('ws://127.0.0.1:8974/');
|
||||||
let retry: NodeJS.Timeout;
|
let retry: NodeJS.Timeout;
|
||||||
this.ws.onopen = (() => {
|
this.ws.onopen = () => {
|
||||||
console.info('[WebNowPlaying] Connected to Rainmeter');
|
console.info('[WebNowPlaying] Connected to Rainmeter');
|
||||||
this.ws.send(`PLAYER:${this.playerName}`);
|
this.ws?.send(`PLAYER:${this.playerName}`);
|
||||||
}).bind(this);
|
};
|
||||||
|
|
||||||
this.ws.onclose = () => {
|
this.ws.onclose = () => {
|
||||||
clearTimeout(retry);
|
clearTimeout(retry);
|
||||||
|
@ -175,7 +176,7 @@ export default class WebNowPlaying {
|
||||||
|
|
||||||
this.ws.onerror = () => {
|
this.ws.onerror = () => {
|
||||||
clearTimeout(retry);
|
clearTimeout(retry);
|
||||||
this.ws.close();
|
this.ws?.close();
|
||||||
};
|
};
|
||||||
|
|
||||||
this.ws.onmessage = this.fireEvent?.bind(this);
|
this.ws.onmessage = this.fireEvent?.bind(this);
|
||||||
|
@ -194,8 +195,8 @@ export default class WebNowPlaying {
|
||||||
console.info('[WebNowPlaying] Connected to wsapi');
|
console.info('[WebNowPlaying] Connected to wsapi');
|
||||||
};
|
};
|
||||||
|
|
||||||
this.wsapiConn.onmessage = (evt: { data: string; }) => {
|
this.wsapiConn.onmessage = (evt: WebSocket.MessageEvent) => {
|
||||||
const response = JSON.parse(evt.data);
|
const response = JSON.parse(<string>evt.data);
|
||||||
if (response.type === 'playbackStateUpdate') {
|
if (response.type === 'playbackStateUpdate') {
|
||||||
this.sendSongInfo(response.data);
|
this.sendSongInfo(response.data);
|
||||||
}
|
}
|
||||||
|
@ -214,7 +215,7 @@ export default class WebNowPlaying {
|
||||||
public onBeforeQuit() {
|
public onBeforeQuit() {
|
||||||
if (this.ws) {
|
if (this.ws) {
|
||||||
this.ws.send('STATE:0');
|
this.ws.send('STATE:0');
|
||||||
this.ws.onclose = null; // disable onclose handler first to stop it from retrying
|
this.ws.onclose = () => void 0; // disable onclose handler first to stop it from retrying
|
||||||
this.ws.close();
|
this.ws.close();
|
||||||
}
|
}
|
||||||
if (this.wsapiConn) {
|
if (this.wsapiConn) {
|
||||||
|
@ -227,7 +228,8 @@ export default class WebNowPlaying {
|
||||||
* Runs on playback State Change
|
* Runs on playback State Change
|
||||||
* @param attributes Music Attributes (attributes.status = current state)
|
* @param attributes Music Attributes (attributes.status = current state)
|
||||||
*/
|
*/
|
||||||
onPlaybackStateDidChange(attributes: any) {
|
@WebNowPlaying.windowsOnly
|
||||||
|
public onPlaybackStateDidChange(attributes: any) {
|
||||||
this.sendSongInfo(attributes);
|
this.sendSongInfo(attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3572,6 +3572,27 @@ const app = new Vue({
|
||||||
darwinShare(url) {
|
darwinShare(url) {
|
||||||
ipcRenderer.send('share-menu', url)
|
ipcRenderer.send('share-menu', url)
|
||||||
},
|
},
|
||||||
|
SpacePause() {
|
||||||
|
const elems = document.querySelectorAll('input');
|
||||||
|
for (elem of elems){
|
||||||
|
if (elem === document.activeElement) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!this.isDev) // disable in dev mode to keep my sanity
|
||||||
|
MusicKitInterop.playPause();
|
||||||
|
},
|
||||||
|
MKJSLang(){
|
||||||
|
let u = this.cfg.general.language;
|
||||||
|
let langcodes = ['af', 'sq', 'ar', 'eu', 'bg', 'be', 'ca', 'zh', 'zh-tw', 'zh-cn', 'zh-hk', 'zh-sg', 'hr', 'cs', 'da', 'nl', 'nl-be', 'en', 'en-us', 'en-eg', 'en-au', 'en-gb', 'en-ca', 'en-nz', 'en-ie', 'en-za', 'en-jm', 'en-bz', 'en-tt', 'en-001', 'et', 'fo', 'fa', 'fi', 'fr', 'fr-ca', 'gd', 'de', 'de-ch', 'el', 'he', 'hi', 'hu', 'is', 'id', 'it', 'ja', 'ko', 'lv', 'lt', 'mk', 'mt', 'no', 'nb', 'nn', 'pl', 'pt-br', 'pt', 'rm', 'ro', 'ru', 'sr', 'sk', 'sl', 'es', 'es-mx', 'es-419', 'sv', 'th', 'ts', 'tn', 'tr', 'uk', 'ur', 've', 'vi', 'xh', 'yi', 'zu', 'ms', 'iw', 'lo', 'tl', 'kk', 'ta', 'te', 'bn', 'ga', 'ht', 'la', 'pa', 'sa'];
|
||||||
|
let sellang = "en"
|
||||||
|
if (u && langcodes.includes(u.toLowerCase().replace('_', "-"))) {
|
||||||
|
sellang = ((u.toLowerCase()).replace('_', "-"))
|
||||||
|
} else if (u && u.includes('_') && langcodes.includes(((u.toLowerCase()).replace('_', "-")).split("-")[0])) {
|
||||||
|
sellang = ((u.toLowerCase()).replace('_', "-")).split("-")[0]
|
||||||
|
}
|
||||||
|
return sellang
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,7 @@
|
||||||
<mediaitem-square :kind="'385'" size="600"
|
<mediaitem-square :kind="'385'" size="600"
|
||||||
:item="item ? (item.attributes.kind ? item : ((item.relationships && item.relationships.contents ) ? item.relationships.contents.data[0] : item)) : []"
|
:item="item ? (item.attributes.kind ? item : ((item.relationships && item.relationships.contents ) ? item.relationships.contents.data[0] : item)) : []"
|
||||||
:imagesize="800"
|
:imagesize="800"
|
||||||
v-for="item in categoriesView[1].relationships.contents.data.filter(item => item.type != 'editorial-items')">
|
v-for="item of getFlattenedCategories()">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -123,9 +123,22 @@
|
||||||
if (this.categoriesView != [] && this.categoriesView.length > 0) { this.categoriesReady = true; return await true; } else {
|
if (this.categoriesView != [] && this.categoriesView.length > 0) { this.categoriesReady = true; return await true; } else {
|
||||||
let response = await this.app.mk.api.v3.music(`/v1/recommendations/${this.app.mk.storefrontId}?timezone=${encodeURIComponent(this.app.formatTimezoneOffset())}&name=search-landing&platform=web&extend=editorialArtwork&art%5Burl%5D=f%2Cc&types=editorial-items%2Capple-curators%2Cactivities`);
|
let response = await this.app.mk.api.v3.music(`/v1/recommendations/${this.app.mk.storefrontId}?timezone=${encodeURIComponent(this.app.formatTimezoneOffset())}&name=search-landing&platform=web&extend=editorialArtwork&art%5Burl%5D=f%2Cc&types=editorial-items%2Capple-curators%2Cactivities`);
|
||||||
this.categoriesView = response.data.data;
|
this.categoriesView = response.data.data;
|
||||||
|
console.log(this.categoriesView)
|
||||||
this.categoriesReady = true;
|
this.categoriesReady = true;
|
||||||
return await true;
|
return await true;
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
getFlattenedCategories() {
|
||||||
|
let flattened = [];
|
||||||
|
for (let i = 0; i < this.categoriesView.length; i++) {
|
||||||
|
if (this.categoriesView[i].relationships && this.categoriesView[i].relationships.contents && this.categoriesView[i].relationships.contents.data) {
|
||||||
|
for (let j = 0; j < this.categoriesView[i].relationships.contents.data.length; j++) {
|
||||||
|
if (this.categoriesView[i].relationships.contents.data[j].type != 'editorial-items')
|
||||||
|
flattened.push(this.categoriesView[i].relationships.contents.data[j])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return flattened;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Before Width: | Height: | Size: 7.1 KiB After Width: | Height: | Size: 5.7 KiB |
Before Width: | Height: | Size: 9.8 KiB After Width: | Height: | Size: 7.7 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 17 KiB |