#123230 - 2004-07-19 05:11 PM
Play Command how to stop or restart the wav-file
|
LarsRoan
Lurker
Registered: 2004-07-19
Posts: 3
|
Hello
As a member of a norwegian choir I am on my way to make a script for exercise. I have no experience with KiXtart so I'm calling you for help.
When we start at an new song we'll make a number of short wav-files. Each of them is just 3-4-5-6 measures long (10-15 second), short pieces, with critical part of the song. By KixForms I have succeeded to make a simple form with a number of buttons like this: $Button1.OnClick = "PLAY 12.wav " $Button2.OnClick = "PLAY 27.wav " ;12 and 27 is measure number..
In this way it will be easy to repeat x number of times a short cut of the song. The plan is to distribute the package to all the other members as an exe-file. Ready for exercise.
And it funks. Except that it's not possible to restart the music-file until it's finished. That's a must! The whole idea is to >start, >restart, >restart immediately.... Neither is it possible to close the window until the play-command is finished. Here is the script (not complete):
Break On $System = CreateObject("Kixtart.System") SetConsole("HIDE") ;KD START
;************* Form ************** $Form = $System.Form() $Form.BackColor = 150,192,200 $Form.FontName = "Tahoma" $Form.FontSize = 8 $Form.Height = 291 $Form.Left = 20 $Form.Text = "KiXforms Designer Template" $Form.Top = 20 ;************************************** ;************* Button1 ************** $Button1 = $Form.Controls.Button() $Button1.FontName = "Tahoma" $Button1.FontSize = 8 $Button1.Height = 23 $Button1.Left = 40 $Button1.Text = "Meas.no 12-14" $Button1.Top = 60 $Button1.Width = 100 $Button1.OnClick = "PLAY Bess12.wav " ;************************************** ;************* Button2 ************** $Button2 = $Form.Controls.Button() $Button2.FontName = "Tahoma" $Button2.FontSize = 8 $Button2.Height = 23 $Button2.Left = 40 $Button2.Text = "Meas.no 27-32" $Button2.Top = 100 $Button2.Width = 100 $Button2.OnClick = "PLAY Bess27.wav " ;**************************************
;KD END $Form.Show While $Form.Visible $=Execute($Form.DoEvents()) Loop Exit 1
It seems like it's frozen until the wav-file is finished. I hope somebody could help me to improve this script. Isn't KiXscript the right «tool» for this job?
Best regards LarsRoan, Norway
|
|
Top
|
|
|
|
#123231 - 2004-07-19 06:44 PM
Re: Play Command how to stop or restart the wav-file
|
Chris S.
MM club member
   
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
This might help. The only problem is that you can keep hitting the "play" button even if the previous click hasn't stopped playing. Should be a problem if the wav is a short file.
Code:
Break On
Break On $System = CreateObject("Kixtart.System") SetConsole("HIDE") ;KD START
;************* Form ************** $Form = $System.Form() $Form.BackColor = 150,192,200 $Form.FontName = "Tahoma" $Form.FontSize = 8 $Form.Height = 291 $Form.Left = 20 $Form.Text = "KiXforms Designer Template" $Form.Top = 20 ;************************************** ;************* Button1 ************** $Button1 = $Form.Controls.Button() $Button1.FontName = "Tahoma" $Button1.FontSize = 8 $Button1.Height = 23 $Button1.Left = 40 $Button1.Text = "Meas.no 12-14" $Button1.Top = 60 $Button1.Width = 100 $Button1.OnClick = "fnPlayWav(c:\osusong1.wav)" ;$Button1.OnClick = "PLAY Bess12.wav " ;************************************** ;************* Button2 ************** $Button2 = $Form.Controls.Button() $Button2.FontName = "Tahoma" $Button2.FontSize = 8 $Button2.Height = 23 $Button2.Left = 40 $Button2.Text = "Meas.no 27-32" $Button2.Top = 100 $Button2.Width = 100 $Button2.OnClick = "PLAY Bess27.wav " ;**************************************
;KD END $Form.Show While $Form.Visible $=Execute($Form.DoEvents()) Loop Exit 1
Function fnPlayWav($sWavFile) If Not Exist($sWavFile) Exit 2 EndIf $objShell = CreateObject("WScript.Shell") Exit $objShell.Run ("Sndrec32.exe /play /close " + $sWavFile , 0, 0) EndFunction
|
|
Top
|
|
|
|
#123234 - 2004-07-21 04:14 PM
Re: Play Command – how to stop or restart the wav-file
|
LarsRoan
Lurker
Registered: 2004-07-19
Posts: 3
|
Thank you for helping me with the script.
Sealeopard, the plan is not to distribute any media player. Instead let the other members of the choir use their standard player for wav-files.
Chris S, isn't that what this function is for? To close down Sndrec32.exe, windows standard player, when the file has reached the end? Your script close down the windows form immediately after opening up.
Function fnPlayWav($sWavFile) If Not Exist($sWavFile) Exit 2 EndIf $objShell = CreateObject("WScript.Shell") Exit $objShell.Run ("Sndrec32.exe /play /close " + $sWavFile , 0, 0) EndFunction
Lonkero , maybe that's the way to do it; to fire each wav-file as a seperate script – or another process. Lacking experience with KiXtart – is it possible for someone to help me with a script for this? To substitute: $Button1.OnClick = "PLAY Bess12.wav "
with what – for starting a separate process or a seperate script – as in which I immediately can restart... and restart....
Anyhow, thank you for helping me!
Best regards Lasse Roald
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
1 registered
(Allen)
and 1607 anonymous users online.
|
|
|