chore: Prettified Code
[ci skip]
This commit is contained in:
parent
a023bd619c
commit
c32b9b6d70
2 changed files with 57 additions and 58 deletions
|
@ -2,7 +2,7 @@ import * as electron from "electron";
|
|||
import * as os from "os";
|
||||
import { resolve } from "path";
|
||||
import * as CiderReceiver from "../base/castreceiver";
|
||||
const MediaRendererClient = require('upnp-mediarenderer-client')
|
||||
const MediaRendererClient = require("upnp-mediarenderer-client");
|
||||
|
||||
export default class ChromecastPlugin {
|
||||
/**
|
||||
|
@ -15,7 +15,6 @@ export default class ChromecastPlugin {
|
|||
private _timer: any;
|
||||
private audioClient = require("castv2-client").Client;
|
||||
private mdns = require("mdns-js");
|
||||
|
||||
|
||||
private devices: any = [];
|
||||
private castDevices: any = [];
|
||||
|
@ -71,15 +70,13 @@ export default class ChromecastPlugin {
|
|||
|
||||
// actual upnp devices
|
||||
let ssdpBrowser2 = new Client();
|
||||
ssdpBrowser2.on('response', (headers: any, statusCode: any, rinfo: any) => {
|
||||
var location = getLocation(headers);
|
||||
if (location != null) {
|
||||
this.getServiceDescription(location, rinfo.address);
|
||||
}
|
||||
|
||||
});
|
||||
ssdpBrowser2.search('urn:schemas-upnp-org:device:MediaRenderer:1');
|
||||
|
||||
ssdpBrowser2.on("response", (headers: any, statusCode: any, rinfo: any) => {
|
||||
var location = getLocation(headers);
|
||||
if (location != null) {
|
||||
this.getServiceDescription(location, rinfo.address);
|
||||
}
|
||||
});
|
||||
ssdpBrowser2.search("urn:schemas-upnp-org:device:MediaRenderer:1");
|
||||
} catch (e) {
|
||||
console.log("Search GC err", e);
|
||||
}
|
||||
|
@ -258,25 +255,24 @@ export default class ChromecastPlugin {
|
|||
} else {
|
||||
// upnp devices
|
||||
try {
|
||||
let client = new MediaRendererClient(UPNPDesc);
|
||||
const options = {
|
||||
autoplay: true,
|
||||
contentType: 'audio/x-wav',
|
||||
dlnaFeatures: 'DLNA.ORG_PN=-;DLNA.ORG_OP=01;DLNA.ORG_FLAGS=01700000000000000000000000000000',
|
||||
metadata: {
|
||||
title: 'Cider',
|
||||
creator: 'Streaming ...',
|
||||
type: 'audio', // can be 'video', 'audio' or 'image'
|
||||
// url: 'http://' + getIp() + ':' + server.address().port + '/',
|
||||
// protocolInfo: 'DLNA.ORG_PN=MP3;DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01700000000000000000000000000000;
|
||||
}
|
||||
};
|
||||
client.load('http://' + this.getIp() + ':' + this.ciderPort + '/audio.wav', options, function (err: any, _result: any) {
|
||||
if (err) throw err;
|
||||
console.log('playing ...');
|
||||
});
|
||||
} catch (e) {
|
||||
}
|
||||
let client = new MediaRendererClient(UPNPDesc);
|
||||
const options = {
|
||||
autoplay: true,
|
||||
contentType: "audio/x-wav",
|
||||
dlnaFeatures: "DLNA.ORG_PN=-;DLNA.ORG_OP=01;DLNA.ORG_FLAGS=01700000000000000000000000000000",
|
||||
metadata: {
|
||||
title: "Cider",
|
||||
creator: "Streaming ...",
|
||||
type: "audio", // can be 'video', 'audio' or 'image'
|
||||
// url: 'http://' + getIp() + ':' + server.address().port + '/',
|
||||
// protocolInfo: 'DLNA.ORG_PN=MP3;DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01700000000000000000000000000000;
|
||||
},
|
||||
};
|
||||
client.load("http://" + this.getIp() + ":" + this.ciderPort + "/audio.wav", options, function (err: any, _result: any) {
|
||||
if (err) throw err;
|
||||
console.log("playing ...");
|
||||
});
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2002,15 +2002,18 @@ const app = new Vue({
|
|||
}
|
||||
if (kind.toString().includes("apple-curator")) {
|
||||
kind = "appleCurator";
|
||||
app.getTypeFromID("appleCurator", id, false, {
|
||||
platform: "web",
|
||||
include: "grouping,playlists",
|
||||
extend: "editorialArtwork",
|
||||
"art[url]": "f",
|
||||
}).then(() => {
|
||||
kind = "appleCurator";
|
||||
window.location.hash = `${kind}/${id}`;
|
||||
document.querySelector("#app-content").scrollTop = 0});
|
||||
app
|
||||
.getTypeFromID("appleCurator", id, false, {
|
||||
platform: "web",
|
||||
include: "grouping,playlists",
|
||||
extend: "editorialArtwork",
|
||||
"art[url]": "f",
|
||||
})
|
||||
.then(() => {
|
||||
kind = "appleCurator";
|
||||
window.location.hash = `${kind}/${id}`;
|
||||
document.querySelector("#app-content").scrollTop = 0;
|
||||
});
|
||||
} else if (kind == "editorial-elements" || kind == "editorial-items") {
|
||||
console.debug(item);
|
||||
if (item.relationships?.contents?.data != null && item.relationships?.contents?.data.length > 0) {
|
||||
|
@ -4024,26 +4027,26 @@ const app = new Vue({
|
|||
},
|
||||
getMediaItemArtwork(url, height = 64, width) {
|
||||
try {
|
||||
if (typeof url == "undefined" || url == "") {
|
||||
return "./assets/MissingArtwork.svg";
|
||||
}
|
||||
height = parseInt(height * window.devicePixelRatio);
|
||||
if (width) {
|
||||
width = parseInt(width * window.devicePixelRatio);
|
||||
}
|
||||
let newurl = `${(url ?? "")
|
||||
.replace("{w}", width ?? height)
|
||||
.replace("{h}", height)
|
||||
.replace("{f}", "webp")
|
||||
.replace("{c}", width === 900 || width === 380 || width === 600 ? "sr" : "cc")}`;
|
||||
if (typeof url == "undefined" || url == "") {
|
||||
return "./assets/MissingArtwork.svg";
|
||||
}
|
||||
height = parseInt(height * window.devicePixelRatio);
|
||||
if (width) {
|
||||
width = parseInt(width * window.devicePixelRatio);
|
||||
}
|
||||
let newurl = `${(url ?? "")
|
||||
.replace("{w}", width ?? height)
|
||||
.replace("{h}", height)
|
||||
.replace("{f}", "webp")
|
||||
.replace("{c}", width === 900 || width === 380 || width === 600 ? "sr" : "cc")}`;
|
||||
|
||||
if (newurl.includes("900x516")) {
|
||||
newurl = newurl.replace("900x516cc", "900x516sr").replace("900x516bb", "900x516sr");
|
||||
}
|
||||
return newurl;}
|
||||
catch (e) {
|
||||
console.log(url)
|
||||
return "./assets/MissingArtwork.svg"
|
||||
if (newurl.includes("900x516")) {
|
||||
newurl = newurl.replace("900x516cc", "900x516sr").replace("900x516bb", "900x516sr");
|
||||
}
|
||||
return newurl;
|
||||
} catch (e) {
|
||||
console.log(url);
|
||||
return "./assets/MissingArtwork.svg";
|
||||
}
|
||||
},
|
||||
_rgbToRgb(rgb = [0, 0, 0]) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue