private void ClearViewModel() { Albums.Clear(); Artists.Clear(); Playlists.Clear(); Tracks.Clear(); }
public void RefreshData() { try { IsLoadingData = true; // clear all displayed data Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate { Playlists.Clear(); CurrentPlaylistObjects.Clear(); ViewCurrentPlaylistObjects.Refresh(); ViewPlaylists.Refresh(); }); // load the playlists List <VM_Playlist> rawPlaylists = VM_ShokoServer.Instance.ShokoServices.GetAllPlaylists().CastList <VM_Playlist>(); foreach (VM_Playlist contract in rawPlaylists) { Playlists.Add(contract); } IsLoadingData = false; } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
void LoadCD() { if (cd.isPlaylist) { if (cd.CDPath.ToLower().EndsWith(".m3u", StringComparison.OrdinalIgnoreCase) || cd.CDPath.ToLower().EndsWith(".m3u8", StringComparison.OrdinalIgnoreCase)) { audioFiles = Playlists.m3uPlaylist(cd.CDPath).ToArray(); } if (cd.CDPath.ToLower().EndsWith(".pls", StringComparison.OrdinalIgnoreCase)) { audioFiles = Playlists.plsPlaylist(cd.CDPath).ToArray(); } } else { audioFiles = Directory.GetFiles(cd.CDPath, "*.*"). Where(file => file.ToLower().EndsWith(".ogg", StringComparison.OrdinalIgnoreCase) || file.ToLower().EndsWith(".mp3", StringComparison.OrdinalIgnoreCase) || file.ToLower().EndsWith(".flac", StringComparison.OrdinalIgnoreCase) || file.ToLower().EndsWith(".wav", StringComparison.OrdinalIgnoreCase) || file.ToLower().EndsWith(".aiff", StringComparison.OrdinalIgnoreCase)).ToArray(); } eject.gameObject.SetActive(true); cd.inPlayer = true; loadingCD = true; isCDin = true; currentSong = 0; StartCoroutine(LoadingCD()); }
private void ViewModelAddData(Search result) { result.Albums.Items.ForEach(a => Albums.Add(a)); result.Artists.Items.ForEach(a => Artists.Add(a)); result.Playlists.Items.ForEach(p => Playlists.Add(p)); result.Tracks.Items.ForEach(t => Tracks.Add(t)); }
/// <summary> /// Bind the users list of playlists to the view /// </summary> /// <returns></returns> private async Task BindPlaylists() { try { var page = await SpotifyService.GetPlaylists(AuthenticationService.User, AuthenticationService.AuthenticationToken); do { foreach (var playlist in page.Items) { Playlists.Add(playlist); } if (page.HasNextPage) { page = await SpotifyService.GetNextPage(page, AuthenticationService.AuthenticationToken); } else { page = null; } }while (page != null); } catch (Exception ex) { PageException = ex; } Loaded = true; StateHasChanged(); }
private void CreateDtPlaylist(Playlist playlistPaths) { List <string> fileLists = new List <string>(); List <string> fileTypes = new List <string>(); playlist = new Playlist("", mediaPlayer); foreach (var item in playlistPaths.MediaList) { fileLists.Add(item.GetPath()); fileTypes.Add(item.GetType().ToString()); } for (int i = 0; i < fileLists.Count; i++) { string artist = "", album = "", title = "", url = ""; BitmapImage bitmapImage = null; TimeSpan duration; try { TagLib.File tagFile = TagLib.File.Create(fileLists[i]); artist = tagFile.Tag.JoinedPerformers; album = tagFile.Tag.Album; title = tagFile.Tag.Title; bitmapImage = GetBitmapFromIPicture(tagFile.Tag.Pictures.FirstOrDefault()); duration = tagFile.Properties.Duration; url = tagFile.Tag.Copyright; if (fileTypes[i].Split('.').Last() == "Local") { playlist.MediaList.Add(new Local(fileLists[i], title, artist, album, duration.ToString(@"mm\:ss"), bitmapImage, fileLists[i].Split('\\').Last())); } else { playlist.MediaList.Add(new Youtube(fileLists[i], title, artist, album, duration.ToString(@"mm\:ss"), bitmapImage, fileLists[i].Split('\\').Last(), url)); } } catch (FileNotFoundException) { MessageBox.Show("File not Found : " + fileLists[i].Split('\\').Last()); playlists.ListOfPlaylist[playlistIndex].MediaList.RemoveAll(file => file.GetPath() == fileLists[i]); Playlists.SerializeToXml(playlists); } catch (Exception exception) { MessageBox.Show(exception.ToString()); } } foreach (var item in playlist.MediaList) { dtPlayList.Items.Add(item); } }
public Playlists AddAlbumAsPlaylist(Albums a, ISession session) { Playlists p = new Playlists(); p.songs = new List <Songs>(); using (var transaction = session.BeginTransaction()) { session.SaveOrUpdate(a); foreach (Playlists playlist in session.QueryOver <Playlists>().List <Playlists>()) { if (playlist.Name == a.Title) { return(null); } } foreach (Songs s in a.songs) { p.songs.Add(s); } p.Name = a.Title; p.Users_Id = loggedUser; session.Save(p); transaction.Commit(); } return(p); }
/// <summary> /// hinzufügen einer neuen Playlist /// </summary> private void AddPlaylist() { tpadd.Visibility = Visibility.Hidden; string plvalue = tpadd.tbflex.Text; if (Playlists.GetPlaylistNames.Contains(plvalue)) { var resultDialog = MessageBox.Show("Soll die Wiedergabeliste überschrieben werden?", "Wiedergabeliste schon vorhanden", MessageBoxButton.YesNoCancel, MessageBoxImage.Question); switch (resultDialog) { case MessageBoxResult.Yes: tpadd.tbflex.Text = String.Empty; int pl = Playlists.GetPlaylistNames.IndexOf(plvalue); Playlists.GetPlaylists[pl].Playlist = plvalue; Playlists.GetPlaylists[pl].PlaylistConditionGroups.Clear(); ResetDatabinds(); break; case MessageBoxResult.No: tpadd.Visibility = Visibility.Visible; break; } } else { Playlists.Add(new PlaylistClass(plvalue)); Functions.PlaylistChanged = true; lbPlaylist.ItemsSource = null; lbPlaylist.ItemsSource = Playlists.GetPlaylistNames; tpadd.tbflex.Text = String.Empty; lbPlaylist.SelectedIndex = Playlists.GetPlaylistNames.IndexOf(plvalue); } }
public bool Eliminar(int idPlaylist) { bool respuesta; try { Playlists playlistCargada = CargarPorId(idPlaylist); using (UVFYContext context = new UVFYContext()) { playlistCargada = context.Playlists.Find(idPlaylist); if (playlistCargada == null) { throw new RecursoNoExisteException(); } context.Playlists.Remove(playlistCargada); context.SaveChanges(); } respuesta = true; } catch (SqlException e) { Console.WriteLine(e.ToString()); throw new AccesoADatosException(e.Message, e); } return(respuesta); }
public bool Registrar(string nombreDePlaylist, int idUsuario) { bool respuesta = false; Playlists playlistConvertida = new Playlists() { Nombre = nombreDePlaylist, }; if (ValidarParaGuardar(playlistConvertida)) { ConsumidorDAO consumidorDAO = new ConsumidorDAO(); UsuariosConsumidor usuario = consumidorDAO.CargarPorId(idUsuario); playlistConvertida.Consumidor = usuario; try { using (UVFYContext context = new UVFYContext()) { context.Playlists.Add(playlistConvertida); context.Attach(usuario); context.SaveChanges(); respuesta = true; } } catch (SqlException e) { Console.WriteLine(e.ToString()); throw new AccesoADatosException(e.Message, e); } } return(respuesta); }
public bool AgregarCancion(int idPlaylist, int idCancion) { bool respuesta = false; try { Playlists playlist = CargarPorId(idPlaylist); CancionDAO cancionDAO = new CancionDAO(); Canciones cancion = cancionDAO.CargarPorId(idCancion); CancionPlaylist cancionPlaylist = new CancionPlaylist { CancionId = cancion.Id, PlaylistsId = playlist.Id }; using (UVFYContext context = new UVFYContext()) { context.CancionPlaylist.Add(cancionPlaylist); context.SaveChanges(); } respuesta = true; } catch (SqlException e) { Console.WriteLine(e.ToString()); throw new AccesoADatosException(e.Message, e); } catch (DbUpdateException e) { Console.WriteLine(e.ToString()); throw new RecursoYaExisteException(e.Message, e); } return(respuesta); }
public async Task Insert_SingleRow() { var playlists = new Playlists(); var inserted = await playlists.InsertAsync(new { Name = "MassivePlaylist" }); Assert.IsTrue(inserted.PlaylistId > 0); }
public JsonResult getPlayList() { //Se não houver sessão ativa, redireciona para o login if ((string)Session["Token"] == null) { return(Json(false, JsonRequestBehavior.AllowGet)); } else { try { _spotifyApi.Token = (string)Session["Token"]; SpotifyService spotifyService = new SpotifyService(_spotifyApi); //Get user_id and user displayName SpotifyUser spotifyUser = spotifyService.GetUserProfile(); ViewBag.UserName = spotifyUser.DisplayName; //Get user playlists ids Playlists playlists = spotifyService.GetPlaylists(spotifyUser.UserId); //Get all tracks from user List <string> tracks = spotifyService.GetTracksAndArtistsFromPlaylists(playlists); //Generate the new playlist List <string> newPlayList = spotifyService.GenerateNewPlaylist(spotifyUser.DisplayName, tracks); return(Json(newPlayList, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(false, JsonRequestBehavior.AllowGet)); } } }
public virtual void AddPlaylist(Playlist playlist) { // Playlist must be removed from other Folder before AddPlaylist affects it. if (playlist.Folder != null && playlist.Folder.Id != Id) { string message = string.Format("Playlist {0} is already a child of Folder {1}", playlist.Title, playlist.Folder.Title); throw new Exception(message); } if (Playlists.Count == 0) { FirstPlaylist = playlist; playlist.NextPlaylist = playlist; playlist.PreviousPlaylist = playlist; } else { Playlist firstPlayist = FirstPlaylist; Playlist lastPlaylist = firstPlayist.PreviousPlaylist; // Adjust our linked list and add the item. lastPlaylist.NextPlaylist = playlist; playlist.PreviousPlaylist = lastPlaylist; firstPlayist.PreviousPlaylist = playlist; playlist.NextPlaylist = firstPlayist; } playlist.Folder = this; Playlists.Add(playlist); }
public void Insert_SingleRow() { var playlists = new Playlists(); var inserted = playlists.Insert(new { Name = "MassivePlaylist" }); Assert.IsTrue(inserted.PlaylistId > 0); }
/// <summary> /// XML Laden. /// </summary> /// <returns></returns> private Nullable <bool> LoadXML() { //Save Dialog öffnen Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog { FileName = "Playlists", DefaultExt = ".xml", Filter = "XML (.xml)|*.xml" }; // Show save file dialog box Nullable <bool> result = dlg.ShowDialog(); // Process save file dialog box results if (result == true) { try { // Load document result = Playlists.Load(dlg.FileName); } catch (Exception ex) { MessageBox.Show("Es ist ein Fehler beim laden der Playlist aufgetreten." + ex.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Error); } } return(result); }
public void CleanUp() { // delete all rows with ProductName 'Massive Product'. var playlists = new Playlists(); playlists.Delete("Name=@0", "MassivePlaylist"); }
public JsonResult OnPost([FromForm] Playlists newPlaylist) { int loggedUserId; int.TryParse(HttpContext.Session.GetInt32("LoggedUserId").ToString(), out loggedUserId); if (loggedUserId == 0) { return(new JsonResult(new CreatePlaylistStatus { status = false, message = "Please login" })); } newPlaylist.user_id = loggedUserId; _db.playlists.Add(newPlaylist); if (_db.SaveChanges() > 0) { return(new JsonResult(new CreatePlaylistStatus { status = true, message = String.Format("Playlist \"{0}\" was created!", newPlaylist.name), name = newPlaylist.name })); } return(new JsonResult(new CreatePlaylistStatus { status = false, message = "Couldn't create playlist. Try different name" })); }
public async Task <ActionResult <Playlists> > PostPlaylists(Playlists playlists) { _context.Playlists.Add(playlists); await _context.SaveChangesAsync(); return(CreatedAtAction("GetPlaylists", new { id = playlists.Id }, playlists)); }
// Ctor public MainViewModel() { LoadPlaylist(); CurrentPlaylist = Playlists.FirstOrDefault(); CurrentTrack = CurrentPlaylist.TrackList.FirstOrDefault(); }
/// <summary> /// XML Speichern /// </summary> private Boolean SaveXML() { //Save Dialog öffnen Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog { FileName = "Playlists", DefaultExt = ".xml", Filter = "XML (.xml)|*.xml" }; // Show save file dialog box Nullable <bool> result = dlg.ShowDialog(); // Process save file dialog box results if (result == true) { try { // Save document Playlists.Save(dlg.FileName); Functions.PlaylistChanged = false; return(true); } catch { return(false); } } return(true);//Für Abbruchbutton }
public void Save() { if (_isSaving) { return; } _isSaving = true; //Important if the app gets closed var saveThread = new Thread(() => { if (Playlists != null) { Playlists.Save(Paths.BaseDirectory); } if (Config != null) { Config.Save(Paths.BaseDirectory); } if (CurrentState != null) { CurrentState.Save(Paths.BaseDirectory); } _isSaving = false; }) { IsBackground = false, Priority = ThreadPriority.Highest }; saveThread.Start(); }
public async Task <List <IData> > FindAll(string regex) { var searchResults = new List <IData>(); var searchTerm = new Regex(regex, RegexOptions.IgnoreCase | RegexOptions.Compiled); searchResults.AddRange( (await Videos .ToListAsync()) .Where(x => searchTerm.IsMatch(x.Title)) ); searchResults.AddRange( (await Playlists .ToListAsync()) .Where(x => searchTerm.IsMatch(x.Title)) ); searchResults.AddRange( (await PlaylistItems .ToListAsync()) .Where(x => searchTerm.IsMatch(x.Title)) ); return(searchResults); }
public void GenerateLibraryThreadPlaylist(object param) { var handler = (ManualResetEvent)param; try { var files = Directory.GetFiles(PlaylistPath, "*" + PlaylistExtension, SearchOption.AllDirectories); foreach (String file in files) { var playlist = new Playlist(file); lock (Playlists) Playlists.Add(playlist); } } catch (DirectoryNotFoundException) { try { Directory.CreateDirectory(PlaylistPath); } catch (DirectoryNotFoundException) { } } lock (MW) MW.UpdateCurrentPanel(ClickStyle.SELECTION); handler.Set(); }
public async Task <IActionResult> PutPlaylists(long id, Playlists playlists) { if (id != playlists.PlaylistId) { return(BadRequest()); } _context.Entry(playlists).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PlaylistsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
async Task ExecuteLoadChannelCommand() { if (IsBusy) { return; } IsBusy = true; try { Playlists.Clear(); var items = await VideoRepository.LoadChannelAsync(""); foreach (var item in items) { Playlists.Add(item); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } CurrentPlayList = Playlists.FirstOrDefault(pl => pl.Id == "PLlZwsUoL6TOaEwk2wkvVrrZnsSiCl7VKb"); }
public async Task AsListTest() { var res1 = await Playlists.AsList(); Assert.True(res1.Succeeded); Assert.True(0 < res1.Result.Length); }
public async Task GetUriSchemesTest() { var res1 = await Playlists.GetUriSchemes(); Assert.True(res1.Succeeded); Assert.True(0 < res1.Result.Length); }
//Fills ObservableCollection<Sound> Playlists with files found in /user/MyDocuments/AudioPlayer directory. private void FillPlaylist() { string docPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), @"AudioPlayer"); var playlists = new List <Sound>(); try { var allFiles = Directory.GetFiles(docPath); foreach (var file in allFiles) { var pathExtension = Path.GetExtension(file); if (pathExtension?.ToUpper() == ".TXT") { playlists.Add(new Sound() { Name = Path.GetFileNameWithoutExtension(file), Path = file }); } } Playlists.Clear(); playlists.ForEach(c => Playlists.Add(c)); } catch (Exception e) { MessageBox.Show(e.Message); } }
public void LoadPlaylists(string path) { using (FileStream fileStream = File.OpenRead(@path)) using (StreamReader reader = new StreamReader(fileStream)) { while (!reader.EndOfStream) { int i = 0; string line = reader.ReadLine(); if (line == "" || line[0] == '#') { continue; } string[] values = line.Split(','); Playlist playlist = new Playlist(); playlist.Id = Int32.Parse(values[i++]); playlist.Title = values[i++]; playlist.Owner = GetUser(values[i++]); playlist.Rating = float.Parse(values[i++]); Playlists.Add(playlist); } } }
public Playlists GetPlaylists(bool includeTracks = true) { Playlists playlists = null; string jsArray = String.Format(@"[[""{0}"",1],[""all""]]", _sessionId); string response = GoogleMusicService(Service.loadplaylists, jsArray); if (!String.IsNullOrEmpty(response)) { ArrayList array = (_parser.Parse(response)[1] as ArrayList)[0] as ArrayList; playlists = new Playlists(); playlists.lastUpdatedTimestamp = DateTime.Now; foreach (ArrayList pl in array) { Playlist playlist = new Playlist(); for (int i = 0; i < playlistProperties.Length; i++) { string property = playlistProperties[i]; if (!String.IsNullOrEmpty(property)) { MethodInfo info = typeof(Playlist).GetMethod("set_" + property, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (info != null && i < pl.Count) { object pli = pl[i]; if (pli != null) pli = Convert.ChangeType(pli, info.GetParameters()[0].ParameterType); info.Invoke(playlist, new[] { pli }); } else ThrowError(String.Format("Playlist property '{0}' not matched!", property)); } } playlists.Add(playlist); } if (includeTracks) { foreach (Playlist playlist in playlists) playlist.entries = GetPlaylistEntries(playlist.id).entries; } } return playlists; }