Matrix Theme for HABPanel

Weird that Spotify doesn’t have a websocket or similar to track playback events…
To answer your question, yes probably. I would build a directive using $interval (AngularJS) and lazy load the file and use it in my template. It would send a command to an item with a rule attached to it like @Michael_Stjerna - sendCmd('spotify_forceupdate', 'REFRESH')

Something like (disclaimer, may not work, haven’t tested):

    angular
        .module('app.widgets')
        .directive('sendCmdAtInterval', ['$interval', function ($interval) {
            return {
                link: function (scope, element, attrs) {
                    var handler = $interval(function () {
                        scope.sendCmd('spotify_forcerefresh', 'REFRESH');
                    }, 10000);

                    scope.$on('$destroy', handler);
                }
            };
        }]);

then <div oc-lazy-load="'/static/sendcmdatinterval.directive.js'" send-cmd-at-interval class="..."> somewhere in the template around the Spotify stuff. Check the “Injecting custom JavaScript code” in HABPanel Development & Advanced Features: Start Here!

1 Like