public override bool Process(MediaItem mediaItem, out ContentDirectoryMessaging.MediaItemChangeType changeType)
    {
      changeType = ContentDirectoryMessaging.MediaItemChangeType.None;

      var rl = mediaItem.GetResourceLocator();
      using (var ra = rl.CreateAccessor())
      {
        var rad = ra as IResourceDeletor;
        if (rad == null)
          return false;

        // First try to delete the file from storage.
        if (rad.Delete())
        {
          changeType = ContentDirectoryMessaging.MediaItemChangeType.Deleted;

          // If the MediaItem was loaded from ML, remove it there as well.
          if (IsManagedByMediaLibrary(mediaItem))
          {
            IContentDirectory cd = ServiceRegistration.Get<IServerConnectionManager>().ContentDirectory;
            if (cd == null)
              return true;

            cd.DeleteMediaItemOrPath(rl.NativeSystemId, rl.NativeResourcePath, true);
            return true;
          }
        }
      }
      return false;
    }
 public override bool Process(MediaItem mediaItem, out ContentDirectoryMessaging.MediaItemChangeType changeType)
 {
   changeType = ContentDirectoryMessaging.MediaItemChangeType.None;
   WorkflowAction action;
   if (!ServiceRegistration.Get<IWorkflowManager>().MenuStateActions.TryGetValue(ACTION_ID_ADD_ALL_TO_PLAYLIST, out action))
     return false;
   action.Execute();
   return true;
 }
    public override bool Process(MediaItem mediaItem, out ContentDirectoryMessaging.MediaItemChangeType changeType)
    {
      changeType = ContentDirectoryMessaging.MediaItemChangeType.None;
      IContentDirectory cd = ServiceRegistration.Get<IServerConnectionManager>().ContentDirectory;
      if (cd == null)
        return false;

      var rl = mediaItem.GetResourceLocator();

      Guid parentDirectoryId;
      if (!MediaItemAspect.TryGetAttribute(mediaItem.Aspects, ProviderResourceAspect.ATTR_PARENT_DIRECTORY_ID, out parentDirectoryId))
        return false;

      MediaItemAspect.SetAttribute(mediaItem.Aspects, MediaAspect.ATTR_PLAYCOUNT, GetNewPlayCount());

      cd.AddOrUpdateMediaItem(parentDirectoryId, rl.NativeSystemId, rl.NativeResourcePath, mediaItem.Aspects.Values);

      changeType = ContentDirectoryMessaging.MediaItemChangeType.Updated;
      return true;
    }
    protected void UpdateLoadedMediaItems(MediaItem mediaItem, ContentDirectoryMessaging.MediaItemChangeType changeType)
    {
      if (changeType == ContentDirectoryMessaging.MediaItemChangeType.None)
        return;

      bool changed = false;
      lock (_syncObj)
      {
        if (changeType == ContentDirectoryMessaging.MediaItemChangeType.Deleted)
        {
          PlayableMediaItem existingItem = _items.OfType<PlayableMediaItem>().FirstOrDefault(pmi => pmi.MediaItem.Equals(mediaItem));
          if (existingItem != null)
          {
            _items.Remove(existingItem);
            _currentTotalNumItems--;
            changed = true;
          }
        }
        if (changeType == ContentDirectoryMessaging.MediaItemChangeType.Updated)
        {
          PlayableMediaItem existingItem = _items.OfType<PlayableMediaItem>().FirstOrDefault(pmi => pmi.MediaItem.Equals(mediaItem));
          if (existingItem != null)
          {
            existingItem.Update(mediaItem);
          }
        }
      }
      if (changed)
      {
        _items.FireChange();
        Display_Normal(_items.Count, _currentTotalNumItems);
      }
    }
 public abstract bool Process(MediaItem mediaItem, out ContentDirectoryMessaging.MediaItemChangeType changeType);