Comments (5)
I finally made some progress but i'm stuck again..
I added this to simpleCommand.js to extract the URL:
Yamaha.prototype.getPlayInfo = function() { var command = '<YAMAHA_AV cmd="GET"><SERVER><Play_Info>GetParam</Play_Info></SERVER></YAMAHA_AV>'; return this.SendXMLToReceiver(command).then(xml2js.parseStringAsync); };
Yamaha.prototype.getShortAlbumArtURL = function() { return this.getPlayInfo().then(function(info) { var PlayInfo = []; var PlayInfoXML = info.YAMAHA_AV.SERVER[0].Play_Info[0].Album_ART[0].URL[0]; return PlayInfoXML; }); };
Now i can print th URL to the Console with this code:
yamaha.getShortAlbumArtURL().then(function(result){ console.log("Short URL is:"+result); })
But if i want to add the IP Adress:
var ShortAlbumArtURL = yamaha.getShortAlbumArtURL() var FullAlbumArtURL = 'http://' + yamaha.ip + ShortAlbumArtURL; console.log(FullAlbumArtURL);
The output of the console is:
http://192.168.178.39[object Promise]
from yamaha-nodejs.
All calls return promises, not the actual result, it should be probably something like this.
yamaha.getShortAlbumArtURL().then(function(url) {
var FullAlbumArtURL = 'http://' + yamaha.ip + url;
console.log(FullAlbumArtURL);
})
from yamaha-nodejs.
Thank you for helping on that very basic level. That writes the full URL to the console :)
How do i manage to have the FullAlbumArtURL available outside this function?!
My goal is to have a module that returns the full URL to another function.
module.exports.GetImageUri = function(deviceid) {
return yamaha.getShortAlbumArtURL().then(function(URL) {
var FullAlbumArtURL = 'http://' + yamaha.ip + URL; console.log(FullAlbumArtURL);
})
};
But the image is then undefined?
from yamaha-nodejs.
promises are async, it's not possbile to get the result in a sync manner, you have to use then()
like this
GetImageUri().then(function(uri) {
// the result returns
})
from yamaha-nodejs.
Hi PSeitz,
thank you for your support!
i also got soume support over here: https://planet.neeo.com/r/80jwc9
It works for now ... ^^
from yamaha-nodejs.
Related Issues (16)
- Integration with homebridge HOT 2
- Can't import the module HOT 2
- How to figure out the RC-Codes? HOT 7
- Offical API found HOT 3
- Handle request timeout error HOT 5
- Issue with OpenSSL between yams and alexandra install HOT 2
- Zone B Control HOT 1
- delay is inserted regardless of PUT or GET HOT 2
- Scene Feature suggestion. HOT 4
- NPM version doesn't match GitHub HOT 4
- Tailor to multiple zones HOT 7
- Can we make PRs that use http requests? HOT 2
- What does that mean? HOT 2
- Error: socket hang up HOT 1
- Yamaha AVR Discovery HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yamaha-nodejs.