Page 1 of 1

Help! How to set a channel for sound with the new win7 code

PostPosted: Tue Dec 21, 2010 11:32 pm
by reneuend
Now that GM gave us the code shown below, I haven't been able to figure out how to select a specific channel. This is necessary for some of my games because I need specific control when the sound is played and with other sounds. If anyone knows or can figure out how to specify a channel, please let the rest of us who need it know! Pleeeeeassse!

Code: Select all
sub PlaySoundWin7(SoundFile, NumRepeat)

  If Action.IsComponentInstalled("NSPlay.NSPlayCtl.1") = False Then
    MsgBox "Unable to find the media player component.", vbCritical, "Error"
  Else
    If Action.DoesComponentExist("MediaPlayer1") = false Then
      AddComponent "NSPlay.NSPlayCtl.1", "MediaPlayer1"
    End If
    Component("MediaPlayer1").Object.FileName = SoundFile '(replace with your file)
    Component("MediaPlayer1").Object.PlayCount = NumRepeat
    Component("MediaPlayer1").Object.Play
  End If

End Sub




Code: Select all
sub StopSoundWin7()

  Component("MediaPlayer1").Object.Stop

End Sub

PostPosted: Sat Dec 25, 2010 12:54 am
by GM-Support
Hello reneuend,

I have just posted the VBScript code on the following thread:
http://www.adventuremaker.com/phpBB2/viewtopic.php?p=32145#32145

Best regards,
GM-Support

PostPosted: Sat Dec 25, 2010 5:17 pm
by reneuend
Thanks GM. This solves a lot of issues in my games. Very much appreciated!

(edit) I didn't realize until I got home and looked at this code closer that you are overloading VB subroutines? Is this possible? I tried it out but got an error.

PostPosted: Mon Dec 27, 2010 5:49 pm
by GM-Support
reneuend wrote:(edit) I didn't realize until I got home and looked at this code closer that you are overloading VB subroutines? Is this possible? I tried it out but got an error.


You are right, my mistake. I just updated the code to remove the overloading.

Thanks,
GM-Support