Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extracting the ID or ULR of an Album_Art #23

Open
MarkusMas opened this issue May 8, 2018 · 5 comments
Open

Extracting the ID or ULR of an Album_Art #23

MarkusMas opened this issue May 8, 2018 · 5 comments

Comments

@MarkusMas
Copy link

MarkusMas commented May 8, 2018

Hi PSeitz,

thank you for creating this piece of code. I'm trying to use it for creating a driver for my NEEO remote.

Can you please add some commands for extracting info about the playback?

The Request for this would be:
<YAMAHA_AV cmd="GET"><SERVER><Play_Info>GetParam</Play_Info></SERVER></YAMAHA_AV>

Response is then for example:
<YAMAHA_AV rsp="GET" RC="0"><SERVER><Play_Info><Feature_Availability>Ready</Feature_Availability><Playback_Info>Play</Playback_Info><Play_Mode><Repeat>One</Repeat><Shuffle>Off</Shuffle></Play_Mode><Time><Elapsed>1:26</Elapsed></Time><Meta_Info><Artist>A.A. Milne read by Alan Bennett</Artist><Album>Winnie the Pooh</Album><Song>Eeyore, The Old Grey Donkey...</Song></Meta_Info><Album_ART><URL>/YamahaRemoteControl/AlbumART/AlbumART6475.jpg</URL><ID>64752</ID><Format>JPEG</Format></Album_ART></Play_Info></SERVER></YAMAHA_AV>

I would love to integrate the Album_ART into my project so i need the ID or URL of the Album_Art that is played back.

Can you please help to extract this information? I have a very basic knowledge of coding so help would be really appreciated.

@MarkusMas
Copy link
Author

MarkusMas commented May 11, 2018

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]

@PSeitz
Copy link
Owner

PSeitz commented May 11, 2018

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);
})

@MarkusMas
Copy link
Author

MarkusMas commented May 11, 2018

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?

@PSeitz
Copy link
Owner

PSeitz commented May 11, 2018

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
})

@MarkusMas
Copy link
Author

Hi PSeitz,
thank you for your support!
i also got soume support over here: https://planet.neeo.com/r/80jwc9
It works for now ... ^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants