private async void ButtonOnPlayStateChanged(
            SoundPlayButton activeButton, SoundPlayState newState)
        {
            lock (_lockObject)
            {
                if (_isLoading)
                {
                    return;
                }
                _isLoading = true;
            }

            if (activeButton == null)
            {
                return;
            }
            _activeButton = activeButton;

            var notification = new SoundPlayStateChangedNotification
            {
                NewSound = (Sound)activeButton.DataContext,
                NewState = newState
            };

            if (newState == SoundPlayState.Playing)
            {
                foreach (SoundPlayButton button in _buttons)
                {
                    if (button != activeButton &&
                        button.State == SoundPlayState.Playing)
                    {
                        button.State = SoundPlayState.Stopped;
                        MediaElementSound.Stop();
                    }
                }

                await SetSound(activeButton.Sound);

                Play();
            }
            else
            {
                activeButton.State = SoundPlayState.Paused;
                Stop();
            }

            //if (Command != null)
            //    Command.Execute(notification);

            _isLoading = false;
        }
        private async void ButtonOnPlayStateChanged(
            SoundPlayButton activeButton, SoundPlayState newState)
        {
            lock (_lockObject)
            {
                if (_isLoading) return;
                _isLoading = true;
            }

            if (activeButton == null) return;
            _activeButton = activeButton;

            var notification = new SoundPlayStateChangedNotification
            {
                NewSound = (Sound)activeButton.DataContext,
                NewState = newState
            };

            if (newState == SoundPlayState.Playing)
            {
                foreach (SoundPlayButton button in _buttons)
                {
                    if (button != activeButton &&
                        button.State == SoundPlayState.Playing)
                    {
                        button.State = SoundPlayState.Stopped;
                        MediaElementSound.Stop();
                    }
                }

                await SetSound(activeButton.Sound);
                Play();
            }
            else
            {
                activeButton.State = SoundPlayState.Paused;
                Stop();
            }

            //if (Command != null)
            //    Command.Execute(notification);

            _isLoading = false;
        }
 public void Clear()
 {
     Stop();
     _mediaElement = null;
     _sound = null;
     _activeButton = null;
 }