public PlayVM() { _player = new Player(); _player.ChangeProgress += (curr, all) => { _currentProgress = (curr / all) * 100; RaisePropertyChanged("CurrentProgress"); }; _player.EndTrack += track => { var vm = ShownTracks.Where(t => t.Track.TrackID == track.TrackID).FirstOrDefault(); if (vm == null) _currentProgress = 0; else { ShownTracks[(ShownTracks.IndexOf(vm) + 1) % ShownTracks.Count].Play(); //CurrentProgress = 0; } Raise(); }; ShownTracks = new ObservableCollection<TrackVM>(); ShownMusiсDirs = new ObservableCollection<MusiсDirVM>(); MusicService = new MusicService(); var arr = new List<MusiсDirVM>(); MusicService.GetMusicDirs().ForEach(d => arr.Add(new MusiсDirVM(ShownMusiсDirs, ShownTracks, _player, MusicService) { MusiсDir = d })); ShownMusiсDirs.AddRange(arr.OrderBy(d => d.NameDir).ToList()); MusicService.DownloadMusicDirs((dirs) => { MusicService.SupplementMusicDirs(dirs).ForEach(d => ShownMusiсDirs.Add(new MusiсDirVM(ShownMusiсDirs, ShownTracks, _player, MusicService) { MusiсDir = d })); Raise(); }); SearchModeCommand = new DelegateCommand(SearchModeExecute); Raise(); }
//private Track _track; public TrackVM(MusicService service, Player player, ObservableCollection<TrackVM> shownTracks) { Service = service; ShownTracks = shownTracks; Player = player; SaveTrackCommand = new DelegateCommand(SaveTrackExecute); PlayPauseTrackCommand = new DelegateCommand(PlayPauseTrackExecute); IsPlay = false; IsBusy = false; }
public MusiсDirVM(ObservableCollection<MusiсDirVM> shownMusiсDirs, ObservableCollection<TrackVM> shownTracks, Player player, MusicService service) { ShownMusiсDirs = shownMusiсDirs; ShownTracks = shownTracks; Player = player; Service = service; SelectMusicDirCommand = new DelegateCommand(SelectMusicDirExecute); Raise(); }