PlaylistGeneratorAPI.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include "PlaylistGeneratorAPI.h"
  2. #include <api/service/waservicefactory.h>
  3. #include "main.h"
  4. int PlaylistGeneratorAPI::GeneratePlaylist(HWND parent, const itemRecordListW *selectedSeedRecordList)
  5. {
  6. if (hwndDlgCurrent) // Warn if trying to open two seperate playlist generators
  7. {
  8. MultipleInstancesWarning();
  9. return DISPATCH_SUCCESS;
  10. }
  11. AddSeedTracks(selectedSeedRecordList);
  12. if (SongsSelected())
  13. return DISPATCH_SUCCESS;
  14. return DISPATCH_FAILURE;
  15. }
  16. int PlaylistGeneratorAPI::AddSeedTracks(const itemRecordListW *recordList)
  17. {
  18. wchar_t winamp_title[MAX_TITLE_SIZE] = {0};
  19. for (int i = 0; i < recordList->Size; i++)
  20. {
  21. itemRecordW *item = &recordList->Items[i];
  22. GetTitleFormattingML(item->filename, item, winamp_title, MAX_TITLE_SIZE);
  23. seedPlaylist.AppendWithInfo(item->filename, winamp_title, item->length * 1000, item->filesize * 1024);
  24. }
  25. return true;
  26. }
  27. #define CBCLASS PlaylistGeneratorAPI
  28. START_DISPATCH;
  29. CB(API_PLAYLIST_GENERATOR_GENERATEPLAYLIST, GeneratePlaylist)
  30. END_DISPATCH;
  31. #undef CBCLASS