public void NoSelection4MusicHasPriority1() { var musicA = new Music("A") { Priority = 1 }; var musicB = new Music("B") { Priority = 1 }; var musicC = new Music("C") { Priority = 1 }; var musicD = new Music("D") { Priority = 1 }; _store.SetupGetMusic(musicA); _store.SetupGetMusic(musicB); _store.SetupGetMusic(musicC); _store.SetupGetMusic(musicD); _musicLibrary.Add(musicA); _musicLibrary.Add(musicB); _musicLibrary.Add(musicC); _musicLibrary.Add(musicD); var playList = new PlayList(_musicLibrary) {"A","B","C","D"}; playList.UpdateProbability(); const double unitProbability = 1d / 4d; Assert.AreEqual(unitProbability, playList["A"].Probability); Assert.AreEqual(unitProbability, playList["B"].Probability); Assert.AreEqual(unitProbability, playList["C"].Probability); Assert.AreEqual(unitProbability, playList["D"].Probability); Assert.AreEqual(unitProbability * 1, playList["A"].CumulativeProbability); Assert.AreEqual(unitProbability * 2, playList["B"].CumulativeProbability); Assert.AreEqual(unitProbability * 3, playList["C"].CumulativeProbability); Assert.AreEqual(unitProbability * 4, playList["D"].CumulativeProbability); }
public bool Load(PlayList playlist, string fileName) { playlist.Clear(); XmlNodeList nodeEntries; if (!LoadXml(fileName, out nodeEntries)) return false; try { string basePath = Path.GetDirectoryName(Path.GetFullPath(fileName)); foreach (XmlNode node in nodeEntries) { string file = ReadFileName(node); if (file == null) return false; string infoLine = ReadInfoLine(node, file); int duration = ReadLength(node); SetupTv.Utils.GetQualifiedFilename(basePath, ref file); PlayListItem newItem = new PlayListItem(infoLine, file, duration); playlist.Add(newItem); } return true; } catch (Exception) { return false; } }
public void Serialize(string path, PlayList playList) { using (var stream = new FileStream(path, FileMode.Create)) { Serialize(stream, playList); } }
/// <summary> /// Parse the Playlist items /// </summary> /// <param name="playlist">PlayList playlist</param> /// <returns></returns> public PlayList getPlayList(string playlist) { if (playlist.Contains("#EXTM3U")) { _playlist = parsePlaylist(playlist, PlayListType.m3u); } if (playlist.Contains("<playlist version=\"1\" xmlns")) { _playlist = parsePlaylist(playlist, PlayListType.xspf); } if (playlist.Contains("[playlist]")) { _playlist = parsePlaylist(playlist, PlayListType.pls); } if (playlist.Contains("<ASX version=\"3\">")) { _playlist = parsePlaylist(playlist, PlayListType.asx); } //if (playlist.Contains("&clipinfo=\"title=")) //{ // RAMParser ramparser = new RAMParser(); // ramparser.Parse(playlist); // playlistitem = ramparser.PlayListe; //} if (_playlist.Count == 0) { throw new Exception("Can not parse Playlist"); } return _playlist; }
public bool Save(PlayList playlist, string fileName) { try { XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.OmitXmlDeclaration = true; using (XmlWriter writer = XmlWriter.Create(fileName, settings)) { writer.WriteStartElement("WinampXML"); writer.WriteStartElement("playlist"); writer.WriteAttributeString("num_entries", playlist.Count.ToString()); writer.WriteAttributeString("label", playlist.Name); foreach (PlayListItem item in playlist) { writer.WriteStartElement("entry"); writer.WriteAttributeString("Playstring", "file:" + item.FileName); writer.WriteElementString("Name", item.Description); writer.WriteElementString("Length", item.Duration.ToString()); writer.WriteEndElement(); } writer.WriteEndElement(); writer.WriteEndElement(); } return true; } catch (Exception e) { Log.Info("failed to save a playlist {0}. err: {1} stack: {2}", fileName, e.Message, e.StackTrace); return false; } }
public void Play() { selectedList = new PlayList(0, null); if (selectedModels.Count == 0) selectedList = playlist; else { foreach(Composition comp in selectedModels) { selectedList.AddComposition(comp); } } // ButtonEnabled = false; selectedList.IsStop = false; NotifyPropertyChanged("ButtonEnabled"); selectedList.Complete += Stop; selectedList.GetProcessLength += Process; selectedList.Step += Step; selectedList.Reset += Reset; thread = new Thread(selectedList.Play); thread.IsBackground = true; thread.Start(); PlayCommand = new Command(action => Pause()); NotifyPropertyChanged("PlayCommand"); PlayButtonContent = "Pause"; NotifyPropertyChanged("PlayButtonContent"); }
public void NoSelection4Music2Classic() { var musicA = new Music("A") { Priority = 1 }; musicA[Constants.Tags.Genre] = "Classic"; var musicB = new Music("B") { Priority = 2 }; var musicC = new Music("C") { Priority = 3 }; musicC[Constants.Tags.Genre] = "Classic"; var musicD = new Music("D") { Priority = 4 }; _store.SetupGetMusic(musicA); _store.SetupGetMusic(musicB); _store.SetupGetMusic(musicC); _store.SetupGetMusic(musicD); _musicLibrary.Add(musicA); _musicLibrary.Add(musicB); _musicLibrary.Add(musicC); _musicLibrary.Add(musicD); var playList = new PlayList(_musicLibrary) { "A", "B", "C", "D" }; playList.UpdateProbability(); const double totalPriority = 10d; const double unitProbability = 1d / totalPriority; _store.VerifyAll(); AreEqual(unitProbability * musicA.Priority, playList["A"].Probability); AreEqual(unitProbability * musicB.Priority, playList["B"].Probability); AreEqual(unitProbability * musicC.Priority, playList["C"].Probability); AreEqual(unitProbability * musicD.Priority, playList["D"].Probability); AreEqual(unitProbability * 1, playList["A"].CumulativeProbability); AreEqual(unitProbability * 3, playList["B"].CumulativeProbability); AreEqual(unitProbability * 6, playList["C"].CumulativeProbability); AreEqual(unitProbability * 10, playList["D"].CumulativeProbability); }
private void addToPlButton_Click(object sender, EventArgs e) { try { string plName = PlBox.Text; Int32 selectedRowCount = plContentGrid.Rows.GetRowCount(DataGridViewElementStates.Selected); int[] row = new int[selectedRowCount]; for (int i = 0; i < selectedRowCount; ++i) { row[i] = plContentGrid.SelectedRows[i].Index; } PlayList pl; for (int i = 0; i < selectedRowCount; ++i) { pl = new PlayList(plName, Album.GetAlbumId(_pelems[row[i]].AlbumName), Artist.CheckArtist(_pelems[row[i]].ArtistName), TrackList.GetTrackId(_pelems[row[i]].TrackName)); pl.Create(); } MessageBox.Show("Done!^_^", "TheResult"); } catch { MessageBox.Show("Something bad has happened =(", "Whoops!"); } }
public void NewlyAddedSongsAreNotMarkedPlayed() { PlayList pl = new PlayList(); PlayListItem item = new PlayListItem("my song", "myfile.mp3"); pl.Add(item); Assert.IsFalse(pl.AllPlayed()); }
public void Serialize(Stream stream, PlayList playList) { if (stream == null) throw new ArgumentNullException("stream"); if (playList == null) throw new ArgumentNullException("playList"); _serializer.WriteObject(stream, playList); }
public Player(PlayList playList) { if (playList == null) throw new ArgumentNullException("playList"); _playList = playList; _track = _playList.GetFirstTrack(); State = PlayerStop.Instance; }
public void LoadB4S() { PlayList playlist = new PlayList(); IPlayListIO loader = new PlayListB4sIO(); Assert.IsTrue(loader.Load(playlist, "Core\\Playlists\\TestData\\exampleList.b4s")); Assert.AreEqual(@"E:\Program Files\Winamp3\demo.mp3", playlist[0].FileName); Assert.AreEqual(@"E:\Program Files\Winamp3\demo2.mp3", playlist[1].FileName); Assert.AreEqual(2, playlist.Count); }
public void RemoveReallyRemovesASong() { PlayList pl = new PlayList(); PlayListItem item = new PlayListItem("my song", "myfile.mp3"); pl.Add(item); pl.Remove("myfile.mp3"); Assert.AreEqual(0, pl.Count); }
public void RaiseContentChangeWhenAddItemToPlayList() { var newItem = new PlayListItem(new ImageId(30), ""); var playListListener = MockRepository.GenerateMock<PlayListListener>(); playListListener.Expect(l => l.ContentChanged(new PlayListContent(0, "", new []{newItem}))); var playList = new PlayList(new PlayListContent(0, "", new PlayListItem[0]), null); playList.AddListener(playListListener); playList.AddItem(newItem); }
public void UpdateListViewWhenContentOfPlayListChange() { var playList = new PlayList(new PlayListContent(2, "name", new PlayListItem[0]), null); m_Model.SelectedPlayListChanged(playList); var newItem = new PlayListItem(new ImageId(33), "trentatre"); playList.AddItem(newItem); Assert.That(GetPlayListItemsInListView(), Is.EquivalentTo(new[] {newItem})); }
public void LoadM3U() { PlayList playlist = new PlayList(); IPlayListIO loader = new PlayListM3uIO(); Assert.IsTrue(loader.Load(playlist, "Core\\Playlists\\TestData\\exampleList.m3u"), "playlist could not even load!"); Assert.IsTrue(playlist[0].FileName.EndsWith("Bob Marley - 01 - Judge Not.mp3")); Assert.IsTrue(playlist[1].FileName.EndsWith("Bob Marley - 02 - One Cup of Coffee.mp3")); Assert.IsTrue(playlist[2].FileName.EndsWith("Bob Marley - 03 - Simmer Down.mp3")); Assert.IsTrue(playlist[3].FileName.EndsWith("Bob Marley - 05 - Guava Jelly.mp3")); }
public PlayListViewModel(PlayList playList,string name) { Maximum = 5; ButtonEnabled = true; PlayCommand = new Command(action => Play()); StopCommand = new Command(action => Stop()); PlayButtonContent = "Play"; this.playlist = playList; header = name; }
public void LoadTest() { PlayList playlist = new PlayList(); IPlayListIO loader = new PlayListWPLIO(); Assert.IsTrue(loader.Load(playlist, "Core\\Playlists\\TestData\\exampleList.wpl")); string lastName = playlist[playlist.Count - 1].FileName; Assert.IsTrue(playlist[0].FileName.EndsWith("01-chant_down_babylon-rev.mp3")); Assert.IsTrue(playlist[1].FileName.EndsWith("06-blackman_redemption-rev.mp3")); Assert.IsTrue(lastName.EndsWith("satisfy_my_soul_babe_(version)-just.mp3")); }
public void AllPlayedReturnsTrueWhenAllArePlayed() { PlayList pl = new PlayList(); PlayListItem item = new PlayListItem("my song", "myfile.mp3"); item.Played = true; pl.Add(item); item = new PlayListItem("my 2:d song", "myfile2.mp3"); item.Played = true; pl.Add(item); Assert.IsTrue(pl.AllPlayed()); }
public void UplaodListViewOnlyForChnageInSelectedPlayList() { var playList1 = new PlayList(new PlayListContent(1, "name", new PlayListItem[0]), null); var playList2 = new PlayList(new PlayListContent(2, "name", new PlayListItem[0]), null); m_Model.SelectedPlayListChanged(playList1); m_Model.SelectedPlayListChanged(playList2); m_Model.SelectedPlayListChanged(playList1); var newItem = new PlayListItem(new ImageId(33), "trentatre"); playList2.AddItem(newItem); Assert.That(GetPlayListItemsInListView(), Is.Empty); }
public bool Load(PlayList playlist, string fileName) { playlist.Clear(); try { string basePath = Path.GetDirectoryName(Path.GetFullPath(fileName)); XmlDocument doc = new XmlDocument(); doc.Load(fileName); if (doc.DocumentElement == null) { return false; } XmlNode nodeRoot = doc.DocumentElement.SelectSingleNode("/asx"); if (nodeRoot == null) { return false; } XmlNodeList nodeEntries = nodeRoot.SelectNodes("entry"); foreach (XmlNode node in nodeEntries) { XmlNode srcNode = node.SelectSingleNode("ref"); if (srcNode != null) { XmlNode url = srcNode.Attributes.GetNamedItem("href"); if (url != null) { if (url.InnerText != null) { if (url.InnerText.Length > 0) { fileName = url.InnerText; if (!(fileName.ToLowerInvariant().StartsWith("http") || fileName.ToLowerInvariant().StartsWith("mms") || fileName.ToLowerInvariant().StartsWith("rtp"))) continue; PlayListItem newItem = new PlayListItem(fileName, fileName, 0); newItem.Type = PlayListItem.PlayListItemType.Audio; playlist.Add(newItem); } } } } } return true; } catch (Exception ex) { Log.Info("exception loading playlist {0} err:{1} stack:{2}", fileName, ex.Message, ex.StackTrace); } return false; }
public Application() { var path = System.AppDomain.CurrentDomain.BaseDirectory + "\\playlists\\"; foreach (FileInfo file in new DirectoryInfo(path).GetFiles("*.pl")) playlists.Add(PlayList.Load(file.Name.Split('.')[0])); if (playlists.Count > 0) currentPlayList = playlists[0]; thread = new Thread(new ThreadStart(Process)); thread.Start(); currentTrack.Play(); }
public void AddPlayList() { if (SelectedModels.Count != 0) { PlayList list = new PlayList(ID, Name); foreach (Composition comp in SelectedModels) { list.AddComposition(comp); } PlayListViewModel playlist = new PlayListViewModel(list, Name); viewModels.Add(playlist); NotifyPropertyChanged(String.Empty); } }
public bool Load(PlayList playlist, string fileName) { playlist.Clear(); try { string basePath = Path.GetDirectoryName(Path.GetFullPath(fileName)); XmlDocument doc = new XmlDocument(); doc.Load(fileName); if (doc.DocumentElement == null) { return false; } XmlNode nodeRoot = doc.DocumentElement.SelectSingleNode("/smil/body/seq"); if (nodeRoot == null) { return false; } XmlNodeList nodeEntries = nodeRoot.SelectNodes("media"); foreach (XmlNode node in nodeEntries) { XmlNode srcNode = node.Attributes.GetNamedItem("src"); if (srcNode != null) { if (srcNode.InnerText != null) { if (srcNode.InnerText.Length > 0) { fileName = srcNode.InnerText; Util.Utils.GetQualifiedFilename(basePath, ref fileName); PlayListItem newItem = new PlayListItem(fileName, fileName, 0); newItem.Type = PlayListItem.PlayListItemType.Audio; string description; description = Path.GetFileName(fileName); newItem.Description = description; playlist.Add(newItem); } } } } return true; } catch (Exception ex) { Log.Info("exception loading playlist {0} err:{1} stack:{2}", fileName, ex.Message, ex.StackTrace); } return false; }
public PlayList GetPlayList(PluginContext context) { PlayList playList = null; if (typeof(IPlugin).IsAssignableFrom(_type)) { var pluginResponse = OldInstance.GetList(context); playList = new RemoteFork.Plugins.Items.Converter.PlayList(pluginResponse); } else if (typeof(IRemotePlugin).IsAssignableFrom(_type)) { playList = Instance.GetPlayList(context); } return(playList); }
private void comboBoxPlayList_SelectedValueChanged(object sender, EventArgs e) { if (ExistPlayList(this.comboBoxPlayList.Text)) { this.playList = this.ReturnPlayList(this.comboBoxPlayList.Text); this.LoadPlaylistSounds(); } else if (String.IsNullOrWhiteSpace(this.comboBoxPlayList.Text) && String.IsNullOrEmpty(this.comboBoxPlayList.Text)) { this.playList = new PlayList() { Name = this.comboBoxPlayList.Text }; this.SavePlayList(playList); this.RefreshList(); } }
public PlaylistDetailPage(PlayList playlist) { _baseViewModel = new BaseViewModel(); _playListDetailPageViewModel = new PlaylistDetailPageViewModel(); BackgroundColor = Color.FromHex("#F1ECCE"); Title = playlist.Name; #if __ANDROID__ Padding = new Thickness(5, 5, 5, 5); #endif #if __IOS__ Padding = new Thickness(10, 30, 10, 10); #endif userPlaylist = playlist; FindPlaylist(); SetContent(); }
/// <summary> /// 재생목록내 파일을 삭제한다. /// </summary> /// <returns>DB 처리 결과</returns> public SQLiteResult DeletePlayListFiles(PlayList ownerPlayList, IEnumerable <PlayListFile> playListFiles) { return(Transactional(() => { SQLiteResult result = SQLiteResult.EMPTY; using (var pstmt = this.conn.Prepare(DML_DELETE_PLAYLIST_FILE)) { List <string> subtitleList = new List <string>(); foreach (PlayListFile playListFile in playListFiles) { if (playListFile.SubtitleList != null && playListFile.SubtitleList.Count > 0) { subtitleList.AddRange(playListFile.SubtitleList); } pstmt.Bind("@OWNER_SEQ", ownerPlayList.Seq); pstmt.Bind("@PATH", playListFile.Path); result = pstmt.Step(); if (result != SQLitePCL.SQLiteResult.DONE) { return result; } // Resets the statement, to that it can be used again (with different parameters). pstmt.Reset(); pstmt.ClearBindings(); } foreach (string path in subtitleList) { pstmt.Bind("@OWNER_SEQ", ownerPlayList.Seq); pstmt.Bind("@PATH", path); pstmt.Step(); // Resets the statement, to that it can be used again (with different parameters). pstmt.Reset(); pstmt.ClearBindings(); } } return result; })); }
public async Task GetPlayListByIDAsyncShouldReturnPlayList() { using (var context = new MusicDBContext(options)) { IMusicRepoDB _repo = new MusicRepoDB(context); PlayList testPlayList = new PlayList(); testPlayList.Id = 4; testPlayList.UserId = 1; testPlayList.Name = "Songs to git gud too"; var newPlayList = await _repo.AddPlayListAsync(testPlayList); var foundPlayList = await _repo.GetPlayListByIDAsync(4); Assert.NotNull(foundPlayList); Assert.Equal(4, foundPlayList.Id); } }
protected void DeleteTrack_Click(object sender, EventArgs e) { if (PlayList.Rows.Count == 0) { MessageUserControl.ShowInfo("Warning", "No playlist has been retreived."); } else { // check if playlist name field is empty if (string.IsNullOrEmpty(PlaylistName.Text)) { MessageUserControl.ShowInfo("Warning", "No playlist name has been supplied."); } else { // collect the selected tracks to delete List <int> trackstodelete = new List <int>(); int selectedrows = 0; CheckBox playlistselection = null; for (int i = 0; i < PlayList.Rows.Count; i++) { playlistselection = PlayList.Rows[i].FindControl("Selected") as CheckBox; if (playlistselection.Checked) { trackstodelete.Add(int.Parse((PlayList.Rows[i].FindControl("TrackId") as Label).Text)); selectedrows++; } } if (selectedrows == 0) { MessageUserControl.ShowInfo("Information", "No playlist tracks have been selected."); } else { // at this point you have your required data, now send to BLL for processing MessageUserControl.TryRun(() => { PlaylistTracksController sysmgr = new PlaylistTracksController(); List <UserPlaylistTrack> playlistdata = sysmgr.DeleteTracks(User.Identity.Name, PlaylistName.Text, trackstodelete); PlayList.DataSource = playlistdata; PlayList.DataBind(); }, "Removed", "Track(s) have been removed."); } } } }
/// <summary> /// The OutputReadLine /// </summary> /// <param name="process">The process<see cref="Process"/></param> /// <param name="line">The line<see cref="string"/></param> public void OutputReadLine(Process process, string line) { Match m; if (line.StartsWith("[youtube:playlist]")) { if ((m = _regexPlaylistInfo.Match(line)).Success) { // Get the playlist info var name = m.Groups[1].Value; var onlineCount = int.Parse(m.Groups[2].Value); this.PlayList = new PlayList(_playlist_id, name, onlineCount); } } else if (line.StartsWith("[info]")) { // New json found, break & create a VideoInfo instance if ((m = _regexVideoJson.Match(line)).Success) { _jsonPaths.Add(m.Groups[1].Value.Trim()); } } else if (line.StartsWith("[download]")) { if ((m = _regexPlaylistIndex.Match(line)).Success) { var i = -1; if (int.TryParse(m.Groups[1].Value, out i)) { _currentVideoPlaylistIndex = i; } else { throw new Exception($"PlaylistReader: Couldn't parse '{m.Groups[1].Value}' to integer for '{nameof(_currentVideoPlaylistIndex)}'"); } } } else if (line.StartsWith("[youtube]")) { if ((m = _regexVideoID.Match(line)).Success) { _currentVideoID = m.Groups[1].Value; } } }
public PlayListResponse AddPlayList(AddPlayListRequest request, Guid idUser) { User user = _repositoryUser.Get(idUser); PlayList playList = new PlayList(request.Name, user); AddNotifications(playList); if (this.IsInvalid()) { return(null); } playList = _repositoryPlayList.Add(playList); return((PlayListResponse)playList); }
public PlayListResponse AdicionarPlayList(AdicionarPlayListRequest request, Guid idUsuario) { Usuario usuario = _repositoryUsuario.Obter(idUsuario); PlayList playList = new PlayList(request.Nome, usuario); AddNotifications(playList); if (this.IsInvalid()) { return(null); } playList = _repositoryPlayList.Adicionar(playList); return((PlayListResponse)playList); }
private void button10_Click(object sender, EventArgs e) { if (Media_Player.playState == WMPLib.WMPPlayState.wmppsPlaying) { if (PlayList.SelectedIndex > 0) { Media_Player.Ctlcontrols.previous(); PlayList.SelectedIndex -= 1; PlayList.Update(); } else { PlayList.SelectedIndex = 0; PlayList.Update(); } } }
public IActionResult Create(PlayListCreateViewModel model) { var currentUserId = this._signInManager.UserManager.GetUserId(HttpContext.User); _currentMediaUser = _mediaService.GetAllMediaUsers().First(p => p.Id == currentUserId); var newPlayList = new PlayList() { Name = model.Name, MediaList = new List <Media>(), MediaUser = _currentMediaUser, MediaUserId = currentUserId }; _currentMediaUser.Playlists.Add(newPlayList); _mediaService.SaveChanges(); return(RedirectToAction("Index")); }
protected void DeleteTrack_Click(object sender, EventArgs e) { //code to go here string username = "******"; if (string.IsNullOrEmpty(PlaylistName.Text)) { MessageUserControl.ShowInfo("Missing Data", "Enter a playlist name"); } else { if (PlayList.Rows.Count == 0) { MessageUserControl.ShowInfo("Missing Data", "Playlist has no tracks to remove."); } else { List <int> tracksToDelete = new List <int>(); int rowsSelected = 0; CheckBox playlistSelection = null; for (int i = 0; i < PlayList.Rows.Count; i++) { playlistSelection = PlayList.Rows[i].FindControl("Selected") as CheckBox; if (playlistSelection.Checked) { rowsSelected++; tracksToDelete.Add(int.Parse((PlayList.Rows[i].FindControl("TrackID") as Label).Text)); if (rowsSelected == 0) { MessageUserControl.ShowInfo("No data", "You must select at least one track to remove"); } else { MessageUserControl.TryRun(() => { PlaylistTracksController sysmgr = new PlaylistTracksController(); sysmgr.DeleteTracks(username, PlaylistName.Text, tracksToDelete); List <UserPlaylistTrack> info = sysmgr.List_TracksForPlaylist(PlaylistName.Text, username); PlayList.DataSource = info; PlayList.DataBind(); }, "Remove Tracks", "Track(s) have been Removed"); } } } } } }
async Task <int> onLoadList__(object ___notUsed___) { Bpr.Beep1of2(); var sw = Stopwatch.StartNew(); int ttlRows = await Task.Run(() => { _db.MediaUnits.Take(7).Load(); return(_db.MediaUnits.Local.Count()); }); //{ Task.Delay(3333); return DateTime .Now.Millisecond; }); PlayList.ClearAddRange(_db.MediaUnits.Local); if (PlayList.Count() > 0) { CurMediaUnit = PlayList[0]; } TopLefttInfo = $"{PlayList.Count()} songs loaded in {.001 * sw.ElapsedMilliseconds:N1} sec. "; Bpr.Beep2of2(); return(ttlRows); }
private void NextBtn_Click(object sender, EventArgs e) { if (Media_Player.playState == WMPLib.WMPPlayState.wmppsPlaying) { if (PlayList.SelectedIndex < (PlayList.Items.Count - 1)) { Media_Player.Ctlcontrols.next(); PlayList.SelectedIndex += 1; PlayList.Update(); } else { PlayList.SelectedIndex = 0; PlayList.Update(); } } }
public async Task <bool> UpdateUserPlaylists(string url, PlayList playlist) { string jsonObject = JsonConvert.SerializeObject(playlist); StringContent content = new StringContent(jsonObject, Encoding.UTF8, "application/json"); try { var response = await client.PostAsync(url, content); return(response.IsSuccessStatusCode); } catch (HttpRequestException ex) { Console.WriteLine(ex.Message); return(false); } }
public void ResetSetsAllItemsToFalse() { PlayList pl = new PlayList(); PlayListItem item = new PlayListItem("my song", "myfile.mp3"); pl.Add(item); PlayListItem item2 = new PlayListItem("my 2:d song", "myfile2.mp3"); pl.Add(item2); pl[0].Played = true; pl[1].Played = true; pl.ResetStatus(); Assert.IsFalse(pl[0].Played); Assert.IsFalse(pl[1].Played); }
public AdicionarVideoResponse AdicionarVideo(AdicionarVideoRequest request, Guid id) { if (request == null) { AddNotification("AdicionarVideoRequest", MSG.X0_NAO_INFORMADO.ToFormat("AdicionarVideoRequest")); } var usuario = _repositoryUsuario.Obter(id); if (usuario == null) { AddNotification("Usuario", MSG.OBJETO_X0_E_OBRIGATORIO.ToFormat("Usuario")); } var canal = _repositoryCanal.Obter(request.IdCanal); if (canal == null) { AddNotification("Canal", MSG.OBJETO_X0_E_OBRIGATORIO.ToFormat("Canal")); } PlayList playList = null; if (request.IdPlayList != Guid.Empty) { playList = _repositoryPlayList.Obter(request.IdPlayList); if (playList == null) { AddNotification("PlayList", MSG.OBJETO_X0_E_OBRIGATORIO.ToFormat("PlayList")); } } Video video = new Video(canal, playList, request.Titulo, request.Descricao, request.Tags, request.OrdemNaPlaylist, request.IdVideoYoutube, usuario); AddNotifications(video); if (this.IsInvalid()) { return(null); } ; _repositoryVideo.Adicionar(video); return(new AdicionarVideoResponse(video.Id)); }
private async void ReadPlaylist() { try { StorageFile fileAsync = await ApplicationData.Current.LocalFolder.GetFileAsync(this.playlistname); StorageFile storageFile = fileAsync; IInputStream inputStream = await storageFile.OpenSequentialReadAsync(); try { DataContractSerializer dataContractSerializer = new DataContractSerializer(typeof(PlayList)); PlayList playList = dataContractSerializer.ReadObject(inputStream.AsStreamForRead()) as PlayList; this.internal_playlist = playList; } finally { if (inputStream != null) { inputStream.Dispose(); } } StorageFile fileAsync1 = await ApplicationData.Current.LocalFolder.GetFileAsync(this.shuffleplaylistname); storageFile = fileAsync1; IInputStream inputStream1 = await storageFile.OpenSequentialReadAsync(); try { DataContractSerializer dataContractSerializer1 = new DataContractSerializer(typeof(PlayList)); PlayList playList1 = dataContractSerializer1.ReadObject(inputStream1.AsStreamForRead()) as PlayList; this.shuffle_internal_playlist = playList1; } finally { if (inputStream1 != null) { inputStream1.Dispose(); } } } catch (Exception exception) { } }
public IEnumerable <WebPlaylistItem> GetPlaylistItems(string playlistId) { PlayList mpPlaylist = new PlayList(); string path = GetPlaylistPath(playlistId); IPlayListIO factory = PlayListFactory.CreateIO(path); if (factory.Load(mpPlaylist, path)) { List <WebPlaylistItem> retList = new List <WebPlaylistItem>(); foreach (PlayListItem i in mpPlaylist) { WebPlaylistItem webItem = new WebPlaylistItem(); WebMusicTrackBasic track = LoadAllTracks <WebMusicTrackBasic>().FirstOrDefault(x => x.Path.Contains(i.FileName)); webItem.Title = i.Description; webItem.Duration = i.Duration; webItem.Path = new List <String>(); webItem.Path.Add(i.FileName); if (track != null) { webItem.Id = track.Id; webItem.Type = track.Type; webItem.DateAdded = track.DateAdded; } else { Log.Warn("Couldn't get track information for " + i.FileName); } retList.Add(webItem); } return(retList); } else if (new FileInfo(path).Length == 0) { // for newly created playlists, return an empty list, to make sure that a CreatePlaylist call followed by an AddItem works return(new List <WebPlaylistItem>()); } else { Log.Warn("Couldn't load playlist {0}", playlistId); return(null); } }
public CreatePlayList(PlayList playList) { InitializeComponent(); if (playList != null) { PlayListName.Text = playList.Name; PlayListName.IsEnabled = false; musicsListView.ItemsSource = new ObservableCollection <Music>(playList.musicList); } else { PlayListName.Text = ""; musicsListView.ItemsSource = new ObservableCollection <Music>(); } }
//前の動画へ public void Prev() { if (PlayList.Count == 1) { return; } var index = PlayList.IndexOf(SelectedPlayList); if (index <= 0) { SelectedPlayList = PlayList.Last(); } else { SelectedPlayList = PlayList[index - 1]; } }
public void DoAddSelectedSongsToNewPlayList(object sender, RoutedEventArgs args) { PlayList pl = new PlayList() { Name = "New Playlist" }; foreach (ListBox lb in InnerListBoxes) { foreach (Song s in lb.SelectedItems) { pl.SongList.Add(s); } } ParentWindow.SongLibrary.PlayListList.Add(pl); ParentWindow.UpdatePlayListContextMenuItems(); ParentWindow.AsyncSerialize(ParentWindow.BackgroundCallback); }
public Task <PlayList> AddToPlayListAsync(string Video) { string id; string title; id = Helpers.Video.ExtraerId(Video); title = id; PlayList playVideo = new PlayList { Id = id, Title = title, Url = Video }; return(Task.FromResult(playVideo)); }
public async Task <ActionResult <PlayListDto> > CreatePlayList(int userId, CreatePlayListDto createPlayListDto) { var playlist = new PlayList { Name = createPlayListDto.Name, TrackCount = createPlayListDto.TrackCount, Tracks = new Collection <Track>(), User = await _unitOfWork.UserRepository.GetUserByIdAsync(userId) }; _unitOfWork.PlayListRepository.AddItem(playlist); if (await _unitOfWork.Complete()) { return(Ok(_mapper.Map <PlayListDto>(playlist))); } return(BadRequest("Unable to create Play List")); }
public async Task <List <PlayList> > GeneratePlayLists(int range) { var playLists = new List <PlayList>(); for (var playlistNumber = 1; playlistNumber < range; playlistNumber++) { var playList = new PlayList() { Id = Guid.NewGuid().ToString(), Name = "PlayLista: " + _helper.GetRandomShortString() }; playLists.Add(playList); Context.Add(playList); } await Context.SaveChangesAsync(); return(playLists); }
private void Clear() { if (CurrentPlaylist != null) { if (HasChanges) { if (MessageBox.Show("Do you wish to save changes in " + CurrentPlaylist.PlaylistName + " ?", CurrentPlaylist.PlaylistName, MessageBoxButton.OKCancel) == MessageBoxResult.OK) { this.UpdateList(); } } } CurrentPlaylist = null; PlayList.Clear(); }
public async Task <PlayList> GetTracksById(int playlistId) { var list = new PlayList(); var playListSql = @"select playlist_id as Id,name as Name from playlist where playlist_id = @0 order by playlist_id;"; var tracks = @"SELECT track.track_id as Id,track.name as Name ,(track.milliseconds / 60000)::decimal as Duration ,(track.bytes / 1048576 )::decimal(10,3) as Bytes,track.unit_price::decimal as Price,track.composer as Composer from playlist_track inner join track on track.track_id = playlist_track.track_id where playlist_track.playlist_id = @0 order by composer;"; using (var reader = await _runner.OpenReaderAsync(playListSql + tracks, playlistId)) { if (reader.ReadAsync() != null) { list = reader.ToSingle <PlayList>(); await reader.NextResultAsync(); list.Tracks = reader.ToList <Track>(); } } return(list); }
static void Main(string[] args) { MediaLibrary library = new MediaLibrary(); IPlayList <Video> videoPlayList = new PlayList(); IPlayList <Image> imagePlayList = new PlayList(); IPlayList <Audio> audioPlayList = new PlayList(); videoPlayList.Add(new Video()); imagePlayList.Add(new Image()); audioPlayList.Add(new Audio()); library.AddPlayList((PlayList)audioPlayList); library.AddPlayList((PlayList)videoPlayList); library.AddPlayList((PlayList)imagePlayList); library.PlayAllPlayLists(); Console.ReadKey(); }
public void DoAddSelectedPlaylistsToNewPlayList(object sender, RoutedEventArgs args) { PlayList newPlaylist = new PlayList() { Name = "New Playlist" }; foreach (PlayList pl in PlaylistListBox.SelectedItems) { foreach (Song s in pl.SongList) { newPlaylist.SongList.Add(s); } } ParentWindow.SongLibrary.PlayListList.Add(newPlaylist); ParentWindow.UpdatePlayListContextMenuItems(); ParentWindow.AsyncSerialize(ParentWindow.BackgroundCallback); }
public PlaylistVideoPage(Video video, PlayList playlist) { _baseViewModel = new BaseViewModel(); _playListVideoPageViewModel = new PlaylistVideoPageViewModel(); BackgroundColor = Color.FromHex("#F1ECCE"); videoUrl = video.Link; #if __ANDROID__ Padding = new Thickness(5, 5, 5, 5); #endif #if __IOS__ Padding = new Thickness(10, 30, 10, 10); #endif Title = video.Name; videoTechnique = video; userPlaylist = playlist; SetContent(video, playlist); }
private void DownloadButtonClick(object sender, RoutedEventArgs e) { IsIndeterminate = true; List <PlaylistItem> playlistItems = new List <PlaylistItem>(); PlayList .Split('\n') .Where(s => !string.IsNullOrWhiteSpace(s.Trim())) .ToList(). ForEach(s => playlistItems.Add(new PlaylistItem(this) { Name = s })); new DownloadWindow(_runSettings, playlistItems, this).Show(); Hide(); }
public bool Load(PlayList playlist, string playlistFileName) { playlist.Clear(); try { var doc = new XmlDocument(); doc.Load(playlistFileName); if (doc.DocumentElement == null) return false; XmlNode nodeRoot = doc.DocumentElement.SelectSingleNode("/smil/body/seq"); if (nodeRoot == null) return false; XmlNodeList nodeEntries = nodeRoot.SelectNodes("media"); if (nodeEntries != null) foreach (XmlNode node in nodeEntries) { XmlNode srcNode = node.Attributes.GetNamedItem("src"); if (srcNode != null) { if (srcNode.InnerText != null) { if (srcNode.InnerText.Length > 0) { var playlistUrl = srcNode.InnerText; var newItem = new PlayListItem(playlistUrl, playlistUrl, 0) { Type = PlayListItem.PlayListItemType.Audio }; string description = Path.GetFileName(playlistUrl); newItem.Description = description; playlist.Add(newItem); } } } } return true; } catch (Exception e) { Log.Error(e.StackTrace); } return false; }
public bool Load(PlayList incomingPlaylist, string playlistFileName) { if (playlistFileName == null) return false; playlist = incomingPlaylist; playlist.Clear(); XmlDocument doc = new XmlDocument(); try { doc.Load(playlistFileName); } catch (XmlException e) { MPTVSeriesLog.Write(string.Format("Cannot Load Playlist file: {0}",playlistFileName)); MPTVSeriesLog.Write(e.Message); return false; } try { playlist.Name = Path.GetFileName(playlistFileName); basePath = Path.GetDirectoryName(Path.GetFullPath(playlistFileName)); XmlNodeList nodeList = doc.DocumentElement.SelectNodes("/Playlist/Episode"); if (nodeList == null) return false; foreach (XmlNode node in nodeList) { if (!AddItem(node.SelectSingleNode("ID").InnerText)) return false; } } catch (Exception ex) { MPTVSeriesLog.Write(string.Format("exception loading playlist {0} err:{1} stack:{2}", playlistFileName, ex.Message, ex.StackTrace)); return false; } return true; }
public PlayListView(PlayList pl) : base("PlayList", H1(Text("PlayList "+pl.Name.ToUpper()+" Details")), Form("get", "/playlist/"+pl.Id+"/edit", InputSubmit("Edit PlayList")), P(Text(pl.Description)), Ul( pl.Tracks.OrderBy(x=>x.Key).Select( t => Li(Label("id" , t.Value.Id+". ") ,Label("name" , " Name: "+t.Value.Name) , Label("Album" , " Album: "+t.Value.Album.Name) , Label("Artist", " Artist: "+t.Value.Artist) , Label("Duration" , " Duration: "+t.Value.Duration.ToString()), Form("post" , "/playlist/"+pl.Id+"/changetrackpos/"+t.Key, InputSubmit("Up","Up"), InputSubmit("Down","Down") )) ).ToArray() ), P(Form("get","/playlist/"+pl.Id+"/search",Label("search","Search on Spotify") ,InputSearch("search"))), A(ResolveUri.ForPlayLists(), "PlayLists")) { }
private void createPlButton_Click(object sender, EventArgs e) { try { string plname = plBox.Text; if (plname != "") { Album tempal = Album.GetAlbumID("TestAlbum"); Artist tempar = Artist.CheckArtist("TestBand"); TrackList temptr = TrackList.GetTrackID("Test1"); PlayList pl = new PlayList(plname, tempal, tempar, temptr); pl.Create(); } MainForm.Instance().ChangeControl(new AddMusicSub()); } catch { MessageBox.Show("Something bad has happened =(", "Whoops!"); } }
public bool Load(PlayList playlist, string fileName) { playlist.Clear(); XmlNodeList nodeEntries; if (!LoadXml(fileName, out nodeEntries)) { return false; } try { string basePath = Path.GetDirectoryName(Path.GetFullPath(fileName)); foreach (XmlNode node in nodeEntries) { string file = ReadFileName(node); if (file == null) { return false; } string infoLine = ReadInfoLine(node, file); int duration = ReadLength(node); file = PathUtil.GetAbsolutePath(basePath, file); PlayListItem newItem = new PlayListItem(infoLine, file, duration); playlist.Add(newItem); } return true; } catch (Exception ex) { Log.Info("exception loading playlist {0} err:{1} stack:{2}", fileName, ex.Message, ex.StackTrace); return false; } }