Exemplo n.º 1
0
        public virtual void MediaAdd(MediaBase media)
        {
            MediaBase prevMedia;

            lock (((IDictionary)Files).SyncRoot)
            {
                if (Files.TryGetValue(media.MediaGuid, out prevMedia))
                {
                    if (prevMedia is IServerMedia || prevMedia is IAnimatedMedia)
                    {
                        ThreadPool.QueueUserWorkItem(o =>
                        {
                            if (prevMedia is IAnimatedMedia am)
                            {
                                EngineController.Database.DbDeleteMedia(am);
                            }
                            if (prevMedia is IServerMedia sm)
                            {
                                EngineController.Database.DbDeleteMedia(sm);
                            }
                            Logger.Warn("Media {0} replaced in dictionary. Previous media deleted in database.",
                                        prevMedia);
                        });
                        Debug.WriteLine(prevMedia, "Media replaced in dictionary");
                    }
                }
                Files[media.MediaGuid] = media;
            }
            media.PropertyChanged += _media_PropertyChanged;
            MediaAdded?.Invoke(this, new MediaEventArgs(media));
        }
Exemplo n.º 2
0
 public void AddMedia(IMediaInfo mediaInfo, int insertIndex = -1)
 {
     if (insertIndex >= 0)
     {
         Medias.Insert(insertIndex, mediaInfo);
     }
     else
     {
         Medias.Add(mediaInfo);
     }
     if (AutoSave)
     {
         Save();
     }
     MediaAdded?.Invoke(this, new PlaylistMediaAddedEventArgs(this, mediaInfo, insertIndex));
 }
 internal virtual void NotifyMediaAdded(IMedia media)
 {
     MediaAdded?.Invoke(this, new MediaEventArgs(media));
 }