public async void Load(Mediafile mp3file, bool play = false, double currentPos = 0, double vol = 50) { if (mp3file != null) { try { if (play == true) { Player.IgnoreErrors = true; } if (await Player.Load(mp3file)) { TracksCollection?.Elements.Where(t => t.State == PlayerState.Playing).ToList().ForEach(new Action <Mediafile>((Mediafile file) => { file.State = PlayerState.Stopped; service.UpdateMediafile(file); })); PlaylistSongCollection?.Where(t => t.State == PlayerState.Playing).ToList().ForEach(new Action <Mediafile>((Mediafile file) => { file.State = PlayerState.Stopped; })); PlayPauseCommand.IsEnabled = true; mp3file.State = PlayerState.Playing; if (Player.Volume == 50) { Player.Volume = vol; } if (play) { PlayPauseCommand.Execute(null); } else { DontUpdatePosition = true; CurrentPosition = currentPos; } if (GetPlayingCollection() != null) { UpcomingSong = await GetUpcomingSong(); } Themes.ThemeManager.SetThemeColor(Player.CurrentlyPlayingFile.AttachedPicture); } else { BLogger.Logger.Error("Failed to load file. Loading next file..."); TracksCollection?.Elements.Where(t => t.State == PlayerState.Playing).ToList().ForEach(new Action <Mediafile>((Mediafile file) => { file.State = PlayerState.Stopped; service.UpdateMediafile(file); })); PlaylistSongCollection?.Where(t => t.State == PlayerState.Playing).ToList().ForEach(new Action <Mediafile>((Mediafile file) => { file.State = PlayerState.Stopped; })); mp3file.State = PlayerState.Playing; int indexoferrorfile = GetPlayingCollection().IndexOf(GetPlayingCollection().FirstOrDefault(t => t.Path == mp3file.Path)); Player.IgnoreErrors = false; Load(await GetUpcomingSong(), true); } } catch (Exception ex) { BLogger.Logger.Error("Failed to load file.", ex); } } }
private void OnOpenMediaCommand() { var fileName = DialogService.OpenFileDialog(); if (!String.IsNullOrWhiteSpace(fileName)) { MediaPath = fileName; _debugMessageList.Add("Opening media file: " + fileName); _totalTime = _startFrom != null ? _startFrom.Value : 0; } PlayPauseCommand.RaiseCanExecuteChanged(); }
public ToolbarViewModel(Models models) { m_models = models; PlayPauseCommand = new PlayPauseCommand(models); ResetCommand = new ResetCommand(models); SaveScreenShotCommand = new ScreenShotCommand(models); ToggleCameraMovementCommand = new ActionCommand(() => models.Settings.AllowCameraMovement = !models.Settings.AllowCameraMovement); EnterFreeFlightMode = new EnterFreeFlightMode(models); OneIterationCommand = new PerformIterationsCommand(m_models, 1u); NIterationsCommand = new PerformNIterationsCommand(m_models); ContinuousSequenceRenderCommand = new RenderSequenceCommand(m_models, -1, true, false); m_models.Renderer.PropertyChanged += RendererOnPropertyChanged; m_models.Settings.PropertyChanged += SettingsOnPropertyChanged; }
/// <summary> /// Handles mouse click events for both Host and Fullscreen. /// </summary> private void HandleMouseAction(object sender, MouseButtonEventArgs e, int clickCount) { bool IsFullScreen = sender is FullScreenUI; if (IsActionFullScreen(e, clickCount)) { FullScreen = !IsFullScreen; // using !FullScreen can return wrong value when exiting fullscreen e.Handled = true; } else if (IsActionPause(e, clickCount)) { if (PlayPauseCommand.CanExecute(null)) { PlayPauseCommand.Execute(null); } e.Handled = true; } }
private async void Load(object mp3file, bool play = false) { StorageFile file = mp3file as StorageFile; if (file != null) { await player.Load(file.Path); Length = player.Length; CurrentPosition = 0; Tags = player.Tags; if (play) { PlayPauseCommand.IsEnabled = true; PlayPauseCommand.Execute(null); } } GC.Collect(); }
public async void Load(Mediafile mp3file, bool play = false, double currentPos = 0, double vol = 50) { if (mp3file != null) { if (play == true) { Player.IgnoreErrors = true; } if (await Player.Load(mp3file)) { TracksCollection?.Elements.Where(t => t.State == PlayerState.Playing).ToList().ForEach(new Action <Mediafile>((Mediafile file) => { file.State = PlayerState.Stopped; service.UpdateMediafile(file); })); PlaylistSongCollection?.Elements.Where(t => t.State == PlayerState.Playing).ToList().ForEach(new Action <Mediafile>((Mediafile file) => { file.State = PlayerState.Stopped; })); PlayPauseCommand.IsEnabled = true; mp3file.State = PlayerState.Playing; if (play) { PlayPauseCommand.Execute(null); } else { Player.Volume = vol; DontUpdatePosition = true; CurrentPosition = currentPos; } if (GetPlayingCollection() != null) { UpcomingSong = await GetUpcomingSong(); } } else { TracksCollection?.Elements.Where(t => t.State == PlayerState.Playing).ToList().ForEach(new Action <Mediafile>((Mediafile file) => { file.State = PlayerState.Stopped; service.UpdateMediafile(file); })); PlaylistSongCollection?.Elements.Where(t => t.State == PlayerState.Playing).ToList().ForEach(new Action <Mediafile>((Mediafile file) => { file.State = PlayerState.Stopped; })); mp3file.State = PlayerState.Playing; int indexoferrorfile = GetPlayingCollection().IndexOf(GetPlayingCollection().FirstOrDefault(t => t.Path == mp3file.Path)); Player.IgnoreErrors = false; Load(await GetUpcomingSong(), true); } } }
/// <summary> /// Handles mouse click events for both Host and Fullscreen. /// </summary> private void HandleMouseAction(object?_, PointerPressedEventArgs e, int clickCount) { var isFullScreen = false; // sender is FullScreenUI; if (IsActionFullScreen(e.MouseButton, clickCount)) { FullScreen = !isFullScreen; // using !FullScreen can return wrong value when exiting fullscreen e.Handled = true; } else if (IsActionPause(e.MouseButton, clickCount)) { if (PlayPauseCommand.CanExecute(null)) { PlayPauseCommand.Execute(null); } e.Handled = true; } }
public async void Load(Mediafile mp3file, bool play = false, double currentPos = 0, double vol = 50) { if (mp3file != null) { if (play == true) { Player.IgnoreErrors = true; } ChangePlayingSongState(PlayerState.Playing, PlayerState.Stopped); if (await Player.Load(mp3file)) { PlayPauseCommand.IsEnabled = true; mp3file.State = PlayerState.Playing; if (LibVM.TracksCollection.Elements.Count(t => t.Path == Player.CurrentlyPlayingFile?.Path) < 2) { var mp3 = LibVM.TracksCollection?.Elements?.SingleOrDefault(t => t.Path == Player.CurrentlyPlayingFile?.Path); if (mp3 != null) { mp3.State = PlayerState.Playing; } } if (play) { PlayPauseCommand.Execute(null); } else { Player.Volume = vol; DontUpdatePosition = true; CurrentPosition = currentPos; } UpcomingSong = await GetUpcomingSong(); } else { mp3file.State = PlayerState.Playing; int indexoferrorfile = GetPlayingCollection().IndexOf(GetPlayingCollection().FirstOrDefault(t => t.Path == mp3file.Path)); Player.IgnoreErrors = false; Load(await GetUpcomingSong(), true); } } }
private async void Load(Mediafile mp3file, bool play = false, double currentPos = 0, double vol = 50) { if (mp3file != null) { if (await Player.Load(mp3file)) { PlayPauseCommand.IsEnabled = true; if (play) { PlayPauseCommand.Execute(null); } else { Player.Volume = vol; DontUpdatePosition = true; CurrentPosition = currentPos; } } } }
protected MediaPlaybackViewModel(HistoryService historyService, IMediaService mediaService, VlcService mediaPlayerService) { _historyService = historyService; _mediaService = mediaService; _mediaService.StatusChanged += PlayerStateChanged; _vlcPlayerService = mediaPlayerService; _displayAlwaysOnRequest = new DisplayRequest(); _sliderPositionTimer = new DispatcherTimer(); _sliderPositionTimer.Tick += FirePositionUpdate; _sliderPositionTimer.Interval = TimeSpan.FromMilliseconds(16); _skipAhead = new ActionCommand(() => _mediaService.SkipAhead()); _skipBack = new ActionCommand(() => _mediaService.SkipBack()); _playNext = new PlayNextCommand(); _playPrevious = new PlayPreviousCommand(); _playOrPause = new PlayPauseCommand(); _goBackCommand = new StopVideoCommand(); }
private async void Player_MediaEnded(object sender, Events.MediaEndedEventArgs e) { await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() => { DontUpdatePosition = true; CurrentPosition = 0; player.PlayerState = PlayerState.Stopped; if (!Repeat) { await player.Pause(); timer.Stop(); PlayPauseIcon = new SymbolIcon(Symbol.Play); DontUpdatePosition = false; } else { timer.Start(); DontUpdatePosition = false; PlayPauseCommand.Execute(null); } }); }
private async void Load(object mp3file, bool play = false, double currentPos = 0, double vol = 50) { StorageFile file = mp3file as StorageFile; if (file != null && file.FileType == ".mp3") { await player.Load(file.Path); Length = player.Length; PlayPauseCommand.IsEnabled = true; if (play) { PlayPauseCommand.Execute(null); } else { Volume = vol; DontUpdatePosition = true; CurrentPosition = currentPos; } Tags = player.Tags; } GC.Collect(); }
// Used to initialise a new instance of the BasicWAVPlayerViewModel public BasicWAVPlayerViewModel() { OpenWAVCommand = new OpenWAVCommand(this); PlayPauseCommand = new PlayPauseCommand(this); }
private void OnPlayPause(PlayPauseCommand message) { PlayPause(); }