public LyrePlayerViewModel(IContainer ioc, SettingsPageViewModel settings, PlaylistViewModel playlist) { _speakers = OutputDevice.GetByName("Microsoft GS Wavetable Synth"); _timeWatcher = PlaybackCurrentTimeWatcher.Instance; _events = ioc.Get <IEventAggregator>(); _events.Subscribe(this); _settings = settings; Playlist = playlist; SelectedMidiInput = MidiInputs[0]; _timeWatcher.CurrentTimeChanged += OnSongTick; // SystemMediaTransportControls is only supported on Windows 10 and later // https://docs.microsoft.com/en-us/uwp/api/windows.media.systemmediatransportcontrols if (Environment.OSVersion.Platform == PlatformID.Win32NT && Environment.OSVersion.Version.Major >= 10) { _player = ioc.Get <MediaPlayer>(); _player.CommandManager.NextReceived += (_, _) => Next(); _player.CommandManager.PreviousReceived += (_, _) => Previous(); _player.CommandManager.PlayReceived += async(_, _) => await PlayPause(); _player.CommandManager.PauseReceived += async(_, _) => await PlayPause(); } }
public LyrePlayerViewModel(IContainer ioc, MainWindowViewModel main) { _main = main; _timeWatcher = PlaybackCurrentTimeWatcher.Instance; _events = ioc.Get <IEventAggregator>(); _events.Subscribe(this); SelectedMidiInput = MidiInputs[0]; _timeWatcher.CurrentTimeChanged += OnSongTick; // SystemMediaTransportControls is only supported on Windows 10 and later // https://docs.microsoft.com/en-us/uwp/api/windows.media.systemmediatransportcontrols if (Environment.OSVersion.Platform == PlatformID.Win32NT && Environment.OSVersion.Version.Major >= 10) { _player = ioc.Get <MediaPlayer>(); _player !.CommandManager.NextReceived += (_, _) => Next(); _player !.CommandManager.PreviousReceived += (_, _) => Previous(); _player !.CommandManager.PlayReceived += async(_, _) => await PlayPause(); _player !.CommandManager.PauseReceived += async(_, _) => await PlayPause(); } try { _speakers = OutputDevice.GetByName("Microsoft GS Wavetable Synth"); } catch (ArgumentException e) { new ErrorContentDialog(e, closeText: "Ignore").ShowAsync(); SettingsView.CanUseSpeakers = false; Settings.UseSpeakers = false; } }