Beispiel #1
0
        private AppMessage MessageReceiver(AppMessage message)
        {
            _log.Information($"AppMessage received: {message.ToString()}");
            AppMessage retMessage = new AppMessage(AppMessage.CommandType.Error, $"Unsupported command type {message.Command.ToString()}");

            switch (message.Command)
            {
            case AppMessage.CommandType.Play:
                if (Player.IsValid)
                {
                    Player.Play();
                    retMessage.Copy(message);
                }
                else
                {
                    retMessage.Param = "";
                }
                break;

            case AppMessage.CommandType.Stop:
                if (Player.IsValid)
                {
                    Player.Pause();
                    retMessage.Copy(message);
                }
                else
                {
                    retMessage.Param = "";
                }
                break;

            case AppMessage.CommandType.Media:
                retMessage.Command = AppMessage.CommandType.Media;
                retMessage.Param   = Player.MediaUri.ToString();
                break;

            case AppMessage.CommandType.State:

                switch (Player.State)
                {
                case Windows.Media.Playback.MediaPlaybackState.Opening:
                    retMessage.Command = AppMessage.CommandType.Unknown;
                    retMessage.Param   = "Video is currently opening";
                    break;

                case Windows.Media.Playback.MediaPlaybackState.Buffering:
                    retMessage.Command = AppMessage.CommandType.Unknown;
                    retMessage.Param   = "Video is buffering";
                    break;

                case Windows.Media.Playback.MediaPlaybackState.Playing:
                    retMessage.Command = AppMessage.CommandType.Play;
                    break;

                case Windows.Media.Playback.MediaPlaybackState.Paused:
                    retMessage.Command = AppMessage.CommandType.Stop;
                    break;

                default:
                    retMessage.Command = AppMessage.CommandType.Unknown;
                    break;
                }

                break;

            default:
                break;
            }
            return(retMessage);
        }