ChriD / node-raumkernel

A nodeJs lib for controlling the raumfeld multiroom system
MIT License
17 stars 7 forks source link

RendererState is not up to date #46

Closed ulilicht closed 3 years ago

ulilicht commented 3 years ago

Hello,

first of all, thanks for your great library!

I encountered the following issue: When trying to access the currently playing information, e.g. CurrentTrackMetaData of a renderer, the rendererState is not up to date. I attached an example below, after some time, the rendererState changes.

Is there a way to reliably access information within rendererState? Any event I potentitally can rely on to get information about the currently playing media of a renderer?

I observed similar behaviour on the combinedZoneStateChanged event, there as well _combinedZoneState.zones[2].rendererState changes after some time.

Thank you for your help!

Code example 1, renderer state different after some time:

let RaumkernelLib = require('node-raumkernel');
let raumkernel = new RaumkernelLib.Raumkernel();
const testRendererUDN = 'uuid:e570d28c-172f-4aa9-9a91-aab8d974a9b0';

raumkernel.init();

raumkernel.on('systemReady', (_ready) => {
    const renderer = raumkernel.managerDisposer.deviceManager.mediaRenderersVirtual.get(testRendererUDN);

    console.log(JSON.stringify(renderer.rendererState));

    setTimeout(() => {
        console.log(JSON.stringify(renderer.rendererState)); // different output
    }, 1000);
});

Code example 2, event payload differs after some time:

raumkernel.on('combinedZoneStateChanged', _combinedZoneState => {
        console.log(JSON.stringify(_combinedZoneState.zones[2].rendererState));

        setTimeout(() => {
            console.log(JSON.stringify(_combinedZoneState.zones[2].rendererState)); // different output
        }, 1000);
});
ChriD commented 3 years ago

Hi, Does the rendererMediaItemDataChanged(_mediaRenderer, _mediaItemData) event behave the same? This would be the event that triggers whenever a new media item will be played by the renderer. Each renderer does have a dedicated currentMediaItemData property which should contain proper info.

Or it is the same problem as #43 where some UPNP messages gets stuck in traffic and will override newer ones

I am not sure whats the content of the media item wehn using spotify. I think it will not work with spotify. But all other should work

ulilicht commented 3 years ago

Thank you, the event behaves correctly. It is less convenient to get the correct information with the event instead of combined for all renderers, but it will serve as a workaround for me.