 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
nataschabakker
Joined: 18 May 2009 Posts: 11 Location: Amsterdam Holand
|
Posted: Tue Oct 06, 2009 9:16 am Post subject: Sound problem, muting with extra sec |
|
|
Hi,
I have build a sampler for a quiz for my school for kids.
With this we can play a music song with medaplayer and when i have select a jingle and pres the button, he mute the music for x seconds, after the jingle has playing, the music is back. Its works fine.
But there a problem with calculating some file, sometimes a jinlge is 2 sec and 600 mmsec, but the script stopt by 2 sec's. I think he can't calculate mmsec.
Now is it posiable to take a extra sec for every jingle, so when i select a jingle, he calculate it for 2 seconds, but he mute the player for 3 seconds.
Can someone help me with this? It would be great, thanks allot.
X Natascha
ps maybe can some look at the script too if i make it correct anyway, maby there are some things i can be make better? suggestions.
| Code: |
SetFormat,float,0.0
MP3INI=%A_scriptdir%\MP3INI.txt
ifnotexist,%MP3INI%
{
IniWrite,nothing2 , %MP3INI% ,MP3short , KEY1
IniWrite,2000x , %MP3INI% ,MP3shortlenght , KEY_1
}
Gui,2:Add, Button, x10 y10 w90 h90 gJingle1,Tune 1
Gui,2:Add, Picture, x10 y110 w18 h18 gMH1,%A_ScriptDir%\inc\open.ico
IniRead,MP3L1, %MP3INI% ,MP3shortlenght , KEY_1
Gui,2:Add, Text , x30 y110 ,Select
Gui,2:Show, x300 y3 h260 w130, Test
MP3L2:=(MP3L1/1000)
return
;-------------- plays jingle1 for x seconds ----------
Jingle1:
PostMessage, 0x111, 18816, 150, , Windows Media Player
PostMessage, 0x111, 18816, 150, , Windows Media Player
PostMessage, 0x111, 18816, 150, , Windows Media Player
PostMessage, 0x111, 18816, 150, , Windows Media Player
PostMessage, 0x111, 18816, 150, , Windows Media Player
PostMessage, 0x111, 18816, 150, , Windows Media Player
PostMessage, 0x111, 18816, 150, , Windows Media Player
PostMessage, 0x111, 18816, 150, , Windows Media Player
PostMessage, 0x111, 18816, 150, , Windows Media Player
PostMessage, 0x111, 18816, 150, , Windows Media Player
PostMessage, 0x111, 18816, 150, , Windows Media Player
GuiControl,2:Text,playx,Jingle1
IniRead,MP3jingle1 , %MP3INI% ,MP3short , KEY1
soundplay,%MP3jingle1%
SetTimer, a_continue, %MP3L1% ; run a_continue once, in 4 seconds.
return
a_continue:
soundplay,notexisted.mp3
IfWinExist, %moz%
{
;WinActivate, %moz%
;WinWaitActive, %moz%,,5
ControlSend,,{space}, %moz%
}
PostMessage, 0x111, 18815, 50, , Windows Media Player
PostMessage, 0x111, 18815, 50, , Windows Media Player
PostMessage, 0x111, 18815, 50, , Windows Media Player
PostMessage, 0x111, 18815, 50, , Windows Media Player
PostMessage, 0x111, 18815, 50, , Windows Media Player
PostMessage, 0x111, 18815, 50, , Windows Media Player
PostMessage, 0x111, 18815, 50, , Windows Media Player
PostMessage, 0x111, 18815, 50, , Windows Media Player
PostMessage, 0x111, 18815, 50, , Windows Media Player
PostMessage, 0x111, 18815, 50, , Windows Media Player
return
MH1:
; --- write MP3 file path short jingle ------------
FileSelectFile, selectedmp3short ,1, %AA%, Select your MP3/WAV file short jingle,*.mp3;*.wav
if selectedmp3short=
return
IniWrite,%selectedmp3short% , %MP3INI% ,MP3short , KEY1
gosub,A2
IniRead,MP3L1, %MP3INI% ,MP3shortlenght , KEY_1
MP3L2:=(MP3L1/1000)
GuiControl,2:Text,Time1,%MP3L2%
return
;---------------------------------------------------------------------------
A2:
;---------------------- TIME LENGHT DURATION MP3----------------------------
;TAG........... http://www.softpedia.com/progDownload/Tag-Download-21935.html
;----------------------------------------------------------------------------
IniRead,MP3VAR2, %MP3INI% ,MP3short , KEY1
Musicfile="%MP3VAR2%"
F1=test55.txt
ifexist,%F1%
Filedelete,%F1%
DetectHiddenWindows On
mycmd=c:\tag.exe --test --tofilen %F1% %Musicfile%
run,%comspec% /K %myCmd%,,hide,PID1
WinWait %ComSpec% ahk_pid %PID1%
WinActivate ahk_pid %PID1%
process,close,%PID1%
loop,read,%F1%
{
LR=%A_loopreadline%
ifinstring,LR,Details:
stringsplit,C,LR,`,
stringsplit,D,C3,`:
stringmid,d1a,d1,11,2
}
D1b:=ABS(D1a)
D2b:=ABS(D2)
MINMilliSEC:=((D1b*60)*1000)
SECMilliSEC:=(D2b*1000)
Total:=(MINMilliSEC+SECMilliSEC)
;msgbox,Minutes-ms=%MINmilliSEC%`nSeconds-ms=%SECMilliSEC%`nTotal=%total%
;run,%F1%
IniWrite,%Total% , %MP3INI% ,MP3shortlenght , KEY_1
;exitapp
return
;------------------------------------------------------------------------------
|
|
|
| Back to top |
|
 |
txquestor
Joined: 22 Aug 2009 Posts: 294
|
Posted: Tue Oct 06, 2009 10:36 pm Post subject: |
|
|
Try the command "A_Tickount"
| Code: |
_TickCount The number of milliseconds since the computer was rebooted. By storing A_TickCount in a variable, elapsed time can later be measured by subtracting that variable from the latest A_TickCount value. For example:
StartTime := A_TickCount
Sleep, 1000
ElapsedTime := A_TickCount - StartTime
MsgBox, %ElapsedTime% milliseconds have elapsed.If you need more precision than A_TickCount's 10ms, use QueryPerformanceCounter().
|
The QueryPerformanceCounter gives more accuracy.
| Code: |
; Example: Demonstrates QueryPerformanceCounter(), which gives more precision than A_TickCount's 10ms.
DllCall("QueryPerformanceCounter", "Int64 *", CounterBefore)
Sleep 1000
DllCall("QueryPerformanceCounter", "Int64 *", CounterAfter)
MsgBox % "Elapsed QPC time is " . CounterAfter - CounterBefore
|
Have Fun,  _________________
"Man's quest for knowledge is an expanding series whose limit is infinity" |
|
| Back to top |
|
 |
nataschabakker
Joined: 18 May 2009 Posts: 11 Location: Amsterdam Holand
|
Posted: Wed Oct 07, 2009 8:09 am Post subject: difficult |
|
|
Oke oeps
Thats too difficult for me, can you explane it for me how to configure that with my situation/script? |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|