api_queue.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. #ifndef NULLSOFT_API_QUEUE_H
  2. #define NULLSOFT_API_QUEUE_H
  3. /*
  4. ** JTFE v1.0.1 Wasabi API interface
  5. ** (Released: 06/01/2010)
  6. **
  7. **
  8. ** This header file provides the interfaces implemented by the JTFE plugin for other plugins/services to be able
  9. ** to make use of it's queue which allows for Winamp's playback order to be overriden.
  10. **
  11. ** To use this api assumes you know already how to make use of the wasabi service based system
  12. ** (see the more complete examples provided in the SDK).
  13. **
  14. **
  15. ** Example:
  16. **
  17. ** The following psuedo code shows how to clear the current queue (if one exists) and will then add in a specifc
  18. ** file by the full path passed and also adding a file based on the position in the current playlist.
  19. **
  20. ** if(!WASABI_API_QUEUEMGR) ServiceBuild(WASABI_API_QUEUEMGR,QueueManagerApiGUID);
  21. ** if(WASABI_API_QUEUEMGR){
  22. ** // Clear the queue (if one exists)
  23. ** WASABI_API_QUEUEMGR->ClearQueue();
  24. **
  25. ** // Add the full file path (wchar_t_path_to_file)
  26. ** WASABI_API_QUEUEMGR->AddItemToQueue(0,1,wchar_t_path_to_file);
  27. **
  28. ** // Add the first file in the playlist editor into the queue
  29. ** WASABI_API_QUEUEMGR->AddItemToQueue(0,0,0);
  30. ** }
  31. **
  32. **
  33. ** Notes:
  34. **
  35. ** This header only provides access to the functions it exports. Some actions like the MoveQueuedItem(s) functions
  36. ** have not been implemented in this api even though they are internally implemented. In future releases of the
  37. ** plugin it is hoped that these (and another useful/requested) apis will also be implemented and provided.
  38. **
  39. ** Changes:
  40. ** v1.0.1 - Fixes EnableQueueAdvance(..) and IsQueueAdvanceEnabled(..) interfaces not correctly defined in this file
  41. ** - Fixes crash when calling IsQueueAdvanceEnabled(..) (if previous issue was manually corrected)
  42. **
  43. */
  44. #if (_MSC_VER <= 1200)
  45. typedef int intptr_t;
  46. #endif
  47. enum PLAYLIST_TYPE {M3U_PLAYLIST=0x0, PLS_PLAYLIST=0x1, M3U8_PLAYLIST=0x2};
  48. enum MOVE_MODE {MOVE_TOP_OF_LIST=-2, MOVE_UP_LIST=-1, MOVE_DOWN_LIST=1, MOVE_END_OF_LIST=2, MOVE_END_TO_START=3 };
  49. #ifdef __cplusplus
  50. #include <bfc/dispatch.h>
  51. class api_queue : public Dispatchable
  52. {
  53. protected:
  54. api_queue() {}
  55. ~api_queue() {}
  56. public:
  57. // main handling functions of the queue to add/remove/clear all
  58. BOOL AddItemToQueue(int item, int update_now, wchar_t* file);
  59. void RemoveQueuedItem(int item, int no_update=0);
  60. void ClearQueue(void);
  61. /*
  62. ** handling functions to allow for querying/manipulating of the queue items
  63. ** note: need to have a consistancy in the functions and all that...
  64. **
  65. ** use GetNumberOfQueuedItems() and then loop upto that via GetQueuedItemFromIndex(..) to get item id of the queue
  66. */
  67. int GetNumberOfQueuedItems(void);
  68. int GetQueuedItemFromIndex(int idx);
  69. wchar_t* GetQueuedItemFilePath(int item);
  70. int GetQueuedItemPlaylistPosition(int item);
  71. int IsItemQueuedMultipleTimes(int item, int test_only); // returns how many times an item is showing in the queue
  72. // Note: these are to be implemented after JTFE 1.0
  73. //BOOL MoveQueuedItem(int item, int mode/*MOVE_MODE*/);
  74. //BOOL MoveQueuedItems(int* items, int mode/*MOVE_MODE*/);
  75. /*
  76. ** miscellaneous actions available on the queue
  77. */
  78. void RandomiseQueue(void);
  79. // will ignore the item position and match it up against the current playlist (may cause queued item position merging)
  80. void RefreshQueue(void);
  81. BOOL LoadPlaylistIntoQueue(wchar_t* playlist_file, int reset_queue);
  82. BOOL SaveQueueToPlaylist(wchar_t* playlist_file, int playlist_type/*PLAYLIST_TYPE*/);
  83. // enables/disables queue advancement and query this state
  84. int EnableQueueAdvance(int enabled);
  85. int IsQueueAdvanceEnabled(void);
  86. public:
  87. DISPATCH_CODES
  88. {
  89. API_QUEUE_ADDITEMTOQUEUE = 1,
  90. API_QUEUE_REMOVEQUEUEDITEM = 2,
  91. API_QUEUE_CLEARQUEUE = 3,
  92. API_QUEUE_GETNUMBEROFQUEUEDITEMS = 10,
  93. API_QUEUE_GETQUEUEDITEMFROMINDEX = 11,
  94. API_QUEUE_GETQUEUEDITEMFILEPATH = 12,
  95. API_QUEUE_GETQUEUEDITEMPLAYLISTPOSITION = 13,
  96. API_QUEUE_ISITEMQUEUEDMULTIPLETIMES = 14,
  97. // Note: to be implemented after JTFE 1.0
  98. //API_QUEUE_MOVEQUEUEDITEM = 15,
  99. //API_QUEUE_MOVEQUEUEDITEMS = 16,
  100. API_QUEUE_RANDOMISEQUEUE = 20,
  101. API_QUEUE_REFRESHQUEUE = 21,
  102. API_QUEUE_LOADPLAYLISTINTOQUEUE = 22,
  103. API_QUEUE_SAVEQUEUETOPLAYLIST = 23,
  104. API_QUEUE_ENABLEQUEUEADVANCE = 30,
  105. API_QUEUE_ISQUEUEADVANCEENABLED = 31
  106. };
  107. };
  108. inline BOOL api_queue::AddItemToQueue(int item, int update_now, wchar_t* file)
  109. {
  110. return _call(API_QUEUE_ADDITEMTOQUEUE, (BOOL)0, item, update_now, file);
  111. }
  112. inline void api_queue::RemoveQueuedItem(int item, int no_update)
  113. {
  114. _voidcall(API_QUEUE_REMOVEQUEUEDITEM, item, no_update);
  115. }
  116. inline void api_queue::ClearQueue(void)
  117. {
  118. _voidcall(API_QUEUE_CLEARQUEUE);
  119. }
  120. inline int api_queue::GetNumberOfQueuedItems(void)
  121. {
  122. return _call(API_QUEUE_GETNUMBEROFQUEUEDITEMS, (int)0);
  123. }
  124. inline int api_queue::GetQueuedItemFromIndex(int idx)
  125. {
  126. return _call(API_QUEUE_GETQUEUEDITEMFROMINDEX, (int)0, idx);
  127. }
  128. inline wchar_t* api_queue::GetQueuedItemFilePath(int item)
  129. {
  130. return _call(API_QUEUE_GETQUEUEDITEMFILEPATH, (wchar_t*)0, item);
  131. }
  132. inline int api_queue::GetQueuedItemPlaylistPosition(int item)
  133. {
  134. return _call(API_QUEUE_GETQUEUEDITEMPLAYLISTPOSITION, (int)0, item);
  135. }
  136. inline int api_queue::IsItemQueuedMultipleTimes(int item, int test_only)
  137. {
  138. return _call(API_QUEUE_ISITEMQUEUEDMULTIPLETIMES, (int)0, item, test_only);
  139. }
  140. inline void api_queue::RandomiseQueue(void)
  141. {
  142. _voidcall(API_QUEUE_RANDOMISEQUEUE);
  143. }
  144. inline void api_queue::RefreshQueue(void)
  145. {
  146. _voidcall(API_QUEUE_REFRESHQUEUE);
  147. }
  148. inline int api_queue::LoadPlaylistIntoQueue(wchar_t* playlist_file, int reset_queue)
  149. {
  150. return _call(API_QUEUE_LOADPLAYLISTINTOQUEUE, (int)0, playlist_file, reset_queue);
  151. }
  152. inline int api_queue::SaveQueueToPlaylist(wchar_t* playlist_file, int playlist_type)
  153. {
  154. return _call(API_QUEUE_SAVEQUEUETOPLAYLIST, (int)0, playlist_file, playlist_type);
  155. }
  156. inline int api_queue::EnableQueueAdvance(int enabled)
  157. {
  158. return _call(API_QUEUE_ENABLEQUEUEADVANCE, (int)0, enabled);
  159. }
  160. inline int api_queue::IsQueueAdvanceEnabled(void)
  161. {
  162. return _call(API_QUEUE_ISQUEUEADVANCEENABLED, (int)0);
  163. }
  164. #endif
  165. // {7DC8C14F-F27F-48e8-A3D1-602BB3196E40}
  166. static const GUID QueueManagerApiGUID =
  167. { 0x7dc8c14f, 0xf27f, 0x48e8, { 0xa3, 0xd1, 0x60, 0x2b, 0xb3, 0x19, 0x6e, 0x40 } };
  168. #endif