api_playlistmanager.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. #ifndef NULLSOFT_API_PLAYLISTMANAGER_H
  2. #define NULLSOFT_API_PLAYLISTMANAGER_H
  3. #include <bfc/dispatch.h>
  4. class ifc_playlistloadercallback;
  5. class ifc_playlist;
  6. class ifc_playlistdirectorycallback;
  7. enum
  8. {
  9. PLAYLISTMANAGER_SUCCESS = 0,
  10. PLAYLISTMANAGER_FAILED = 1,
  11. PLAYLISTMANAGER_LOAD_NO_LOADER = 1,
  12. PLAYLISTMANAGER_LOAD_LOADER_OPEN_FAILED = 2,
  13. };
  14. class api_playlistmanager : public Dispatchable
  15. {
  16. protected:
  17. api_playlistmanager() {}
  18. ~api_playlistmanager() {}
  19. public:
  20. int Load( const wchar_t *filename, ifc_playlistloadercallback *playlist );
  21. int LoadAs( const wchar_t *filename, const wchar_t *ext, ifc_playlistloadercallback *playlist ); // call with ext in the format ".pls"
  22. int LoadFromDialog( const wchar_t *fns, ifc_playlistloadercallback *playlist );
  23. int LoadFromANSIDialog( const char *fns, ifc_playlistloadercallback *playlist );
  24. int Save( const wchar_t *filename, ifc_playlist *playlist );
  25. size_t Copy( const wchar_t *destFn, const wchar_t *srcFn ); // returns number of items copied
  26. size_t CountItems( const wchar_t *filename );
  27. int GetLengthMilliseconds( const wchar_t *filename );
  28. uint64_t GetLongLengthMilliseconds( const wchar_t *filename );
  29. void Randomize( ifc_playlist *playlist );
  30. void Reverse( ifc_playlist *playlist );
  31. void LoadDirectory( const wchar_t *directory, ifc_playlistloadercallback *callback, ifc_playlistdirectorycallback *dirCallback );
  32. bool CanLoad( const wchar_t *filename );
  33. void GetExtensionList( wchar_t *extensionList, size_t extensionListCch );
  34. void GetFilterList( wchar_t *extensionList, size_t extensionListCch );
  35. const wchar_t *EnumExtension( size_t num );
  36. public:
  37. DISPATCH_CODES
  38. {
  39. API_PLAYLISTMANAGER_LOAD = 10,
  40. API_PLAYLISTMANAGER_LOADNULLDELIMITED = 11,
  41. API_PLAYLISTMANAGER_LOADNULLDELIMITED_ANSI = 12,
  42. API_PLAYLISTMANAGER_LOADAS = 13,
  43. API_PLAYLISTMANAGER_SAVE = 20,
  44. API_PLAYLISTMANAGER_COPY = 30,
  45. API_PLAYLISTMANAGER_COUNT = 40,
  46. API_PLAYLISTMANAGER_GETLENGTH = 50,
  47. API_PLAYLISTMANAGER_GETLONGLENGTH = 51,
  48. API_PLAYLISTMANAGER_LOADDIRECTORY = 60,
  49. API_PLAYLISTMANAGER_RANDOMIZE = 100,
  50. API_PLAYLISTMANAGER_REVERSE = 110,
  51. API_PLAYLISTMANAGER_CANLOAD = 120,
  52. API_PLAYLISTMANAGER_GETEXTENSIONLIST = 130,
  53. API_PLAYLISTMANAGER_GETFILTERLIST = 140,
  54. API_PLAYLISTMANAGER_ENUMEXTENSION = 150,
  55. };
  56. };
  57. inline void api_playlistmanager::GetFilterList( wchar_t *extensionList, size_t extensionListCch )
  58. {
  59. extensionList[ 0 ] = 0; // just in case no one implements it
  60. extensionList[ 1 ] = 0;
  61. _voidcall( API_PLAYLISTMANAGER_GETFILTERLIST, extensionList, extensionListCch );
  62. }
  63. inline int api_playlistmanager::LoadAs( const wchar_t *filename, const wchar_t *ext, ifc_playlistloadercallback *playlist )
  64. {
  65. return _call( API_PLAYLISTMANAGER_LOADAS, (int)PLAYLISTMANAGER_FAILED, filename, ext, playlist );
  66. }
  67. inline void api_playlistmanager::GetExtensionList( wchar_t *extensionList, size_t extensionListCch )
  68. {
  69. extensionList[ 0 ] = 0; // just in case no one implements it
  70. _voidcall( API_PLAYLISTMANAGER_GETEXTENSIONLIST, extensionList, extensionListCch );
  71. }
  72. inline int api_playlistmanager::Load( const wchar_t *filename, ifc_playlistloadercallback *playlist )
  73. {
  74. return _call( API_PLAYLISTMANAGER_LOAD, (int)PLAYLISTMANAGER_FAILED, filename, playlist );
  75. }
  76. inline int api_playlistmanager::LoadFromDialog( const wchar_t *filename, ifc_playlistloadercallback *playlist )
  77. {
  78. return _call( API_PLAYLISTMANAGER_LOADNULLDELIMITED, (int)PLAYLISTMANAGER_FAILED, filename, playlist );
  79. }
  80. inline int api_playlistmanager::LoadFromANSIDialog( const char *filename, ifc_playlistloadercallback *playlist )
  81. {
  82. return _call( API_PLAYLISTMANAGER_LOADNULLDELIMITED_ANSI, (int)PLAYLISTMANAGER_FAILED, filename, playlist );
  83. }
  84. inline int api_playlistmanager::Save( const wchar_t *filename, ifc_playlist *playlist )
  85. {
  86. return _call( API_PLAYLISTMANAGER_SAVE, (int)PLAYLISTMANAGER_FAILED, filename, playlist );
  87. }
  88. inline size_t api_playlistmanager::Copy( const wchar_t *destFn, const wchar_t *srcFn )
  89. {
  90. return _call( API_PLAYLISTMANAGER_COPY, (size_t)0, destFn, srcFn );
  91. }
  92. inline size_t api_playlistmanager::CountItems( const wchar_t *filename )
  93. {
  94. return _call( API_PLAYLISTMANAGER_COUNT, (size_t)0, filename );
  95. }
  96. inline int api_playlistmanager::GetLengthMilliseconds( const wchar_t *filename )
  97. {
  98. return _call( API_PLAYLISTMANAGER_GETLENGTH, (int)0, filename );
  99. }
  100. inline uint64_t api_playlistmanager::GetLongLengthMilliseconds( const wchar_t *filename )
  101. {
  102. return _call( API_PLAYLISTMANAGER_GETLONGLENGTH, (uint64_t)0, filename );
  103. }
  104. inline void api_playlistmanager::Randomize( ifc_playlist *playlist )
  105. {
  106. _voidcall( API_PLAYLISTMANAGER_RANDOMIZE, playlist );
  107. }
  108. inline void api_playlistmanager::Reverse( ifc_playlist *playlist )
  109. {
  110. _voidcall( API_PLAYLISTMANAGER_REVERSE, playlist );
  111. }
  112. inline void api_playlistmanager::LoadDirectory( const wchar_t *directory, ifc_playlistloadercallback *callback, ifc_playlistdirectorycallback *dirCallback )
  113. {
  114. _voidcall( API_PLAYLISTMANAGER_LOADDIRECTORY, directory, callback, dirCallback );
  115. }
  116. inline bool api_playlistmanager::CanLoad( const wchar_t *filename )
  117. {
  118. return _call( API_PLAYLISTMANAGER_CANLOAD, (bool)true, filename );
  119. }
  120. inline const wchar_t *api_playlistmanager::EnumExtension( size_t num )
  121. {
  122. return _call( API_PLAYLISTMANAGER_ENUMEXTENSION, (const wchar_t *)0, num );
  123. }
  124. // {C5618774-7177-43aa-9906-933C9F40EBDC}
  125. static const GUID api_playlistmanagerGUID =
  126. { 0xc5618774, 0x7177, 0x43aa, { 0x99, 0x6, 0x93, 0x3c, 0x9f, 0x40, 0xeb, 0xdc } };
  127. #endif