[Titre du sujet Corrigé] Contrôler Winamp en PureBasic

Vous débutez et vous avez besoin d'aide ? N'hésitez pas à poser vos questions
gansta93
Messages : 1448
Inscription : jeu. 26/févr./2004 11:17
Localisation : Le Village
Contact :

[Titre du sujet Corrigé] Contrôler Winamp en PureBasic

Message par gansta93 »

Bonjour,

Comment faire un Plug-In pour Winamp en PureBasic?
J'ai une autre question:
certains logiciels peuvent récupèrer le titre jouer dans Winamp. Comment peut-on faire?

Merci d'avance.
Dernière modification par gansta93 le sam. 03/sept./2005 15:50, modifié 1 fois.
gansta93
Messages : 1448
Inscription : jeu. 26/févr./2004 11:17
Localisation : Le Village
Contact :

Message par gansta93 »

Arf, ça n'inspire personne?
Ni la première ni la deuxième question? ...:
Avatar de l’utilisateur
Chris
Messages : 3731
Inscription : sam. 24/janv./2004 14:54
Contact :

Message par Chris »

Arf, ça n'inspire personne?
Ben non, pas moi, en tout cas. :D

Par contre, si tu utilises jaPBe, il y a un fichier qui s'appelle WinAmpCall.pbi dans le dossier jaPBe\Includes.
A toi de voir si tu peux en tirer quelque chose
gansta93
Messages : 1448
Inscription : jeu. 26/févr./2004 11:17
Localisation : Le Village
Contact :

Message par gansta93 »

Va faloir que je le réinstalle...
je verrais ça merci.
Backup
Messages : 14526
Inscription : lun. 26/avr./2004 0:40

Message par Backup »

le voici !!

Code : Tout sélectionner

;Info: Winamp Remote Control

;Use PB-Memory.

Global hwnd_Winamp_
Declare Winamp_ToggleWindowVisible()

Procedure Winamp_Hide()
  SendMessage_(hwnd_Winamp_,#WM_SIZE,#SIZE_MINIMIZED,0);send a message
  ShowWindow_(hwnd_Winamp_,#SW_MINIMIZE); and minimize
  ShowWindow_(hwnd_Winamp_,#SW_HIDE); und verstecken
EndProcedure
Procedure Winamp_Show()
  ShowWindow_(hwnd_Winamp_,#SW_SHOW); entstecken
  SendMessage_(hwnd_Winamp_,#WM_SIZE,#SIZE_RESTORED,0); wieder zurück
  ShowWindow_(hwnd_Winamp_,#SW_RESTORE); und normal
EndProcedure
Procedure Winamp_ToggleVisible()
  If hwnd_Winamp_
    If ShowWindow_(hwnd_Winamp_,#SW_SHOWNA)=0
      Winamp_Show()
    Else
      Winamp_Hide()
    EndIf
  EndIf
EndProcedure

Procedure StartWinamp(Winamp_EXE_.s)
  load=0
  Repeat
    hwnd_Winamp_ = FindWindow_("Winamp v1.x",0)
    If hwnd_Winamp_=0 And load=0
      If FileSize(Winamp_EXE_)>0
        RunProgram(Winamp_EXE_)
        load=1
      Else
        load=-2
      EndIf
    EndIf
  Until hwnd_Winamp_<>0 Or load=-2
  If load=1
    ;minimize winamp
    Winamp_Hide()
  EndIf
  ProcedureReturn hwnd_Winamp_
EndProcedure

#WM_WA_IPC=#WM_USER

Procedure SendWinamp(para1,para2)
  If hwnd_Winamp_
    ProcedureReturn SendMessage_(hwnd_Winamp_,#WM_WA_IPC,para1,para2)
  EndIf
EndProcedure
Procedure CopyWinamp(para1,para2,para3)
  If hwnd_Winamp_
    cds.COPYDATASTRUCT
    cds\dwData=para1
    cds\lpData=para2
    cds\cbData=para3
    ProcedureReturn SendMessage_(hwnd_Winamp_,#WM_COPYDATA,0,cds)
  EndIf
EndProcedure
Procedure KeyWinamp(para1)
  If hwnd_Winamp_
    ProcedureReturn SendMessage_(hwnd_Winamp_,#WM_COMMAND,para1,0)
  EndIf
EndProcedure
Procedure Winamp_Version()
  ProcedureReturn SendWinamp(0,0)
EndProcedure
Procedure Winamp_StartPlayback()
  ProcedureReturn SendWinamp(0,100)
EndProcedure
Procedure Winamp_ClearFilelist()
  ProcedureReturn SendWinamp(0,101)
EndProcedure
Procedure Winamp_StartPlay()
  ProcedureReturn SendWinamp(0,102)
EndProcedure
Procedure Winamp_ChDirToDownload()
  ProcedureReturn SendWinamp(0,103)
EndProcedure
Procedure Winamp_IsPlaying();1=play, 3=pause, 0=no
  ProcedureReturn SendWinamp(0,104)
EndProcedure
Procedure Winamp_GetOutputTime(mode);0=Current Song,1=Song length
  ProcedureReturn SendWinamp(mode,105)
EndProcedure
Procedure Winamp_JumpToTime(ms)
  ProcedureReturn SendWinamp(ms,106)
EndProcedure
Procedure Winamp_SaveDefaultList()
  ProcedureReturn SendWinamp(0,120)
EndProcedure
Procedure Winamp_SetPlayListPos(pos)
  ProcedureReturn SendWinamp(pos,121)
EndProcedure
Procedure Winamp_SetVolume(vol)
  ProcedureReturn SendWinamp(vol,122)
EndProcedure
Procedure Winamp_SetPanning(pan)
  ProcedureReturn SendWinamp(pan,123)
EndProcedure
Procedure Winamp_GetListLength()
  ProcedureReturn SendWinamp(0,124)
EndProcedure
Procedure Winamp_GetListPos()
  ProcedureReturn SendWinamp(0,125)
EndProcedure
Procedure Winamp_GetInfo(mode);0 Samplerate, 1=Bitrate; 2=Channels
  ProcedureReturn SendWinamp(mode,126)
EndProcedure
Procedure Winamp_GetEQData(pos)
  ; Value      Meaning
  ; ------------------
  ; 0-9        The 10 bands of EQ Data. 0-63 (+20db - -20db)
  ; 10         The preamp value. 0-63 (+20db - -20db)
  ; 11         Enabled. zero If disabled, nonzero If enabled.
  ; 12         Autoload. zero If disabled, nonzero If enabled.
  ProcedureReturn SendWinamp(pos,127)
EndProcedure
Procedure Winamp_SetEQData(pos)
  ProcedureReturn SendWinamp(pos,128)
EndProcedure
Procedure Winamp_AddBookmark(name$)
  ProcedureReturn SendWinamp(@name$,129)
EndProcedure
Procedure Winamp_Restart()
  ProcedureReturn SendWinamp(0,135)
EndProcedure

Procedure Winamp_MBopen(url$)
  ProcedureReturn SendWinamp(@url$,136)
EndProcedure
Procedure Winamp_PlayFile(name$)
  ProcedureReturn CopyWinamp(100,@name$,Len(name$)+1)
EndProcedure
Procedure Winamp_ChDir(dir$)
  ProcedureReturn CopyWinamp(103,@di$,Len(dir$)+1)
EndProcedure

Procedure Winamp_close()
  ProcedureReturn KeyWinamp(40001)
EndProcedure
Procedure Winamp_TooglePrefs()
  ProcedureReturn KeyWinamp(40012)
EndProcedure
Procedure Winamp_ToggleTop()
  ProcedureReturn KeyWinamp(40019)
EndProcedure
Procedure Winamp_ToggleRepeat()
  ProcedureReturn KeyWinamp(40022)
EndProcedure
Procedure Winamp_ToggleShuffle()
  ProcedureReturn KeyWinamp(40023)
EndProcedure
Procedure Winamp_OpenFileDialog()
  ProcedureReturn KeyWinamp(40029)
EndProcedure
Procedure Winamp_ToggleEQ()
  ProcedureReturn KeyWinamp(40036)
EndProcedure
Procedure Winamp_DisplayModeElapsed()
  ProcedureReturn KeyWinamp(40037)
EndProcedure
Procedure Winamp_DisplayModeRemaining()
  ProcedureReturn KeyWinamp(40038)
EndProcedure
Procedure Winamp_TogglePlayList()
  ProcedureReturn KeyWinamp(40040)
EndProcedure
Procedure Winamp_ToggleAbout()
  ProcedureReturn KeyWinamp(40041)
EndProcedure
Procedure Winamp_PreviousTrack()
  ProcedureReturn KeyWinamp(40044)
EndProcedure
Procedure Winamp_Play()
  ProcedureReturn KeyWinamp(40045)
EndProcedure
Procedure Winamp_Pause()
  ProcedureReturn KeyWinamp(40046)
EndProcedure
Procedure Winamp_Stop()
  ProcedureReturn KeyWinamp(40047)
EndProcedure
Procedure Winamp_NextTrack()
  ProcedureReturn KeyWinamp(40048)
EndProcedure
Procedure Winamp_VolumeUp()
  ProcedureReturn KeyWinamp(40058)
EndProcedure
Procedure Winamp_VolumeDown()
  ProcedureReturn KeyWinamp(40059)
EndProcedure
Procedure Winamp_FFWD5s()
  ProcedureReturn KeyWinamp(40060)
EndProcedure
Procedure Winamp_REWD5d()
  ProcedureReturn KeyWinamp(40061)
EndProcedure
Procedure Winamp_ToggleWindowShade()
  ProcedureReturn KeyWinamp(40064)
EndProcedure
Procedure Winamp_Rewind5S()
  ProcedureReturn KeyWinamp(40144)
EndProcedure
Procedure Winamp_OpenDialog()
  ProcedureReturn KeyWinamp(40145)
EndProcedure
Procedure Winamp_FadeOut()
  ProcedureReturn KeyWinamp(40147)
EndProcedure
Procedure Winamp_FastForward5S()
  ProcedureReturn KeyWinamp(40148)
EndProcedure
Procedure Winamp_FirstTrack()
  ProcedureReturn KeyWinamp(40154)
EndProcedure
Procedure Winamp_OpenURLDialog()
  ProcedureReturn KeyWinamp(40155)
EndProcedure
Procedure Winamp_StopAfterTrack()
  ProcedureReturn KeyWinamp(40157)
EndProcedure
Procedure Winamp_LastTrack()
  ProcedureReturn KeyWinamp(40158)
EndProcedure
Procedure Winamp_ToggleDoublesize()
  ProcedureReturn KeyWinamp(40165)
EndProcedure
Procedure Winamp_LoadPresetDialog()
  ProcedureReturn KeyWinamp(40172)
EndProcedure
Procedure Winamp_AutoLoadPresetDialog()
  ProcedureReturn KeyWinamp(40173)
EndProcedure
Procedure Winamp_LoadDefaultPreset()
  ProcedureReturn KeyWinamp(40174)
EndProcedure
Procedure Winamp_SavePresetDialog()
  ProcedureReturn KeyWinamp(40175)
EndProcedure
Procedure Winamp_AutoSavePreset()
  ProcedureReturn KeyWinamp(40176)
EndProcedure
Procedure Winamp_DeletePreset()
  ProcedureReturn KeyWinamp(40178)
EndProcedure
Procedure Winamp_DeletePresetDialog()
  ProcedureReturn KeyWinamp(40180)
EndProcedure
Procedure Winamp_ToggleEasyMove()
  ProcedureReturn KeyWinamp(40186)
EndProcedure
Procedure Winamp_FileInfoBox()
  ProcedureReturn KeyWinamp(40188)
EndProcedure
Procedure Winamp_ToggleTitleAutoScr()
  ProcedureReturn KeyWinamp(40189)
EndProcedure
Procedure Winamp_OptionsVis()
  ProcedureReturn KeyWinamp(40190)
EndProcedure
Procedure Winamp_OptionsVisPlugin()
  ProcedureReturn KeyWinamp(40191)
EndProcedure
Procedure Winamp_ExecuteVis()
  ProcedureReturn KeyWinamp(40192)
EndProcedure
Procedure Winamp_JumpToTimeDialog()
  ProcedureReturn KeyWinamp(40193)
EndProcedure
Procedure Winamp_JumpToFileDialog()
  ProcedureReturn KeyWinamp(40194)
EndProcedure
Procedure Winamp_10TracksBack()
  ProcedureReturn KeyWinamp(40197)
EndProcedure
Procedure Winamp_SkinSelector()
  ProcedureReturn KeyWinamp(40219)
EndProcedure
Procedure Winamp_CofigureVisPlugin()
  ProcedureReturn KeyWinamp(40221)
EndProcedure
Procedure Winamp_PresetFromEQ()
  ProcedureReturn KeyWinamp(40253)
EndProcedure
Procedure Winamp_PresetToEQ()
  ProcedureReturn KeyWinamp(40254)
EndProcedure
Procedure Winamp_ToggleWindowVisible()
  ProcedureReturn KeyWinamp(40258)
EndProcedure
Procedure Winamp_TogglePlayListShade()
  ProcedureReturn KeyWinamp(40266)
EndProcedure
Procedure Winamp_ReloadSkin()
  ProcedureReturn KeyWinamp(40291)
EndProcedure
Procedure Winamp_ToggleMiniBrowser()
  ProcedureReturn KeyWinamp(40298)
EndProcedure
Procedure Winamp_ShowBookmark()
  ProcedureReturn KeyWinamp(40320)
EndProcedure
Procedure Winamp_AddTrackToBookmark()
  ProcedureReturn KeyWinamp(40321)
EndProcedure
Procedure Winamp_PlayAudioCD()
  ProcedureReturn KeyWinamp(40323)
EndProcedure

Procedure.s Winamp_GetCurrentTitle()
  If hwnd_Winamp_
    adr=AllocateMemory(#MAX_PATH+1000);AllocateMemory(#Winamp_memoryid,2048)
    GetWindowText_(hwnd_Winamp_,adr,#MAX_PATH+999)
    a$=PeekS(adr):a$=Left(a$,FindString(a$," - Winamp",0))
    a=FindString(a$,". ",0)+2
    a$=Mid(a$,a,Len(a$)-a+1)
    FreeMemory(adr)
    ProcedureReturn a$
  Else
    ProcedureReturn ""
  EndIf
EndProcedure
gansta93
Messages : 1448
Inscription : jeu. 26/févr./2004 11:17
Localisation : Le Village
Contact :

Message par gansta93 »

Merci, il ne me reste qu'à comprendre tout ça... encore merci.
gansta93
Messages : 1448
Inscription : jeu. 26/févr./2004 11:17
Localisation : Le Village
Contact :

Message par gansta93 »

Comme je le disais, c'était pour le titre qu'il me falait ça... et il s'avair que ça ne me retourne pas le titre, mais... rien.
Si quelqu'un pouvait m'éclairer svp...
gansta93
Messages : 1448
Inscription : jeu. 26/févr./2004 11:17
Localisation : Le Village
Contact :

Message par gansta93 »

Arf... rien ne marche... j'arrive pas à avoir le titre joué dans Winamp.
gansta93
Messages : 1448
Inscription : jeu. 26/févr./2004 11:17
Localisation : Le Village
Contact :

Message par gansta93 »

Bon, réessayé avec PureBasic 3.94, marche toujours pas. Mais j'ai un fichier .h récupéré dans les sources de WWWinamp (qui sert à contrôler Winamp par une interface web). Quelqu'un peut-il me dire si le code en C correspond avec le code de CallWinamp.pbi svp ?

Code : Tout sélectionner

//Psuedo IPC for frontends for Winamp v1.55+ (< 2.0)


#define WM_WA_IPC WM_USER
// messages are sent to the winamp window using:
//result = SendMessage(hwnd_winamp,WM_WA_IPC,command_data,command);


/* Messages available to send */

#define IPC_GETVERSION 0
/*
        IPC_GETVERSION is sent to the window, and the return value is the version
                Version 1.55 = 0x1551
                Version 1.6b = 0x16A0
                Version 1.60 = 0x16AF
                Version 1.61 = 0x16B0
                Version 1.62 = 0x16B1
                Version 1.64 = 0x16B3
        the command_data parameter is 0.
        so, 
        if (SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETVERSION) != 0x1551)
                MessageBox(NULL,"Error, Winamp 1.55 not found","Warning",MB_OK);
*/


#define IPC_PLAYFILE 100
/*
        IPC_PLAYFILE is sent to the window for each char of a null terminated string of a file to ADD
        to the playlist (it doesn't change the playing status)
        for example:
                char *file = "C:\\download\\booga.mp3";
                int x;
                for (x = 0; x <= strlen(file); x ++)
                        PostMessage(hwnd_winamp,WM_WA_IPC,(LPARAM)file[x],IPC_PLAYFILE);
        will add "C:\download\booga.mp3" to the end of the playlist
*/

#define IPC_DELETE 101
/* 
        IPC_DELETE deletes the internal Winamp playlist.
                SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_DELETE);
*/

#define IPC_STARTPLAY 102
/* 
        IPC_STARTPLAY starts the playing.
                SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_STARTPLAY);
*/

#define IPC_CHDIR 103
/*
        IPC_CHDIR is sent to the window for each char of a null terminated string of a directory to change to
        for example:
                char *dir = "C:\\Download";
                int x;
                for (x = 0; x <= strlen(file); x ++)
                        PostMessage(hwnd_winamp,WM_WA_IPC,(LPARAM)dir[x],IPC_PLAYFILE);
        will change the winamp process to "C:\download" (useful for relative pathnames and loading playlists)

*/
#define IPC_ISPLAYING 104
/*
        IPC_ISPLAYING returns the status of playback.
        If it returns 1, it is playing. if it returns 3, it is paused, if it returns 0, it is not playing.
        If it returns something other than 1,3,or 0, something is screwed.
        isplaying = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_ISPLAYING);
*/


#define IPC_GETOUTPUTTIME 105
/*
        IPC_GETOUTPUTTIME returns the position in milliseconds of the current song.
        Returns -1 if not playing or error.
        song_pos = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETOUTPUTTIME);
*/

#define IPC_JUMPTOTIME 106
/*
        *ONLY AVAILABLE IN v1.60+*
        IPC_JUMPTOTIME sets the position in milliseconds of the current song (approximately)
        Returns -1 if not playing, 1 on eof, or 0 if successful
        SendMessage(hwnd_winamp,WM_WA_IPC,new_song_pos,IPC_JUMPTOTIME);
*/


// THESE MIGHT CHANGE in the future :)
//Also, you can send standard WM_COMMAND messages to the Winamp window (for other controls), including
// Send using SendMessage(hwnd_winamp,WM_COMMAND,WINAMP_OPTIONS_EQ/*orwhatever*/,0);

// toggles the EQ window
#define WINAMP_OPTIONS_EQ               40036
// toggles the playlist window
#define WINAMP_OPTIONS_PLEDIT           40040
// turns the volume up a little
#define WINAMP_VOLUMEUP                 40058
// turns the volume down a little
#define WINAMP_VOLUMEDOWN               40059
// fast forwards 5 seconds
#define WINAMP_FFWD5S                   40060
// rewinds 5 seconds
#define WINAMP_REW5S                    40061
// the following are the five main control buttons, with optionally shift or control pressed
// (for the exact functions of each, just try it out)
#define WINAMP_BUTTON1                  40044
#define WINAMP_BUTTON2                  40045
#define WINAMP_BUTTON3                  40046
#define WINAMP_BUTTON4                  0x9C6F
#define WINAMP_BUTTON5                  40048
#define WINAMP_BUTTON1_SHIFT            40144
#define WINAMP_BUTTON2_SHIFT            40145
#define WINAMP_BUTTON3_SHIFT            40146
#define WINAMP_BUTTON4_SHIFT            0x9CD3
#define WINAMP_BUTTON5_SHIFT            40148
#define WINAMP_BUTTON1_CTRL             40154
#define WINAMP_BUTTON2_CTRL             40155
#define WINAMP_BUTTON3_CTRL             40156
#define WINAMP_BUTTON4_CTRL             40157
#define WINAMP_BUTTON5_CTRL             40158
// pops up the load file(s) box
#define WINAMP_FILE_PLAY                40029
// pops up the preferences
#define WINAMP_OPTIONS_PREFS            40012
// toggles always on top
#define WINAMP_OPTIONS_AOT              40019
// pops up the about box :)
#define WINAMP_HELP_ABOUT               40041


// hope this helps, 
// -Justin [justin@nullsoft.com]
C sûr que ça devrait marcher avec celui-là, vu que c celui que WWWinamp utilise et il marche avec la dernière version de Winamp.
Je devrais peut-être me mettre au c moi... ;-)
gansta93
Messages : 1448
Inscription : jeu. 26/févr./2004 11:17
Localisation : Le Village
Contact :

Message par gansta93 »

Rebonjour,

J'ai fais un code en m'inspirant de CallWinamp.pbi pour récupérer le titre du fichier joué.

Code : Tout sélectionner

id = FindWindow_("Winamp v1.x",#Null)
If id
  title$=Space(63000)
  GetWindowText_(id,title$,63000)
  title$=StringField(title$,2,".")
  title$=Right(title$,Len(title$)-1)
  pos=FindString(title$," - Winamp",1)
  title$=Left(title$,pos-1)
  Debug title$
EndIf
Si quelqu'un a quelque chose à apporter à ce code...
Sinon j'ai passé le fichier .h que j'ai mis plus haut à HeaderCinverter, et j'ai eu ceci, plain de constentes (je crois que je vais faire une lib...)

Code : Tout sélectionner

#WM_WA_IPC = #WM_USER
#IPC_GETVERSION = 0
#IPC_PLAYFILE = 100
#IPC_DELETE = 101
#IPC_STARTPLAY = 102
#IPC_CHDIR = 103
#IPC_ISPLAYING = 104
#IPC_GETOUTPUTTIME = 105
#IPC_JUMPTOTIME = 106
#WINAMP_OPTIONS_EQ = 40036
#WINAMP_OPTIONS_PLEDIT = 40040
#WINAMP_VOLUMEUP = 40058
#WINAMP_VOLUMEDOWN = 40059
#WINAMP_FFWD5S = 40060
#WINAMP_REW5S = 40061
#WINAMP_BUTTON1 = 40044
#WINAMP_BUTTON2 = 40045
#WINAMP_BUTTON3 = 40046
#WINAMP_BUTTON4 = $9C6F
#WINAMP_BUTTON5 = 40048
#WINAMP_BUTTON1_SHIFT = 40144
#WINAMP_BUTTON2_SHIFT = 40145
#WINAMP_BUTTON3_SHIFT = 40146
#WINAMP_BUTTON4_SHIFT = $9CD3
#WINAMP_BUTTON5_SHIFT = 40148
#WINAMP_BUTTON1_CTRL = 40154
#WINAMP_BUTTON2_CTRL = 40155
#WINAMP_BUTTON3_CTRL = 40156
#WINAMP_BUTTON4_CTRL = 40157
#WINAMP_BUTTON5_CTRL = 40158
#WINAMP_FILE_PLAY = 40029
#WINAMP_OPTIONS_PREFS = 40012
#WINAMP_OPTIONS_AOT = 40019
#WINAMP_HELP_ABOUT = 40041
Répondre