Page 1 of 1 1
Topic Options
#123230 - 2004-07-19 05:11 PM Play Command – how to stop or restart the wav-file
LarsRoan Offline
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. Offline
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
#123232 - 2004-07-19 09:07 PM Re: Play Command – how to stop or restart the wav-file
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I would go with kix but fire it as another process.
then that could be closed from the mother script.
_________________________
!

download KiXnet

Top
#123233 - 2004-07-20 03:12 AM Re: Play Command – how to stop or restart the wav-file
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
A better approach would be to play the sound files through a COM-enabled media player, which could then be controlled via KiXtart/KiXforms.
_________________________
There are two types of vessels, submarines and targets.

Top
#123234 - 2004-07-21 04:14 PM Re: Play Command – how to stop or restart the wav-file
LarsRoan Offline
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
#123235 - 2004-07-23 10:31 AM Re: Play Command – how to stop or restart the wav-file
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
have a script that only has:
Code:
break on
play $arg1



in it.
then in your main script:
Code:
 
$playbutton.onclick="run '"+@scriptdir+"\wkix_player.exe "+@scriptdir+"\myplayerScript.kix $arg1=the_wav_file.wav'"
$stopbutton.onclick="run 'kill wkix_player.exe -f"



well, this is the shortest way.
wkix_player is just wkix32 renamed to be able to kill it without killing your main script
_________________________
!

download KiXnet

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1636 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.056 seconds in which 0.027 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org