private void AddVideoPlaylist(object param) { string name = InputPlaylistName(); Library.PlayList tmp = new Library.PlayList(); tmp.Icon = this.mediaPlayer.LibIcons[Media.MediaTypes.Video]; tmp.Name = name; tmp.Type = Library.LibraryType.PlayList; tmp.MediaType = Media.MediaTypes.Video; PlayLists.Add(tmp); Console.WriteLine("New Playlist: " + tmp); this.mediaPlayer.Playlists.Add(tmp); this.mediaPlayer.SerializePlaylists(); OnPropertyChanged("PlayLists"); }
private void UpdatePlayList() { SongInfo = new Song( DateTime.Now.ToString("HH:mm"), tagInfo.artist, tagInfo.title, tagInfo.album, tagInfo.comment, tagInfo.genre, tagInfo.year, tagInfo.artist + " - " + tagInfo.title); mainWindow.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(delegate() { PlayLists.Add(SongInfo); })); }
private void RenameSelectedPlaylist(object param) { if (PlayLists[SelectedPlaylist] != null) { string newName = InputPlaylistName(); if (File.Exists(Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "\\MVMPV2.d\\" + PlayLists[SelectedPlaylist].Name + ".xml")) { File.Delete(Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "\\MVMPV2.d\\" + PlayLists[SelectedPlaylist].Name + ".xml"); } if (newName != null) { PlayLists[SelectedPlaylist].Name = newName; } this.mediaPlayer.Playlists = PlayLists.ToList <Library.PlayList>(); this.mediaPlayer.SerializePlaylists(); } }
public List <Track> GetTracks(string genreID) { string token = GetToken(); HttpWebRequest playlistRequest = (HttpWebRequest)WebRequest.Create( $"{BaseUrl}/v1/browse/categories/{genreID}/playlists?limit=1"); playlistRequest.Method = WebRequestMethods.Http.Get; playlistRequest.Accept = "application/json"; playlistRequest.Headers["Authorization"] = "Bearer " + token; string responseJson; using (var response = (HttpWebResponse)playlistRequest.GetResponse()) using (var sr = new StreamReader(response.GetResponseStream())) responseJson = sr.ReadToEnd(); PlayLists playList = JsonConvert.DeserializeObject <PlayLists>(responseJson); string tracksUrl = playList.Playlists.Items.FirstOrDefault()?.Tracks.Href; if (string.IsNullOrWhiteSpace(tracksUrl)) { return(new List <Track>()); } HttpWebRequest tracksRequest = (HttpWebRequest)WebRequest.Create(tracksUrl); tracksRequest.Method = WebRequestMethods.Http.Get; tracksRequest.Accept = "application/json"; tracksRequest.Headers["Authorization"] = "Bearer " + token; using (var response = (HttpWebResponse)tracksRequest.GetResponse()) using (var sr = new StreamReader(response.GetResponseStream())) responseJson = sr.ReadToEnd(); TracksRoot tracks = JsonConvert.DeserializeObject <TracksRoot>(responseJson); var trackList = (from item in tracks.Items select item.Track) .Take(5) .ToList(); return(trackList); }
private void AddMusicPlaylist(object param) { string name = InputPlaylistName(); Library.PlayList tmp = new Library.PlayList(); tmp.Icon = this.mediaPlayer.LibIcons[Media.MediaTypes.Music]; tmp.Name = name; tmp.Type = Library.LibraryType.PlayList; tmp.MediaType = Media.MediaTypes.Music; tmp.Content = new List <Media.Media>(); tmp.Content.Add(mediaPlayer.AudioList.Content[0].List[0]); MusicPlayList.Add(tmp); OnPropertyChanged("MusicPlayList"); PlayLists.Add(tmp); Console.WriteLine("New Playlist: " + tmp); this.mediaPlayer.Playlists.Add(tmp); this.mediaPlayer.SerializePlaylists(); }
/// <summary> /// 打开一首音乐 /// </summary> private void OpenMusic() { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "所有支持的文件|*.mp3;*.wav|mp3|*.mp3|wav|*.wav"; ofd.ValidateNames = true; ofd.CheckPathExists = true; ofd.CheckFileExists = true; ofd.Multiselect = false; if (ofd.ShowDialog() == DialogResult.OK) { var selectedPlayList = PlayLists.Where(i => i.IsSelected == true).First(); var playList = selectedPlayList.PlayList; PlayListService.CleanMusic(playList); PlayListService.AddMusic(playList, OpenMusicService.OpenMusic(ofd.FileName)); InitMusicList(selectedPlayList); } }
static public void CreateData(FierceStukCloudDbContext context) { PlayLists = PlayListsFactory(); Authors = AuthorsFactory(); context.PlayLists.AddRange(PlayLists.AsEnumerable()); context.Authors.AddRange(Authors.AsEnumerable()); context.SaveChanges(); var s1 = new Song() { Id = Guid.NewGuid(), Title = "title0" }; s1.Authors.Add(Authors[0]); //s1.DbAuthors = new List<SongAuthor>() //{ // SongAuthorFactory(s1.Id, Authors[0].Id) //}; var s2 = new Song() { Id = Guid.NewGuid(), Title = "title2" }; s2.Authors.Add(Authors[0]); //s2.DbAuthors = new List<SongAuthor>() //{ // SongAuthorFactory(s2.Id, Authors[0].Id) //}; Songs = new List <Song>(); Songs.Add(s1); Songs.Add(s2); //PlayLists[0].DbSongs.Add(new SongPlayList() { Place = 0, PlayListId = PlayLists[0].Id, SongId = Songs[0].Id }); PlayLists[0].Songs.Add(Songs[0]); context.Songs.Add(s1); context.Songs.Add(s2); context.SaveChanges(); }
private async Task OnFwChanged(string path, bool isAFolder) { var files = PlayLists .SelectMany(f => f.Items) .Where(f => isAFolder ? f.Path.StartsWith(path) : f.Path == path) .ToList(); foreach (var file in files) { var playlist = PlayLists.FirstOrDefault(f => f.Id == file.PlayListId); if (playlist == null) { continue; } await playlist.SetFileInfo(file.Id, _setDurationTokenSource.Token); _appWebServer?.OnFileChanged(playlist.Id); } }
public PlayListItemResponseDto GetPlayListForMediaWebSocket(long playlistId) { var playlist = PlayLists.FirstOrDefault(pl => pl.Id == playlistId); if (playlist == null) { return(null); } return(new PlayListItemResponseDto { Id = playlist.Id, Loop = playlist.Loop, Name = playlist.Name, NumberOfFiles = playlist.Items.Count, Position = playlist.Position, Shuffle = playlist.Shuffle, TotalDuration = playlist.TotalDuration, Files = _mapper.Map <List <FileItemResponseDto> >(playlist.Items) }); }
public Task SetFileLoop(long id, long playlistId, bool loop) { var pl = PlayLists.FirstOrDefault(pl => pl.Id == playlistId); if (pl == null) { Logger.LogWarning($"{nameof(SetFileLoop)}: Couldnt update fileId = {id} because playlistId = {playlistId} doesnt exists"); return(ShowSnackbarMsg(GetText("PlayListDoesntExist"))); } var file = pl.Items.FirstOrDefault(f => f.Id == id); if (file == null) { Logger.LogWarning($"{nameof(SetFileLoop)}: Couldnt update fileId = {id} because it doesnt exists"); return(ShowSnackbarMsg(GetText("FileDoesntExist"))); } file.Loop = loop; return(Task.CompletedTask); }
public Task PlayFileForMediaWebSocket(long id, long playlistId, bool force) { var playList = PlayLists.FirstOrDefault(pl => pl.Id == playlistId); if (playList == null) { Logger.LogWarning($"{nameof(PlayFileForMediaWebSocket)}: Couldnt play fileId = {id} because playlistId = {playlistId} doesnt exists"); _appWebServer.OnServerMsg?.Invoke(GetText("PlayListDoesntExist")); return(Task.CompletedTask); } var file = playList.Items.FirstOrDefault(f => f.Id == id); if (file != null) { return(PlayFile(file, force)); } Logger.LogWarning($"{nameof(PlayFileForMediaWebSocket)}: Couldnt play fileId = {id} because it doesnt exists"); _appWebServer.OnServerMsg?.Invoke(GetText("FileDoesntExist")); return(Task.CompletedTask); }
/// <summary> /// 切换播放列表 /// </summary> private void PlayListClick() { var selectedPlayList = PlayLists.Where(i => i.IsSelected == true).First(); InitMusicList(selectedPlayList); }