AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

i would like to define the volume of this mci handle!

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
soggos



Joined: 27 Mar 2008
Posts: 37
Location: France

PostPosted: Wed Aug 13, 2008 10:56 am    Post subject: i would like to define the volume of this mci handle! Reply with quote

Cause i have a console
i can make sample : define the begin and the end of the loop
it's good for live, but i would like to define the volume of this mci handle!
not define the master or wave just this mci
cause i want to drive many console for mixing
the code:
Code:



if %0% != 0
   {
   SelectedFileName = %1%
   }
ELSE
   SelectedFileName =

   
   

gosub console



if %0% != 0
{

   h := Media_Open(SelectedFileName)

SplitPath, SelectedFileName, name, dir, ext, name_no_ext, drive

Media_ToHHMMSS(Media_Length(h), hh, mm, ss)
TEMPS_TOTAL = %hh%:%mm%:%ss%

len := Media_Length(h)
guicontrol ,,TEMPS_POSI2, %len%
guicontrol ,,TEMPS_POSI1, 0
guicontrol ,,NOMTITRE, %dir% %name_no_ext%
Media_Play(h)
}
SetTimer ,AFFICHE_TEMPS,100
return






; ------------------------------------------------------------------

CONSOLE:
Gui, Font, S8 Bold cGreen, Verdana
Gui, Add, Text, x6 y7 w320 h20 vNOMTITRE +Center,
Gui, Add, Text, x326 y7 w60 h20 vTEMPS_PASSE +Center, 0
Gui, Add, Text, x116 y27 w80 h20 vTEMPS_PASSE2 +Right, 10
Gui, Font, S8 Bold cBlack, Verdana
Gui, Add, Text, x386 y7 w60 h20 , %TEMPS_TOTAL%
Gui, Font, S7 Norm cBlack, Verdana
Gui, Add, Button, x226 y67 w100 h20 gJOUER, &JOUER
Gui, Add, Button, x326 y67 w100 h20 gPAUSER, &PAUSE
Gui, Add, Button, x326 y47 w100 h20 gSTOPPER, &STOPPER
Gui, Add, Button, x36 y47 w80 h20 gBOUCLE1, &Deb Boucle
Gui, Add, Button, x36 y67 w80 h20 gBOUCLE2, &Faire Boucle
Gui, Add, Edit, x116 y47 w80 h20 vTEMPS_POSI1 +Right,
Gui, Add, Edit, x116 y67 w80 h20 vTEMPS_POSI2 +Right,
Gui, Add, Edit, x226 y47 w100 h20 vTEMPS_POSIN,
Gui, Add, Progress, x11 y97 w520 h10 cBlue vMyProgress,
Gui, Add, Slider, x6 y102 w530 h20 Range0-%len% Page1000 TickInterval500 NoTicks vMyProgress2 gALLER, 0
Gui, Add, Button, x196 y47 w20 h20 gRAZBOUCLE1, 0
Gui, Add, Button, x36 y87 w160 h10 gRAZBOUCLE2, fin
Gui, Add, Button, x6 y47 w30 h20 gALLER1, aller
Gui, Add, Button, x6 y67 w30 h20 gALLER2, aller
Gui, Add, Button, x16 y127 w250 h20 gALLERMOINS, -
Gui, Add, Button, x276 y127 w250 h20 gALLERPLUS, +
Gui, Add, Text, x306 y27 w120 h20 vSTATUSdeLECTURE +Center, %STATUSdeLECTURE%
Gui, Add, Checkbox, x226 y27 w80 h20 vFAIREBOUCLE, &BOUCLE

Gui, Add, Button, x226 y5 w80 h20 gVOLUMEmoins, &moins




Gui, Show,    h195 w562,, %SelectedFileName%
Return


; ------------------------------------------------------------------
AFFICHE_TEMPS:

   pos := Media_Position(h)
guicontrol ,,TEMPS_PASSE2, %pos%
    GuiControl,, TEMPS_POSIN, %pos%

combien := ( pos * 100 ) / len
    GuiControl,, MyProgress, %combien%
   
    ;GuiControl,, MyProgress2, %combien%

az := Media_Status(h)
guicontrol ,,STATUSdeLECTURE, %az%

guiControlGet ,FAIREBOUCLE
if FAIREBOUCLE = 1
   goto BOUCLER
return


; ------------------------------------------------------------------
BOUCLER:

   settimer , AFFICHE_TEMPS, off
guiControlGet ,TEMPS_POSI1
   Media_Seek(h, TEMPS_POSI1, False)
Media_Play(h)
   
loop   
{
guiControlGet ,FAIREBOUCLE
if FAIREBOUCLE = 0
{
   settimer , AFFICHE_TEMPS, on
break
}
guicontrol ,,STATUSdeLECTURE, en BOUCLE
guiControlGet ,TEMPS_POSI1
guiControlGet ,TEMPS_POSI2
   pos := Media_Position(h)
      If(pos >= TEMPS_POSI2)
   {
   Media_Seek(h, TEMPS_POSI1, False)
   }
else
{
guicontrol ,,TEMPS_PASSE2, %pos%
combien := ( pos * 100 ) / len
    GuiControl ,, MyProgress, %combien%
}   
}
   
   
return

; ------------------------------------------------------------------

ALLER:

guiControlGet ,MyProgress2
guicontrol ,,TEMPS_POSIN, %MyProgress2%

   Media_Seek(h, MyProgress2, False)
return

; ------------------------------------------------------------------
BOUCLE1:
pos := Media_Position(h)
guicontrol ,,TEMPS_POSI1, %pos%
return


; -----------------------------------------------------------------
BOUCLE2:
pos := Media_Position(h)
guicontrol ,,TEMPS_POSI2, %pos%
guiControl ,,FAIREBOUCLE,1
return


; ------------------------------------------------------------------
RAZBOUCLE1:
guicontrol ,,TEMPS_POSI1, 0
return
RAZBOUCLE2:
len := Media_Length(h)
guicontrol ,,TEMPS_POSI2, %len%
return



; ------------------------------------------------------------------
ALLER1:
guiControlGet ,TEMPS_POSI1
Media_Seek(h, TEMPS_POSI1, False)
return
ALLER2:
guiControlGet ,TEMPS_POSI2
Media_Seek(h, TEMPS_POSI2, False)
return


; ------------------------------------------------------------------
ALLERPLUS:
Media_Seek(h, 100, True)
   pos := Media_Position(h)
guicontrol ,,TEMPS_POSIN, %pos%
return

ALLERMOINS:
Media_Seek(h, -100, True)
   pos := Media_Position(h)
guicontrol ,,TEMPS_POSIN, %pos%
return






; ------------------------------------------------------------------
JOUER:
;guiControlGet ,TEMPS_POSIN
;guiControlGet ,MyProgress2

;Media_Seek(h, TEMPS_POSIN, False)
Media_Play(h)
return

STOPPER:
Media_Stop(h)
return

PAUSER:
Media_Pause(h)
return

PAUSERR:
Media_Resume(h)
return





; =======================================================================================
; ======================================================================================
;   ... . (drag&drop, rezise ...

   GuiDropFiles:  ; Support drag & drop.

   
compte =
   ;   StringSplit, Array, A_GuiEvent, .

Loop, parse, A_GuiEvent, `n
{
    SelectedFileName = %A_LoopField%  ; Get the first file only (in case there's more than one).
    compte+=1
   ;   break
}


if compte >1
{
FileList = %A_GuiEvent%
Sort, FileList
;Loop, parse, FileList, `n
    ;GuiControl ,,
   ;MsgBox File number %A_Index% is:`n%A_LoopField%.
   
GuiControl,, MyEdit1, %FileList%  ; Put the text into the control.
   ;   Gosub LISTEdeFICHIERS
}


   else
   {
   
Loop, parse, A_GuiEvent, `n
   {
   
 ;Gui , Show, , >  %A_GuiEvent%
 ;CurrentFileName = %A_GuiEvent%
 
   Gosub NOUVEAU
    ;   SelectedFileName = %A_LoopField%  ; Get the first file only (in case there's more than one).
      break
   }
   

   

   ;   GuiControl,, MyEdit1, %SelectedFileName%  ; Put the text into the control.
   

 

   }   


return

; ------------------------------------------------------------------
NOUVEAU:

;Media_Close(h)
gui destroy
;msgbox ,4096,, %SelectedFileName%


h :=Media_Open(SelectedFileName)

Media_Play(h)

 len := Media_Length(h)

Media_ToHHMMSS(Media_Length(h), hh, mm, ss)
TEMPS_TOTAL = %hh%:%mm%:%ss%
 gosub CONSOLE
 
SplitPath, SelectedFileName, name, dir, ext, name_no_ext, drive
guicontrol ,,NOMTITRE, %name_no_ext%
guicontrol ,,TEMPS_POSI2, %len%
guicontrol ,,TEMPS_POSI1, 0
guicontrol ,,MyProgress2, 0
guicontrol ,,TEMPS_TOTAL, %TEMPS_TOTAL%




return



F5::
reload
return

F7::
ExitApp
return



GuiClose:
ExitApp




; ----------------------------------------------------------------------------------;;
;; AutoHotkey Version: 1.0.47.04
;; Language:       Anyone
;; Author:         Fincs <fernandoincs@hotmail.com>
;:
;; Script Function:
;;   Functions to handle multimedia files
;;
;: Title: Media.ahk - Multimedia functions to use with AutoHotkey

;
; Function: Media_Open
; Description:
;      Opens a multimedia file for use with other multimedia functions
; Syntax: Media_Open(File[, Alias=""])
; Parameters:
;      File - The multimedia file
;      Alias - (optional) A name such as media1, if you do not
;         specify one it is automatically generated
; Return Value:
;      The multimedia handle or a 0 to indicate failure
; Example:
;      file:mediaopenclose-example.ahk
;Media_Play(h)


;h := Media_Open("I:\2.WMV")




; -----------------------------------------------------------------------------------
Media_Open(File, Alias=""){
   Static SoundNumber = 0
   IfNotExist, %File%
   {
      ErrorLevel = -2
      Return 0
   }
   If Alias =
   {
      SoundNumber ++
      Alias = AutoHotkey%SoundNumber%
   }
   ;Loop, %Param1%
   ;   File_Short = %A_LoopFileShortPath%
   ErrorLevel := _mciExecute("open """ File """ alias " Alias)
   Return Alias
}

;
; Function: Media_Close
; Description:
;      Closes a multimedia file
; Syntax: Media_Close(MediaHandle)
; Parameters:
;      MediaHandle - Multimedia handle returned by [url=Media_Open.htm]Media_Open()[/url]
; Return Value:
;      Return value returned by MCI
; Example:
;      file:mediaopenclose-example.ahk
;

Media_Close(MediaHandle){
   Return _mciExecute("close " MediaHandle)
}

;
; Function: Media_Play
; Description:
;      Plays a multimedia file from the current position (beginning is the default)
; Syntax: Media_Play(MediaHandle[, Wait=0])
; Parameters:
;      MediaHandle - Multimedia handle returned by [url=Media_Open.htm]Media_Open()[/url]
;      Wait - (optional) If TRUE the script will wait for the multimedia file to finish before continuing.
;         Else the script will continue while the multimedia file is playing.
; Return Value:
;      Return value returned by MCI
; Example:
;      file:playonesecond-example.ahk
;

Media_Play(MediaHandle, Wait=0){
   If(Wait <> 0 AND Wait <> 1)
      Return -2
   If Wait = 1
      Return _mciExecute("play " MediaHandle " wait")
   Else
      Return _mciExecute("play " MediaHandle)
}

;
; Function: Media_Stop
; Description:
;      Stops the multimedia file
; Syntax: Media_Stop(MediaHandle)
; Parameters:
;      MediaHandle - Multimedia handle returned by [url=Media_Open.htm]Media_Open()[/url]
; Return Value:
;      Return value returned by MCI
; Example:
;      file:playonesecond-example.ahk
;

Media_Stop(MediaHandle){
   ret := _mciExecute("seek " MediaHandle " to start")
   ret := ret && _mciExecute("stop " MediaHandle)
   Return ret
}

;
; Function: Media_Pause
; Description:
;      Pauses the multimedia file
; Syntax: Media_Pause(MediaHandle)
; Parameters:
;      MediaHandle - Multimedia handle returned by [url=Media_Open.htm]Media_Open()[/url]
; Return Value:
;      Return value returned by MCI
; Example:
;      file:playonesecond-example.ahk
;

Media_Pause(MediaHandle){

   Return _mciExecute("pause " MediaHandle)
}

;
; Function: Media_Resume
; Description:
;      Resumes the multimedia file after being paused
; Syntax: Media_Resume(MediaHandle)
; Parameters:
;      MediaHandle - Multimedia handle returned by [url=Media_Open.htm]Media_Open()[/url]
; Return Value:
;      Return value returned by MCI
;

Media_Resume(MediaHandle){
   Return _mciExecute("resume " MediaHandle)
}


; MLONG MCIWndPlayReverse(
  ; hwnd 
; );
; MCI_SETAUDIO

;
; Function: Media_Length
; Description:
;      Returns the length of the multimedia file
; Syntax: Media_Length(MediaHandle)
; Parameters:
;      MediaHandle - Multimedia handle returned by [url=Media_Open.htm]Media_Open()[/url]
; Return Value:
;      Length of the multimedia file in milliseconds
; Example:
;      file:fileinfo-example.ahk
;

Media_Length(MediaHandle){
   rc := _mciSendString("set time format milliseconds", dummy)
   If !rc
      Return -rc
   _mciSendString("status " MediaHandle " length", ret)
   Return ret
}

;
; Function: Media_Seek
; Description:
;      Seeks the multimedia file to a specified time
; Syntax: Media_Seek(MediaHandle, Position[, Relative=0])
; Parameters:
;      MediaHandle - Multimedia handle returned by [url=Media_Open.htm]Media_Open()[/url]
;      Pos - Time to seek to in milliseconds
;      Relative - (Optional) If specified, the position specified is relative
;         to the current position
; Return Value:
;      Return value returned by MCI
; Example:
;      file:playnseek-example.ahk
;

Media_Seek(MediaHandle, Position, Relative=0){
   rc := _mciSendString("set time format milliseconds", dummy)
   _mciSendString("status " MediaHandle " mode", stat)
   If stat = playing
      _mciExecute("pause " MediaHandle)
   If !rc
      Return -rc
   _mciSendString("status " MediaHandle " position", cpos)
   _mciSendString("status " MediaHandle " length", length)
   If Relative = 1
      cpos += Position
   Else
      cpos := Position
   If cpos > %length%
      cpos = %length%
   If cpos < 0
      cpos = 0
   ret := _mciExecute("seek " MediaHandle " to " cpos)
   If stat = playing
      _mciExecute("play " MediaHandle)
   Return ret
}

 
;
; Function: Media_Status
; Description:
;      Returns the status of the multimedia file
; Syntax: Media_Status(MediaHandle)
; Parameters:
;      MediaHandle - Multimedia handle returned by [url=Media_Open.htm]Media_Open()[/url]
; Return Value:
;      Current status of the multimedia file
; Remarks:
;      All devices can return the "not ready", "paused", "playing", and "stopped" values.
;      Some devices can return the additional "open", "parked", "recording", and "seeking" values.(MSDN)
;


Media_Status(MediaHandle){
   _mciSendString("status " MediaHandle " mode", ret)
   Return ret
}

;
; Function: Media_Position
; Description:
;      Returns the current position of the multimedia file
; Syntax: Media_Position(MediaHandle)
; Parameters:
;      MediaHandle - Multimedia handle returned by [url=Media_Open.htm]Media_Open()[/url]
; Return Value:
;      Position of the multimedia file in milliseconds
; Example:
;      file:mediaplayer-example.ahk
;

Media_Position(MediaHandle){
   rc := _mciSendString("set time format milliseconds", dummy)
   If !rc
      Return -rc
   _mciSendString("status " MediaHandle " position", ret)
   Return ret
}

;===============================================================================

;
; Function: Media_ToMilliseconds
; Description:
;      Converts the specified hour, minute and second into a valid milliseconds timestamp
; Syntax: Media_ToMilliseconds(Hour, Min, Sec)
; Parameters:
;      Hour, Min, Sec - Position to convert to milliseconds
; Return Value:
;      The specified position converted to milliseconds
;

Media_ToMilliseconds(Hour, Min, Sec){
   milli := Sec * 1000
   milli += (Min * 60) * 1000
   milli += (Hour * 3600) * 1000
   Return milli
}

;
; Function: Media_ToHHMMSS
; Description:
;      Converts the specified milliseconds timestamp to a (Hour, Min, Sec) timestamp
; Syntax: Media_ToHHMMSS(milliseconds, ByRef Hour, ByRef Min, ByRef Sec)
; Parameters:
;      milliseconds - Milliseconds timestamp to convert
;      (ByRef) Hour, Min, Sec - Output variables where store the converted timestamp
; Example:
;      file:fileinfo-example.ahk
;
Media_ToHHMMSS(milliseconds, ByRef Hour, ByRef Min, ByRef Sec){
   milliseconds //= 1000
   Sec := Mod(milliseconds, 60)
   milliseconds //= 60
   Min := Mod(milliseconds, 60)
   milliseconds //= 60
   Hour := Mod(milliseconds, 60)
}

_mciExecute(string){
   Return DllCall("winmm.dll\mciExecute", "str", string, "Cdecl Int")
}

_mciSendString(string, ByRef output, handle=0){
   VarSetCapacity(output, 36, 0)
   ret := DllCall("winmm.dll\mciSendStringA", "str", string, "str", output, "int", 36, "uint", 0, "Cdecl Int")
   If ErrorLevel
      Return -ErrorLevel
   Return ret
}



How-to define the volume of this mci ??

i have tested:

Code:

 Media_VOLUME(MediaHandle,iVol ){
 
;_mciSendString("MCIWnd_SetVolume" MediaHandle ,10)
;_mciExecute("MCIWndSet_Volume" MediaHandle ivol)
;_mciSendCommand("MCIWnd_SetVolume" MediaHandle "ivol",ivol)
;_mciExecute("MCIWnd_SetVolume" MediaHandle "ivol" ivol)
;LONG MCIWndSetVolume(MediaHandle ,ivol) ;Parameters
; _MCIWndSetVolume(MediaHandle ,500)

    Return
 }


VOLUMEmoins:                 ; with a button you call the function  Media_VOLUME(h,ivol)
ivol := ivol-100
 Media_VOLUME(h,ivol)
return



but nothing

Question
Back to top
View user's profile Send private message
soggos



Joined: 27 Mar 2008
Posts: 37
Location: France

PostPosted: Wed Aug 13, 2008 12:10 pm    Post subject: Reply with quote

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group