@tanislav000/bluez
Version:
Bluez5 D-Bus bindings for easy to use bluetooth access in Node.js
114 lines • 8.03 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.OrgBluezMediaControl1 = void 0;
const utilts_1 = require("../utilts");
/*
* Generated by dbus-next interface generator
* Template: typescript-class-auto.ts.hbs
*/
// Introspection XML of org.bluez at /org/bluez/hci0/dev_E8_D0_3C_47_B7_00
const XMLObjectData = `
<node><interface name="org.freedesktop.DBus.Introspectable"><method name="Introspect"><arg name="xml" type="s" direction="out"/></method></interface><interface name="org.bluez.Device1"><method name="Disconnect"/><method name="Connect"/><method name="ConnectProfile"><arg name="UUID" type="s" direction="in"/></method><method name="DisconnectProfile"><arg name="UUID" type="s" direction="in"/></method><method name="Pair"/><method name="CancelPairing"/><property name="Address" type="s" access="read"/><property name="AddressType" type="s" access="read"/><property name="Name" type="s" access="read"/><property name="Alias" type="s" access="readwrite"/><property name="Class" type="u" access="read"/><property name="Appearance" type="q" access="read"/><property name="Icon" type="s" access="read"/><property name="Paired" type="b" access="read"/><property name="Trusted" type="b" access="readwrite"/><property name="Blocked" type="b" access="readwrite"/><property name="LegacyPairing" type="b" access="read"/><property name="RSSI" type="n" access="read"/><property name="Connected" type="b" access="read"/><property name="UUIDs" type="as" access="read"/><property name="Modalias" type="s" access="read"/><property name="Adapter" type="o" access="read"/><property name="ManufacturerData" type="a{qv}" access="read"/><property name="ServiceData" type="a{sv}" access="read"/><property name="TxPower" type="n" access="read"/><property name="ServicesResolved" type="b" access="read"/></interface><interface name="org.freedesktop.DBus.Properties"><method name="Get"><arg name="interface" type="s" direction="in"/><arg name="name" type="s" direction="in"/><arg name="value" type="v" direction="out"/></method><method name="Set"><arg name="interface" type="s" direction="in"/><arg name="name" type="s" direction="in"/><arg name="value" type="v" direction="in"/></method><method name="GetAll"><arg name="interface" type="s" direction="in"/><arg name="properties" type="a{sv}" direction="out"/></method><signal name="PropertiesChanged"><arg name="interface" type="s"/><arg name="changed_properties" type="a{sv}"/><arg name="invalidated_properties" type="as"/></signal></interface><interface name="org.bluez.MediaControl1"><method name="Play"><annotation name="org.freedesktop.DBus.Deprecated" value="true"/></method><method name="Pause"><annotation name="org.freedesktop.DBus.Deprecated" value="true"/></method><method name="Stop"><annotation name="org.freedesktop.DBus.Deprecated" value="true"/></method><method name="Next"><annotation name="org.freedesktop.DBus.Deprecated" value="true"/></method><method name="Previous"><annotation name="org.freedesktop.DBus.Deprecated" value="true"/></method><method name="VolumeUp"><annotation name="org.freedesktop.DBus.Deprecated" value="true"/></method><method name="VolumeDown"><annotation name="org.freedesktop.DBus.Deprecated" value="true"/></method><method name="FastForward"><annotation name="org.freedesktop.DBus.Deprecated" value="true"/></method><method name="Rewind"><annotation name="org.freedesktop.DBus.Deprecated" value="true"/></method><property name="Connected" type="b" access="read"/><property name="Player" type="o" access="read"/></interface></node>`;
/**
* Service: org.bluez
* ObjectPath: /org/bluez/hci0/dev_E8_D0_3C_47_B7_00
* Interface: org.bluez.MediaControl1
*/
class OrgBluezMediaControl1 extends utilts_1.LooselyTypedEmitter {
static Connect(bus, objectPath = "/org/bluez/hci0/dev_E8_D0_3C_47_B7_00", xml = XMLObjectData) {
return bus.getProxyObject("org.bluez", objectPath, xml).then((obj) => new OrgBluezMediaControl1(obj));
}
constructor(dbusObject) {
super();
this.dbusObject = dbusObject;
this.thisDBusInterface = this.dbusObject.getInterface("org.bluez.MediaControl1");
this.propertiesDBusInterface = this.dbusObject.getInterface("org.freedesktop.DBus.Properties");
// forward property change events
const forwardPropertyChange = (iface, changed, invalidated) => {
if (iface === OrgBluezMediaControl1.DbusInterfaceName) {
this.emit("PropertiesChanged", iface, (0, utilts_1.unwrapDbusVariantObject)(changed), invalidated);
}
};
// forward all signals
this.on("newListener", (event, listener) => {
if (event === "PropertiesChanged" && this.listenerCount("PropertiesChanged") === 0) {
this.propertiesDBusInterface.addListener("PropertiesChanged", forwardPropertyChange);
}
else {
this.thisDBusInterface.addListener(event, listener);
}
});
this.on("removeListener", (event, listener) => {
if (event === "PropertiesChanged" && this.listenerCount("PropertiesChanged") === 0) {
this.propertiesDBusInterface.removeListener("PropertiesChanged", forwardPropertyChange);
}
else {
this.thisDBusInterface.removeListener(event, listener);
}
});
}
/***** Properties *****/
getProperties() {
return this.propertiesDBusInterface
.GetAll(OrgBluezMediaControl1.DbusInterfaceName)
.then(utilts_1.unwrapDbusVariantObject);
}
getProperty(name) {
return this.propertiesDBusInterface.Get(OrgBluezMediaControl1.DbusInterfaceName, name).then(utilts_1.unwrapDbusVariant);
}
setProperty(name, value) {
return this.propertiesDBusInterface.Set(OrgBluezMediaControl1.DbusInterfaceName, name, (0, utilts_1.wrapDbusVariant)(value));
}
//@property({ name: 'Connected', signature: 'b', access: ACCESS_READ })
Connected() {
return this.propertiesDBusInterface
.Get(OrgBluezMediaControl1.DbusInterfaceName, "Connected")
.then(utilts_1.unwrapDbusVariant);
}
//@property({ name: 'Player', signature: 'o', access: ACCESS_READ })
Player() {
return this.propertiesDBusInterface
.Get(OrgBluezMediaControl1.DbusInterfaceName, "Player")
.then(utilts_1.unwrapDbusVariant);
}
/***** Methods *****/
//@method({ name: 'Play', inSignature: '', outSignature: '' })
Play() {
return this.thisDBusInterface.Play();
}
//@method({ name: 'Pause', inSignature: '', outSignature: '' })
Pause() {
return this.thisDBusInterface.Pause();
}
//@method({ name: 'Stop', inSignature: '', outSignature: '' })
Stop() {
return this.thisDBusInterface.Stop();
}
//@method({ name: 'Next', inSignature: '', outSignature: '' })
Next() {
return this.thisDBusInterface.Next();
}
//@method({ name: 'Previous', inSignature: '', outSignature: '' })
Previous() {
return this.thisDBusInterface.Previous();
}
//@method({ name: 'VolumeUp', inSignature: '', outSignature: '' })
VolumeUp() {
return this.thisDBusInterface.VolumeUp();
}
//@method({ name: 'VolumeDown', inSignature: '', outSignature: '' })
VolumeDown() {
return this.thisDBusInterface.VolumeDown();
}
//@method({ name: 'FastForward', inSignature: '', outSignature: '' })
FastForward() {
return this.thisDBusInterface.FastForward();
}
//@method({ name: 'Rewind', inSignature: '', outSignature: '' })
Rewind() {
return this.thisDBusInterface.Rewind();
}
}
exports.OrgBluezMediaControl1 = OrgBluezMediaControl1;
OrgBluezMediaControl1.DbusInterfaceName = "org.bluez.MediaControl1";
//# sourceMappingURL=MediaControl1.js.map