wa2frontend.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. #ifndef __WINAMP2FRONTEND_H
  2. #define __WINAMP2FRONTEND_H
  3. #define WA2_GETINFO_SAMPLERATE 0
  4. #define WA2_GETINFO_BITRATE 1
  5. #define WA2_GETINFO_CHANNELS 2
  6. #define WA2_NUMBANDS 10
  7. #define WA2_EQDATA_FIRSTBAND 0
  8. #define WA2_EQDATA_LASTBAND 9
  9. #define WA2_EQDATA_PREAMP 10
  10. #define WA2_EQDATA_ENABLED 11
  11. #define WA2_EQDATA_AUTO 12
  12. #define IPC_GETWND_EQ 0
  13. #define IPC_GETWND_PE 1
  14. #define IPC_GETWND_MB 2
  15. #define IPC_GETWND_VIDEO 3
  16. #define WA2_USERBUTTON_PREV 0
  17. #define WA2_USERBUTTON_PLAY 1
  18. #define WA2_USERBUTTON_PAUSE 2
  19. #define WA2_USERBUTTON_STOP 3
  20. #define WA2_USERBUTTON_NEXT 4
  21. #define WA2_USERBUTTONMOD_NONE 0
  22. #define WA2_USERBUTTONMOD_SHIFT 1
  23. #define WA2_USERBUTTONMOD_CTRL 2
  24. #define WINAMP_MAIN_WINDOW 40258
  25. #define WINAMP_OPTIONS_MINIBROWSER 40298
  26. #define WINAMP_OPTIONS_VIDEO 40328
  27. #define WINAMP_OPTIONS_PLEDIT 40040
  28. #define WINAMP_OPTIONS_EQ 40036
  29. #define WINAMP_FILE_LOC 40185
  30. #define WINAMP_FILE_PLAY 40029
  31. #define WINAMP_FILE_DIR 40187
  32. //-----------------------------------------------------------------------------------------------
  33. #include <windows.h>
  34. #include "../gen_ml/ml.h"
  35. #include "../winamp/wa_ipc.h"
  36. #include "../winamp/ipc_pe.h"
  37. //-----------------------------------------------------------------------------------------------
  38. class Winamp2FrontEnd {
  39. public:
  40. friend BOOL CALLBACK findVisWndProc(HWND hwnd, LPARAM lParam);
  41. Winamp2FrontEnd();
  42. virtual ~Winamp2FrontEnd();
  43. void init(HWND hwndParent);
  44. const char *getVersion();
  45. void enqueueFile(const wchar_t *file);
  46. /*
  47. WA2_USERBUTTON_PLAY
  48. WA2_USERBUTTON_PAUSE
  49. WA2_USERBUTTON_STOP
  50. WA2_USERBUTTON_NEXT
  51. WA2_USERBUTTON_PREV
  52. WA2_USERBUTTONMOD_SHIFT
  53. WA2_USERBUTTONMOD_CTRL
  54. */
  55. void userButton(int button, int modifier);
  56. int isPlaying(); // 0 (false) or 1 (true)
  57. int isPaused(); // 0 (false) or 1 (true)
  58. int isStopped(); // if !isPlaying() and !isStopped() and !isPaused(), we're between tracks
  59. int getPosition(); // in ms
  60. int getLength(); // in ms
  61. int seekTo(int ms); // in millisecond
  62. void setVolume(int v); // 0 (silence) to 255 (loud)
  63. int getVolume(); // 0 (silence) to 255 (loud)
  64. void setPanning(int p); // 0 (left) to 255 (right)
  65. int getPanning(); // 0 (left) to 255 (right)
  66. void setShuffle(int shuffle);
  67. int getShuffle();
  68. void setRepeat(int repeat);
  69. int getRepeat();
  70. void setManualPlaylistAdvance(int manual);
  71. int getManualPlaylistAdvance();
  72. /*
  73. WA2_GETINFO_SAMPLERATE : Samplerate (i.e. 44100)
  74. WA2_GETINFO_BITRATE : Bitrate (i.e. 128)
  75. WA2_GETINFO_CHANNELS : Channels (i.e. 2)
  76. */
  77. int getInfo(int wa2_getinfo);
  78. /*
  79. WA2_EQDATA_FIRSTBAND/LASTBAND (0 to 9) : The 10 bands of EQ data. 0-63 (+20db - -20db)
  80. WA2_EQDATA_PREAMP : The preamp value. 0-63 (+20db - -20db)
  81. WA2_EQDATA_ENABLED : Enabled. zero if disabled, nonzero if enabled.
  82. WA2_EQDATA_AUTO : Autoload. zero if disabled, nonzero if enabled.
  83. */
  84. int getEqData(int wa2_eqdata);
  85. void setEqData(int wa2_eqdata, int val);
  86. void enableWindows(int enabled);
  87. int areWindowsEnabled();
  88. void setWindowsVisible(int visible);
  89. int areWindowsVisible();
  90. int isMainWindowVisible();
  91. void *CanPlay(const wchar_t *);
  92. bool IsPlaylist(const wchar_t *fn);
  93. int getCurPlaylistEntry();
  94. int getPlaylistLength();
  95. const wchar_t *GetCurrentTitle();
  96. const wchar_t *GetCurrentFile();
  97. const wchar_t *getTitle(int plentry);
  98. const char *getFile(int plentry);
  99. const wchar_t *getFileW(int plentry);
  100. void setCurTitle(const wchar_t* new_title);
  101. void playAudioCD(int cd); // id of cd (0 to 4)
  102. void openFileDialog(HWND w);
  103. void openUrlDialog(HWND w);
  104. void openUrl(const wchar_t *url);
  105. void openDirectoryDialog(HWND w);
  106. void ejectPopupMenu();
  107. void previousPopupMenu();
  108. void nextPopupMenu();
  109. void playPopupMenu();
  110. void pausePopupMenu();
  111. void stopPopupMenu();
  112. void setDialogBoxParent(HWND w);
  113. void updateDialogBoxParent(HWND w);
  114. /*
  115. IPC_GETWND_EQ
  116. IPC_GETWND_PE
  117. IPC_GETWND_MB
  118. IPC_GETWND_VIDEO
  119. */
  120. HWND getWnd(int wnd);
  121. int isWindowVisible(intptr_t which);
  122. void setWindowVisible(intptr_t which, int visible);
  123. HWND getMediaLibrary();
  124. void ensureMediaLibraryLoaded();
  125. int isOnTop();
  126. void setOnTop(int ontop);
  127. void toggleOnTop();
  128. // screen coordinates
  129. void triggerPopupMenu(int x, int y);
  130. void triggerEQPresetMenu(int x, int y);
  131. int triggerFileMenu(int x, int y, int width, int height);
  132. int triggerPlayMenu(int x, int y, int width, int height);
  133. int triggerOptionsMenu(int x, int y, int width, int height);
  134. int triggerWindowsMenu(int x, int y, int width, int height);
  135. int triggerHelpMenu(int x, int y, int width, int height);
  136. int triggerPEFileMenu(int x, int y, int width, int height);
  137. int triggerPEPlaylistMenu(int x, int y, int width, int height);
  138. int triggerPESortMenu(int x, int y, int width, int height);
  139. int triggerPEHelpMenu(int x, int y, int width, int height);
  140. int triggerMLFileMenu(int x, int y, int width, int height);
  141. int triggerMLViewMenu(int x, int y, int width, int height);
  142. int triggerMLHelpMenu(int x, int y, int width, int height);
  143. int triggerPEListOfListsMenu(int x, int y);
  144. HMENU getTopMenu();
  145. HMENU getPopupMenu();
  146. int adjustOptionsPopupMenu(int direction);
  147. enum {
  148. WA2_MAINMENUBAR_FILE = 0,
  149. WA2_MAINMENUBAR_PLAY = 1,
  150. WA2_MAINMENUBAR_OPTIONS = 2,
  151. WA2_MAINMENUBAR_WINDOWS = 3,
  152. WA2_MAINUMENUBAR_HELP = 4,
  153. };
  154. HMENU getMenuBarMenu(int which);
  155. int adjustFFWindowsMenu(int direction);
  156. int adjustFFOptionsMenu(int direction);
  157. HWND getMainWindow();
  158. void quit();
  159. char * (*export_sa_get_deprecated)();
  160. char * (*export_sa_get)(char data[75*2+8]);
  161. void (*export_sa_setreq)(int);
  162. int (*export_vu_get)(int channel);
  163. enum {
  164. WA2_PLEDITPOPUP_ADD = 0,
  165. WA2_PLEDITPOPUP_REM = 1,
  166. WA2_PLEDITPOPUP_SEL = 2,
  167. WA2_PLEDITPOPUP_MISC = 3,
  168. WA2_PLEDITPOPUP_LIST = 4,
  169. };
  170. void sendPlCmd(int which, int x=0, int y=0, int menu_align_flag=0);
  171. enum {
  172. WA2_MBCMD_BACK = 0,
  173. WA2_MBCMD_FORWARD = 1,
  174. WA2_MBCMD_STOP = 2,
  175. WA2_MBCMD_RELOAD = 3,
  176. WA2_MBPOPUP_MISC = 4,
  177. };
  178. void registerGlobalHotkey(const char *name, int msg, int wparam, int lparam, int flags, const char *id);
  179. #ifdef MINIBROWSER_SUPPORT
  180. void sendMbCmd(int which, int x=0, int y=0, int menu_align_flag=0);
  181. #endif
  182. enum {
  183. WA2_VIDCMD_FULLSCREEN = 0,
  184. WA2_VIDCMD_1X = 1,
  185. WA2_VIDCMD_2X = 2,
  186. WA2_VIDCMD_LIB = 3,
  187. WA2_VIDPOPUP_MISC = 4,
  188. WA2_VIDCMD_EXIT_FS = 5,
  189. };
  190. void sendVidCmd(int which, int x=0, int y=0, int menu_align_flag=0);
  191. int hasVideoSupport();
  192. int isPlayingVideo();
  193. int isPlayingVideoFullscreen();
  194. int isDoubleSize();
  195. int getTimeDisplayMode();
  196. void toggleVis();
  197. int isVisRunning();
  198. HWND getVisWnd();
  199. IDropTarget *getDropTarget();
  200. int getBitrate(); // in kbps
  201. int getSamplerate(); // in khz
  202. int getChannels(); // 1 mono, 2 stereo ...
  203. int isValidEmbedWndState(embedWindowState *ws);
  204. int PE_getNumItems();
  205. fileinfo2 *PE_getFileTitle(int index);
  206. fileinfo2W *PE_getFileTitleW(int index);
  207. int PE_getCurrentIndex();
  208. void PE_setCurrentIndex(int i);
  209. void switchSkin(const wchar_t *skinname);
  210. void visNext();
  211. void visPrev();
  212. void visRandom(int set);
  213. void pollVisRandom();
  214. void visFullscreen();
  215. void visConfig();
  216. void visMenu();
  217. void setIdealVideoSize(int w, int h) { video_ideal_width = w; video_ideal_height = h; }
  218. void getIdealVideoSize(int *w, int *h);
  219. int getStopOnVideoClose();
  220. void setStopOnVideoClose(int stop);
  221. int GetVideoResize();
  222. void SetVideoResize(int stop);
  223. virtual int isVis(HWND hwnd); // checks children too
  224. HWND getPreferencesWindow();
  225. void setPlEditWidthHeight(int width, int height);
  226. HINSTANCE getLanguagePackInstance();
  227. void openTrackInfo();
  228. const char *getOutputPlugin();
  229. void setDrawBorders(int d);
  230. void disableSkinnedCursors(int disable);
  231. int getMetaData(const wchar_t *filename, const wchar_t *name, wchar_t *data, int data_len);
  232. void GetFileInfo(const wchar_t *filename, wchar_t *title, int titleCch, int *length);
  233. void invalidateCache();
  234. const char *getVideoInfoString();
  235. void playFile(const wchar_t *file);
  236. void rewind5s();
  237. void forward5s();
  238. void endOfPlaylist();
  239. void startOfPlaylist();
  240. void stopWithFade();
  241. void stopAfterCurrent();
  242. void clearPlaylist();
  243. int isWindowShade(int wnd);
  244. int getCurTrackRating();
  245. void setCurTrackRating(int rating);
  246. int isExitEnabled();
  247. int pushExitDisabled();
  248. int popExitDisabled();
  249. int DownloadFile(const char *url, const wchar_t *destfilepath = L"", bool addToMl = true, bool notifyDownloadsList = true);
  250. void getDownloadPath(wchar_t path2store[MAX_PATH]);
  251. void setDownloadPath(const wchar_t * path2store);
  252. bool GetAlbumArt(const wchar_t *filename);
  253. bool IsWinampPro();
  254. private:
  255. void setFoundVis() { foundvis = 1; }
  256. char *m_version;
  257. HWND hwnd_winamp;
  258. HWND hwnd_playlist;
  259. int foundvis;
  260. int enabled;
  261. int visible;
  262. int video_ideal_width;
  263. int video_ideal_height;
  264. DWORD cached_length_time;
  265. int got_length_cache;
  266. int cached_length;
  267. DWORD cached_pos_time;
  268. int got_pos_cache;
  269. int cached_pos;
  270. int saved_video,
  271. #ifdef MINIBROWSER_SUPPORT
  272. saved_mb,
  273. #endif
  274. saved_pe, saved_eq, saved_main;
  275. };
  276. //-----------------------------------------------------------------------------------------------
  277. extern Winamp2FrontEnd wa2;
  278. BOOL DoTrackPopup(HMENU hMenu, UINT fuFlags, int x, int y, HWND hwnd);
  279. #endif