1
0

ifc_playlist.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. #ifndef NULLSOFT_IFC_PLAYLIST_H
  2. #define NULLSOFT_IFC_PLAYLIST_H
  3. #include "bfc/dispatch.h"
  4. #include "bfc/platform/types.h"
  5. enum
  6. {
  7. PLAYLIST_SUCCESS = 0,
  8. PLAYLIST_UNIMPLEMENTED = 1,
  9. };
  10. class ifc_playlist : public Dispatchable
  11. {
  12. protected:
  13. ifc_playlist() {}
  14. ~ifc_playlist() {}
  15. public:
  16. DISPATCH_CODES
  17. {
  18. IFC_PLAYLIST_CLEAR = 10,
  19. //IFC_PLAYLIST_APPENDWITHINFO = 20,
  20. //IFC_PLAYLIST_APPEND = 30,
  21. IFC_PLAYLIST_GETNUMITEMS = 40,
  22. IFC_PLAYLIST_GETITEM = 50,
  23. IFC_PLAYLIST_GETITEMTITLE = 60,
  24. IFC_PLAYLIST_GETITEMLENGTHMILLISECONDS = 70,
  25. IFC_PLAYLIST_GETITEMEXTENDEDINFO = 80,
  26. IFC_PLAYLIST_REVERSE = 90,
  27. IFC_PLAYLIST_SWAP = 100,
  28. IFC_PLAYLIST_RANDOMIZE = 110,
  29. IFC_PLAYLIST_REMOVE = 120,
  30. IFC_PLAYLIST_SORTBYTITLE = 130,
  31. IFC_PLAYLIST_SORTBYFILENAME = 140,
  32. IFC_PLAYLIST_SORTBYDIRECTORY = 150,
  33. };
  34. void Clear();
  35. //void AppendWithInfo(const wchar_t *filename, const char *title, int lengthInMS);
  36. //void Append(const wchar_t *filename);
  37. size_t GetNumItems();
  38. size_t GetItem( size_t item, wchar_t *filename, size_t filenameCch );
  39. size_t GetItemTitle( size_t item, wchar_t *title, size_t titleCch );
  40. int GetItemLengthMilliseconds( size_t item ); // TODO: maybe microsecond for better resolution?
  41. size_t GetItemExtendedInfo( size_t item, const wchar_t *metadata, wchar_t *info, size_t infoCch );
  42. int Reverse(); // optional, return 1 to indicate that you did the reversal (otherwise, caller must perform manually)
  43. int Swap( size_t item1, size_t item2 );
  44. int Randomize( int ( *generator )( ) ); // optional, return 1 to indicate that you did the randomization (otherwise, caller must perform manually)
  45. void Remove( size_t item );
  46. int SortByTitle(); // optional, return 1 to indicate that you did the sort (otherwise, caller must perform manually)
  47. int SortByFilename(); // optional, return 1 to indicate that you did the sort (otherwise, caller must perform manually)
  48. int SortByDirectory();
  49. };
  50. inline void ifc_playlist::Clear()
  51. {
  52. _voidcall( IFC_PLAYLIST_CLEAR );
  53. }
  54. /*
  55. inline void ifc_playlist::AppendWithInfo(const wchar_t *filename, const char *title, int lengthInMS)
  56. {
  57. _voidcall(IFC_PLAYLIST_APPENDWITHINFO, filename, title, lengthInMS);
  58. }
  59. */
  60. /*
  61. inline void ifc_playlist::Append(const wchar_t *filename)
  62. {
  63. _voidcall(IFC_PLAYLIST_APPEND, filename);
  64. }*/
  65. inline size_t ifc_playlist::GetNumItems()
  66. {
  67. return _call( IFC_PLAYLIST_GETNUMITEMS, (size_t)0 );
  68. }
  69. inline size_t ifc_playlist::GetItem( size_t item, wchar_t *filename, size_t filenameCch )
  70. {
  71. return _call( IFC_PLAYLIST_GETITEM, (size_t)0, item, filename, filenameCch );
  72. }
  73. inline size_t ifc_playlist::GetItemTitle( size_t item, wchar_t *title, size_t titleCch )
  74. {
  75. return _call( IFC_PLAYLIST_GETITEMTITLE, (size_t)0, item, title, titleCch );
  76. }
  77. inline int ifc_playlist::GetItemLengthMilliseconds( size_t item )
  78. {
  79. return _call( IFC_PLAYLIST_GETITEMLENGTHMILLISECONDS, (int)-1, item );
  80. }
  81. inline size_t ifc_playlist::GetItemExtendedInfo( size_t item, const wchar_t *metadata, wchar_t *info, size_t infoCch )
  82. {
  83. return _call( IFC_PLAYLIST_GETITEMEXTENDEDINFO, (size_t)0, item, metadata, info, infoCch );
  84. }
  85. inline int ifc_playlist::Reverse()
  86. {
  87. return _call( IFC_PLAYLIST_REVERSE, (int)PLAYLIST_UNIMPLEMENTED );
  88. }
  89. inline int ifc_playlist::Swap( size_t item1, size_t item2 )
  90. {
  91. return _call( IFC_PLAYLIST_SWAP, (int)PLAYLIST_UNIMPLEMENTED, item1, item2 );
  92. }
  93. inline int ifc_playlist::Randomize( int ( *generator )( ) )
  94. {
  95. return _call( IFC_PLAYLIST_RANDOMIZE, (int)PLAYLIST_UNIMPLEMENTED, generator );
  96. }
  97. inline void ifc_playlist::Remove( size_t item )
  98. {
  99. _voidcall( IFC_PLAYLIST_REMOVE, item );
  100. }
  101. inline int ifc_playlist::SortByTitle()
  102. {
  103. return _call( IFC_PLAYLIST_SORTBYTITLE, (int)0 );
  104. }
  105. inline int ifc_playlist::SortByFilename()
  106. {
  107. return _call( IFC_PLAYLIST_SORTBYFILENAME, (int)0 );
  108. }
  109. inline int ifc_playlist::SortByDirectory()
  110. {
  111. return _call( IFC_PLAYLIST_SORTBYDIRECTORY, (int)0 );
  112. }
  113. #endif