Example #1
0
        // receive event notifications from MusicBee
        // you need to set about.ReceiveNotificationFlags = PlayerEvents to receive all notifications, and not just the startup event
        public void ReceiveNotification(string sourceFileUrl, NotificationType type)
        {
            // perform some action depending on the notification type
            switch (type)
            {
            case NotificationType.PluginStartup:
                // Establish a websocket connection if enabled and initialize the messages.
                config                  = new StaticConfig();
                wsClient                = new WebSocketClient(config);
                trackChangedMessage     = new TrackChangedMessage(mbApiInterface);
                playStateChangedMessage = new PlayStateChangedMessage();
                trackTimeTimer          = new TrackTimeTimer(mbApiInterface, wsClient);
                break;

            case NotificationType.TrackChanged:
                trackChangedMessage.Send(wsClient);
                break;

            case NotificationType.PlayStateChanged:
                switch (mbApiInterface.Player_GetPlayState())
                {
                case PlayState.Playing:
                    playStateChangedMessage.Send(wsClient, true);
                    trackTimeTimer.Start();
                    break;

                case PlayState.Paused:
                case PlayState.Stopped:
                    playStateChangedMessage.Send(wsClient, false);
                    trackTimeTimer.Stop();
                    break;
                }
                break;
            }
        }
 private void OnPlayStateChanged(PlayStateChangedMessage message)
 {
     RaisePropertyChanged("IsPlaying");
 }