Help - Search - Members - Calendar
Full Version: automatically add new files from music directory?
Hydrogenaudio Forums > Hosted Forums > foobar2000 > 3rd Party Plugins - (fb2k)
milanorex
Is there any plugin that can look into your music directory and automatically add any files not currently in your playlist? If not, i'd really like to see this!
ludox
I have never seen this plugin but this a good idea. smile.gif
Someone to program it?
Kreisquadratur
When I used Winamp, I used this plugin.
I don't think it is not to hard to program:

1) option for selection the playlist, which should only contain files of a specific folder (including subfolder)
2) The harder part: Write a folderwatcher
3) On folderwatcher add a file, add it to the playlist
spase
This has been asked a million times before.

Please use the search function.
Otto42
QUOTE(Kreisquadratur @ Feb 11 2004, 11:11 AM)
2) The harder part: Write a folderwatcher


(psuedocode)
CODE

function check_folder_for_new_songs(string folder)
{
  while (file=getnextfile(folder))
  {
      if ( file_is_a_directory(file) )
          check_folder_for_new_songs(file);
      else if (! is_file_in_playlist(file,playlist) )
          add_file_to_playlist(playlist,file);
      sleep();  // give up the timeslice to prevent CPU hogging during this process
  }
}


wink.gif
milanorex
QUOTE(spase @ Feb 11 2004, 06:40 PM)
This has been asked a million times before.

Please use the search function.

I only saw one in the General forum... Didnt get much attention.

Anyways, it could either watch the folder for new files, or have you press a button to load any new files? Either way would be great.
danZ
QUOTE(Kreisquadratur @ Feb 11 2004, 11:11 AM)
When I used Winamp, I used this plugin.
I don't think it is not to hard to program:

1) option for selection the playlist, which should only contain files of a specific folder (including subfolder)
2) The harder part: Write a folderwatcher
3) On folderwatcher add a file, add it to the playlist

I wrote a plugin for Winamp that did this. It simply watched the specified folders for additions, deletions, name changes, etc. and then updated the playlist accordingly.

There is an easy way to implement this using the Win32 API instead of using something like the pseudo-code posted a few replies back.

FindFirstChangeNotification
FindNextChangeNotification
FindCloseChangeNotification

is the API that makes this pretty simple to implement and it is efficient since it is event driven vs. polling the directory contents.

Also, I might be wrong here, but I got the impression from a quick look at the 0.8 change log that foobar is doing some type of file or folder monitoring. If this is true, is this functionality exposed in the 0.8 SDK for use by third party components?
mazy
danz, afaik it does that only on files in the database / playlist to decide whether to reload tags from a file or not ... and from my observation it checks for size / date changes when it plays an item and maybe during any file-processing, i.e. when files are drag'n'dropped, added etc.
Otto42
QUOTE(danZ @ Feb 12 2004, 02:52 PM)
There is an easy way to implement this using the Win32 API instead of using something like the pseudo-code posted a few replies back.

FindFirstChangeNotification
FindNextChangeNotification
FindCloseChangeNotification

is the API that makes this pretty simple to implement and it is efficient since it is event driven vs. polling the directory contents.

True, except that using the change notifications thing will only tell you files that have changed since you started watching the folder in question. That is, you Start the first change notification, then get back what changes in there.. If something changed while your program was shut down, then you never notice it this way.

Oh, and if you run this for long periods of time, like in a service, it stops working for no reason after a while. You simply stop getting that event back. Never have figured out why it stops telling you when things change, it just happens. On NT systems it seemed to stop more often, but after a month or two of running, it stops working on 2K/XP systems as well. Polling on a timer and sleeps may be ugllier, but it's more reliable in the long term. It's also easier to port to other platforms (not that that matters in this case).

Anyway, I'm offtopic now. smile.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.