You need to use the correct routine.
Place the following routines in the "Procedures" tab:
- Code: Select all
Sub PlaySoundWin7(SoundFile, NumRepeat, ChannelNumber)
If ChannelNumber < 9 Then
'With VBScript it is currently not possible to interact with the 8 first audio channels.
MsgBox "The specified audio channel is invalid.", vbCritical, "Error"
Exit Sub
End If
If Action.IsComponentInstalled("NSPlay.NSPlayCtl.1") = False Then
MsgBox "Unable to find the media player component.", vbCritical, "Error"
Else
If Action.DoesComponentExist("MediaPlayer" + CStr(ChannelNumber)) = false Then
AddComponent "NSPlay.NSPlayCtl.1", "MediaPlayer" + CStr(ChannelNumber)
End If
Component("MediaPlayer" + CStr(ChannelNumber)).Object.FileName = SoundFile
Component("MediaPlayer" + CStr(ChannelNumber)).Object.PlayCount = NumRepeat
Component("MediaPlayer" + CStr(ChannelNumber)).Object.Play
End If
End Sub
Sub StopSoundWin7(ChannelNumber)
Component("MediaPlayer" + CStr(ChannelNumber)).Object.Stop
End Sub
Usage:
To Play Channel 10:
1st parameter is the file (this one is in the "external" folder of your project
2nd parameter is number of times to repeat (0 = forever)
3rd parameter is the channel number
PlaySoundWin7 GetPath(2) + "rome_total_war_ending.mp3", 0, 10To Stop only Sound Channel 10:
parameter is the channel number to stop
StopSoundWin7 10