Coder Social home page Coder Social logo

Comments (5)

MarkusMas avatar MarkusMas commented on June 7, 2024

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.

PSeitz avatar PSeitz commented on June 7, 2024

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.

MarkusMas avatar MarkusMas commented on June 7, 2024

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.

PSeitz avatar PSeitz commented on June 7, 2024

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.

MarkusMas avatar MarkusMas commented on June 7, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.