Listening for model property changes can be done via propertyChanged on adEvents and mediaEvents.
TODO: Below will be refactored pending name changes
To listen for when the media volume has changed:
var MediaEngineModelProperty = TOP.models.MediaEngineModelProperty;
player.model().mediaEvents().propertyChanged.listen(function(result)
{
switch (result.property)
{
case MediaEngineModelProperty.Volume:
console.log('[propertyChanged]\n\tproperty:', result.property, '\n\told:', result.oldValue, '\n\tnew:', result.currentValue);
break;
}
});
player.setVolume(0.25);Shows this in the console:
[propertyChanged]
property: (2) ["Volume", 3, toString: ƒ, __enum__: {…}]
old: 1
new: 0.25 Some property change events are already being dispatched through the PlayerApiEvents. For the volume model property changed example, the player has adVolumeChanged and mediaVolumeChange events.