// Console.WriteLine(p.Path); private void ImageClick(object sender, MouseButtonEventArgs e) { Media p = (Media)Image.SelectedItem; if (p != null) { AddSound(p.Path); SoundInfo s = null; foreach (SoundInfo tmp in SoundCollection) { if (tmp.FileName == p.Path) { s = tmp; break; } } if (s != null) { if ((PlaylistCollection.ElementAt(curPlay)).SoundCollection.Count > 0) { SoundInfo p1 = (PlaylistCollection.ElementAt(curPlay)).SoundCollection.ElementAt((PlaylistCollection.ElementAt(curPlay)).cur); p1.Icone = ""; (PlaylistCollection.ElementAt(curPlay)).SoundCollection.RemoveAt((PlaylistCollection.ElementAt(curPlay)).cur); (PlaylistCollection.ElementAt(curPlay)).SoundCollection.Insert((PlaylistCollection.ElementAt(curPlay)).cur, p1); (PlaylistCollection.ElementAt(curPlaylist)).cur = SoundCollection.IndexOf(s); } curPlay = curPlaylist; if (play) { s.Icone = "/MediaPlayer;component/Images/playing.png"; } SoundCollection.RemoveAt((PlaylistCollection.ElementAt(curPlaylist)).cur); SoundCollection.Insert((PlaylistCollection.ElementAt(curPlaylist)).cur, s); liste.SelectedItem = s; RoutedEventArgs newEventArgs = new RoutedEventArgs(SelectedEvent); RaiseEvent(newEventArgs); } } }
public void refreshIcon(string filename) { SoundInfo s = null; foreach (SoundInfo so in SoundCollection) { if (so.FileName == filename) { s = so; break; } } if (s == null) { return; } if ((PlaylistCollection.ElementAt(curPlay)).SoundCollection.Count > 0) { SoundInfo p = (PlaylistCollection.ElementAt(curPlay)).SoundCollection.ElementAt((PlaylistCollection.ElementAt(curPlay)).cur); p.Icone = ""; (PlaylistCollection.ElementAt(curPlay)).SoundCollection.RemoveAt((PlaylistCollection.ElementAt(curPlay)).cur); (PlaylistCollection.ElementAt(curPlay)).SoundCollection.Insert((PlaylistCollection.ElementAt(curPlay)).cur, p); (PlaylistCollection.ElementAt(curPlaylist)).cur = SoundCollection.IndexOf(s); } curPlay = curPlaylist; if (play) { s.Icone = "/MediaPlayer;component/Images/playing.png"; } SoundCollection.RemoveAt((PlaylistCollection.ElementAt(curPlaylist)).cur); SoundCollection.Insert((PlaylistCollection.ElementAt(curPlaylist)).cur, s); liste.SelectedItem = s; RoutedEventArgs newEventArgs = new RoutedEventArgs(SelectedEvent); RaiseEvent(newEventArgs); }
public void AddSound(string filename) { SoundInfo s; if (System.IO.Path.GetExtension(filename) == ".m3u" && System.IO.File.Exists(filename)) SearchPlaylist(filename); else if (System.IO.File.Exists(filename) && (s = isInList(filename)) != null) { if ((PlaylistCollection.ElementAt(curPlay)).SoundCollection.Count > 0) { SoundInfo p1 = (PlaylistCollection.ElementAt(curPlay)).SoundCollection.ElementAt((PlaylistCollection.ElementAt(curPlay)).cur); p1.Icone = ""; (PlaylistCollection.ElementAt(curPlay)).SoundCollection.RemoveAt((PlaylistCollection.ElementAt(curPlay)).cur); (PlaylistCollection.ElementAt(curPlay)).SoundCollection.Insert((PlaylistCollection.ElementAt(curPlay)).cur, p1); (PlaylistCollection.ElementAt(curPlaylist)).cur = SoundCollection.IndexOf(s); } curPlay = curPlaylist; if (play) s.Icone = "/MediaPlayer;component/Images/playing.png"; SoundCollection.RemoveAt((PlaylistCollection.ElementAt(curPlaylist)).cur); SoundCollection.Insert((PlaylistCollection.ElementAt(curPlaylist)).cur, s); liste.SelectedItem = s; RoutedEventArgs newEventArgs = new RoutedEventArgs(SelectedEvent); RaiseEvent(newEventArgs); } else if (System.IO.File.Exists(filename)) { tagFile = TagLib.File.Create(filename); string name = tagFile.Tag.Title; if (tagFile.Tag.Title == null) { name = System.IO.Path.GetFileNameWithoutExtension(filename); } s = new SoundInfo { SoundName = name, FileName = filename, Creator = tagFile.Tag.FirstArtist }; s.media = new MediaElement(); s.media.LoadedBehavior = MediaState.Manual; s.media.UnloadedBehavior = MediaState.Manual; s.media.Source = new Uri(filename); s.media.Pause(); s.media.MediaOpened += new RoutedEventHandler(Opened); if ((PlaylistCollection.ElementAt(curPlaylist)).id == (PlaylistCollection.ElementAt(curPlaylist)).cur && play && curPlaylist == curPlay) s.Icone = "/MediaPlayer;component/Images/playing.png"; SoundCollection.Insert((PlaylistCollection.ElementAt(curPlaylist)).id, s); (PlaylistCollection.ElementAt(curPlaylist)).id++; } else { string messageBoxText = "Can't find file " + System.IO.Path.GetFileName(filename); string caption = "Word Processor"; MessageBoxButton button = MessageBoxButton.OK; MessageBoxImage icon = MessageBoxImage.Error; MessageBox.Show(messageBoxText, caption, button, icon); } }
public void AddSound(string filename) { SoundInfo s; if (System.IO.Path.GetExtension(filename) == ".m3u" && System.IO.File.Exists(filename)) { SearchPlaylist(filename); } else if (System.IO.File.Exists(filename) && (s = isInList(filename)) != null) { if ((PlaylistCollection.ElementAt(curPlay)).SoundCollection.Count > 0) { SoundInfo p1 = (PlaylistCollection.ElementAt(curPlay)).SoundCollection.ElementAt((PlaylistCollection.ElementAt(curPlay)).cur); p1.Icone = ""; (PlaylistCollection.ElementAt(curPlay)).SoundCollection.RemoveAt((PlaylistCollection.ElementAt(curPlay)).cur); (PlaylistCollection.ElementAt(curPlay)).SoundCollection.Insert((PlaylistCollection.ElementAt(curPlay)).cur, p1); (PlaylistCollection.ElementAt(curPlaylist)).cur = SoundCollection.IndexOf(s); } curPlay = curPlaylist; if (play) { s.Icone = "/MediaPlayer;component/Images/playing.png"; } SoundCollection.RemoveAt((PlaylistCollection.ElementAt(curPlaylist)).cur); SoundCollection.Insert((PlaylistCollection.ElementAt(curPlaylist)).cur, s); liste.SelectedItem = s; RoutedEventArgs newEventArgs = new RoutedEventArgs(SelectedEvent); RaiseEvent(newEventArgs); } else if (System.IO.File.Exists(filename)) { tagFile = TagLib.File.Create(filename); string name = tagFile.Tag.Title; if (tagFile.Tag.Title == null) { name = System.IO.Path.GetFileNameWithoutExtension(filename); } s = new SoundInfo { SoundName = name, FileName = filename, Creator = tagFile.Tag.FirstArtist }; s.media = new MediaElement(); s.media.LoadedBehavior = MediaState.Manual; s.media.UnloadedBehavior = MediaState.Manual; s.media.Source = new Uri(filename); s.media.Pause(); s.media.MediaOpened += new RoutedEventHandler(Opened); if ((PlaylistCollection.ElementAt(curPlaylist)).id == (PlaylistCollection.ElementAt(curPlaylist)).cur && play && curPlaylist == curPlay) { s.Icone = "/MediaPlayer;component/Images/playing.png"; } SoundCollection.Insert((PlaylistCollection.ElementAt(curPlaylist)).id, s); (PlaylistCollection.ElementAt(curPlaylist)).id++; } else { string messageBoxText = "Can't find file " + System.IO.Path.GetFileName(filename); string caption = "Word Processor"; MessageBoxButton button = MessageBoxButton.OK; MessageBoxImage icon = MessageBoxImage.Error; MessageBox.Show(messageBoxText, caption, button, icon); } }
public void AddUrl(string filename) { SoundInfo s; if ((s = isInList(filename)) != null) { if ((PlaylistCollection.ElementAt(curPlay)).SoundCollection.Count > 0) { SoundInfo p1 = (PlaylistCollection.ElementAt(curPlay)).SoundCollection.ElementAt((PlaylistCollection.ElementAt(curPlay)).cur); p1.Icone = ""; (PlaylistCollection.ElementAt(curPlay)).SoundCollection.RemoveAt((PlaylistCollection.ElementAt(curPlay)).cur); (PlaylistCollection.ElementAt(curPlay)).SoundCollection.Insert((PlaylistCollection.ElementAt(curPlay)).cur, p1); (PlaylistCollection.ElementAt(curPlaylist)).cur = SoundCollection.IndexOf(s); } curPlay = curPlaylist; if (play) s.Icone = "/MediaPlayer;component/Images/playing.png"; SoundCollection.RemoveAt((PlaylistCollection.ElementAt(curPlaylist)).cur); SoundCollection.Insert((PlaylistCollection.ElementAt(curPlaylist)).cur, s); liste.SelectedItem = s; RoutedEventArgs newEventArgs = new RoutedEventArgs(SelectedEvent); RaiseEvent(newEventArgs); } else { s = new SoundInfo { SoundName = filename, FileName = filename, }; s.media = new MediaElement(); s.media.LoadedBehavior = MediaState.Manual; s.media.UnloadedBehavior = MediaState.Manual; s.media.Source = new Uri(filename, UriKind.Absolute); s.media.Pause(); s.media.MediaOpened += new RoutedEventHandler(Opened); if ((PlaylistCollection.ElementAt(curPlaylist)).id == (PlaylistCollection.ElementAt(curPlaylist)).cur && play) s.Icone = "/MediaPlayer;component/Images/playing.png"; SoundCollection.Insert((PlaylistCollection.ElementAt(curPlaylist)).id, s); (PlaylistCollection.ElementAt(curPlaylist)).id++; } }