Exemple #1
0
        public MainWindowViewModel(ISnackbarMessageQueue snackbarMessageQueue)
        {
            snackbarMessageQueue.NotNull(nameof(snackbarMessageQueue));

            PlayerWrapper = new MediaPlayerWrapper();

            if (!File.Exists(_playbackFileName))
            {
                PlaybackHelper.SaveOptions(new PlaybackOptions(), _playbackFileName);
            }

            Playback = PlaybackHelper.LoadOptions(_playbackFileName);
        }
Exemple #2
0
        /// <summary>
        /// 播放音乐文件path。该函数不会显示任何音乐播放界面。如果文件不存在或者文件不是受支持的音乐格式,则抛出UncheckedIOException异常。
        /// </summary>
        /// <param name="path">音乐文件路径。</param>
        /// <param name="volume">播放音量,为0~1的浮点数,默认为1</param>
        /// <param name="looping">是否循环播放,如果looping为true则循环播放,默认为false。</param>
        /// <exception cref="LuaException"></exception>
        public void playMusic(string path, float volume = 1.0f, bool looping = false)
        {
            path = PFiles.Path(path);
            if (_mediaPlayer == null)
            {
                _mediaPlayer = new MediaPlayerWrapper();
            }

            _mediaPlayer.StopAndReset();
            try
            {
                _mediaPlayer.SetDataSource(path);
                _mediaPlayer.SetVolume(volume, volume);
                _mediaPlayer.Looping = looping;
                _mediaPlayer.Prepare();
            }
            catch (Exception e)
            {
                throw new LuaException(e.Message);
            }

            _mediaPlayer.Start();
        }
Exemple #3
0
        /// <summary>
        /// Handler for MouseRightButtonUp. It removes item from the cell.
        /// </summary>
        public void HandleMouseRightButtonUp()
        {
            if (_inventoryCell.Amount == 0)
            {
                return;
            }

            _inventoryCell.Amount--;

            if (_inventoryCell.Amount == 0)
            {
                _inventoryCell.Item = null;
            }

            NotifyOfPropertyChange(() => Amount);
            NotifyOfPropertyChange(() => ImageSource);

            MediaPlayerWrapper player = new MediaPlayerWrapper();

            player.PlayEatingAppleCrunch();

            _inventoryCellRepository.UpdateCell(_inventoryCell);
        }