public Media Create(String path)
 {
     created = false;
     int point = path.LastIndexOf('.');
     if (point != -1)
     {
         String ext = path.Substring(point + 1);
         foreach (KeyValuePair<MediaType, Tuple<List<String>, object>> dic in AuthorizedExtension)
         {
             if (dic.Value.Item1.Contains(ext.ToLower()))
             {
                 media = new Media();
                 media.Type = dic.Key;
                 created = true;
                 Debug.Add("Media " + path + " created !");
             }
         }
     }
     if (!created)
         throw new InvalidMediaException(path + " is not a valid media");
     try
     {
         tag = null;
         tag = TagLib.File.Create(path);
     }
     catch (Exception e)
     {
         Debug.Add(e.ToString() + "\n");
     }
     media.AddTags(tag, path);
     media.CompleteData(AuthorizedExtension[media.Type].Item2);
     Debug.Add("Media datas completed !");
     return media;
 }
Example #2
0
 public bool Equals(Media med)
 {
     if ((object)med == null)
         return false;
     return (Path == med.Path);
 }
Example #3
0
 private void addOneMedia(Media media)
 {
     if (media == null)
         return;
     if (_currentPlaylist == null)
         CurrentPlaylist = new ObservableCollection<Media>();
     CurrentPlaylist.Add(media);
     CurrentMediaInt = CurrentPlaylist.Count - 1;
     Media.Source = new Uri(media.Path);
     TempoCurrentImage = 0;
     if (_currentPlaylist[_currentMediaInt].Type == MediaType.Picture)
         TimeMediaTotal = _tempoImage;
     MediaPicture = media.Picture;
     MediaTitle = System.IO.Path.GetFileNameWithoutExtension(_currentPlaylist[_currentMediaInt].Path);
     IsMediaPlaying = true;
     if (_currentPlaylist[_currentMediaInt].Type != MediaType.Picture)
         Media.Play();
 }
 public void Delete(Media media, string xmlFile = "Library.xml")
 {
     BackgroundWorker worker = new BackgroundWorker();
     worker.WorkerReportsProgress = false;
     worker.DoWork += doDelete;
     worker.RunWorkerCompleted += sendLibrary;
     Tuple<Media, string> tuple = new Tuple<Media, string>(media, xmlFile);
     worker.RunWorkerAsync(tuple);
 }