Jump to content

SoundPlay() over network


Recommended Posts

Hi All,

The code:

SoundPlay("C:Windowsmediatada.wav")

will correctly play the sound when running the script locally (Win7 32 bit, computer name="computer1").  However when I then transfer the script to a second computer (identical OS, computer name="computer2"), and run the script over the network from "computer1," the sound does not play.  The sound file is located in the exact same directory on each computer.  @computername resolves to "computer1" when I run the script from "computer1."  I am also sitting in front of each computer with the sound fully operational on both, so if AutoIt is trying to play the sound on "computer2," I should be able to hear it.  Am I doing something wrong, or is there some issue with playing a sound over a network?  In this case do I have to specify a full path name, including computer name?

Link to comment
Share on other sites

How are you connecting to the other computer? Also, is that the entire script?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I'm connecting via a basic homegroup connection.  Edit:  using "computer1" I established a basic Windows homegroup, and "computer2" joined.  To run the script from "computer1," I open the homegroup on "computer1," connect to "computer2," and open the script located on "computer2."

And yes, that is the entire script.

Edited by cag8f
Link to comment
Share on other sites

You should try:

Soundplay("\\COMPUTERNAME\c$\Windows\Media\tada.wav")

Where "COMPUTERNAME" is the name of the computer you want to play the file from.

Also make sure that Administrative shares are enabled on both computers.

"Just be fred, all we gotta do, just be fred."  -Vocaliod

"That is a Hadouken. A KAMEHAMEHA would have taken him 13 days and 54 episodes to form." - Roden Hoxha

@tabhooked

Clock made of cursors ♣ Desktop Widgets ♣ Water Simulation

Link to comment
Share on other sites

You should try:

Soundplay("\\COMPUTERNAME\c$\Windows\Media\tada.wav")

Where "COMPUTERNAME" is the name of the computer you want to play the file from.

Also make sure that Administrative shares are enabled on both computers.

Thanks.  That all sounds reasonable.  I'll give that shot and let you know.

Link to comment
Share on other sites

 

You should try:

Soundplay("\\COMPUTERNAME\c$\Windows\Media\tada.wav")
Where "COMPUTERNAME" is the name of the computer you want to play the file from.

Also make sure that Administrative shares are enabled on both computers.

This won't work, it will play the sound file from the remote computer, but it will play it on the computer you're running the script on. If you're going to do that, you might as well play the same file from the local computer.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

 

I'm connecting via a basic homegroup connection.  Edit:  using "computer1" I established a basic Windows homegroup, and "computer2" joined.  To run the script from "computer1," I open the homegroup on "computer1," connect to "computer2," and open the script located on "computer2."

 

And yes, that is the entire script.

Are you just connecting to the C: drive of computer2? I've never used homegroups before so I don't know what you're attempting, but the homegroup seems to be just another name for a network workgroup from what I'm reading.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

 

This won't work, it will play the sound file from the remote computer, but it will play it on the computer you're running the script on. If you're going to do that, you might as well play the same file from the local computer.

I'd be happy to play the same file from the local computer.  That's preferred actually, and that's what I thought I was attempting.

Link to comment
Share on other sites

Homegroups are just a fancy version of folder/printer sharing. You're only "connected" to the other computer's shared folders, you're running the script on the local computer and not the remote computer, if you want to run something on the remote computer you have to connect to it or run it using something like PSExec.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

First make sure that the path to the file is correct, currently you have C:Windows, you should have C:Windows in there.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I want to play the local sound file on the local computer, but with a remotely housed script.  Is that possible?  If so, how?

You could try using a Client/Server, heres an example:

Server:

UDPstartup()
$INsocket = UDPBind("192.168.2.15", 1775)
If @error <> 0 Then Exit
$OUTsocket = UDPOpen("192.168.2.10", 1774)
If @error <> 0 Then Exit

While 1
    $data = UDPRecv($INsocket, 10000) ;Receive data
    If $data <> "" Then
        ToolTip($data, 0, 0) ;Display the sound
        $ret = SoundPlay($data) ;Play the sound
        Sleep(500) ;Wait for the client, also gives the tooltip time to display
        UDPSend($OUTsocket, $ret) ;Send the return value of SoundPlay()
        ToolTip("")
    EndIf
WEnd

Client:

UDPStartup()
$INsocket = UDPBind("192.168.2.10", 1774)
If @error <> 0 Then Exit
$OUTsocket = UDPOpen("192.168.2.15", 1775)
If @error <> 0 Then Exit

$Sound = InputBox("Sound Play", "Enter the location of the file to play", "C:\Windows\Media\tada.wav") ;Prompt the user for filename/path

UDPSend($OUTsocket, $Sound) ;Send the data
$timer = TimerInit() ;Timer to tell if the request times out

While TimerDiff($timer) < 5000 ;Loop on the fact that the timer is less than 5000 ms
    $data = UDPRecv($INsocket, 1000) ;Receive data
    If $data <> "" Then
        MsgBox(64, "Return Value", $data) ;Display the result
        UDPShutdown()   
        Exit ;exit the script
    EndIF
WEnd

MsgBox(16, "Error", "Request timed out.")

UDPShutdown()















I havn't tested it yet but, theroretically, it should work.

EDIT: Missing UDPstartup() and UDPShutdown()'s added

Edited by DatMCEyeBall

"Just be fred, all we gotta do, just be fred."  -Vocaliod

"That is a Hadouken. A KAMEHAMEHA would have taken him 13 days and 54 episodes to form." - Roden Hoxha

@tabhooked

Clock made of cursors ♣ Desktop Widgets ♣ Water Simulation

Link to comment
Share on other sites

First make sure that the path to the file is correct, currently you have C:Windows, you should have C:Windows in there.

Sorry, typo on my part.  The path beginning with C:Windows is what I meant to type.

Link to comment
Share on other sites

Instead of SoundPlay() use _WinAPI_PlaySound() function made by Yashied. Example can be found here: >Play a wave file from memory

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Try this, and let us know the results.

SoundPlay("C:\windows\media\tada.wav", 1)

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Try this, and let us know the results.

 

SoundPlay("C:\windows\media\tada.wav", 1)

That's the code that prompted me to post this thread.  When I run that code using a script housed locally, the sound plays as expected.  However when I run that code using a script housed remotely, that code results in no sound played.  I am trying to get the latter to play the intended sound.

Link to comment
Share on other sites

Did you notice the second parameter in the soundplay function I used? It might make a difference.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...