﻿id	summary	reporter	owner	description	type	status	milestone	component	version	severity	resolution	keywords	cc
1707	_SoundPlay fails with Windows Media files in Vista/Win7	Melba23	Jpm	"A recent thread (http://www.autoitscript.com/forum/index.php?showtopic=116712) has shown that in Vista/Win7 there are '''no''' 8.3 shortnames for the media files in the ''Windows\Media'' folder.  As there is no shortname, ''FileGetShortName'' returns the full name - still containing the space (e.g. ''C:\Windows\Media\Windows Ding.wav'').  Becasue of this, ''_SoundPlay(""filename"")'' does not work for these files as the ""''play''"" string passed to the MCI DLL now contains a space and so the call fails.

Some example code (you may have to adjust the path for Win7):
{{{
#include <Sound.au3>

ConsoleWrite(FileGetShortName(""C:\Windows\Media\Windows Ding.wav"") & @CRLF)

_SoundPlay(""C:\Windows\Media\Windows Ding.wav"")
}}}

I do not see this as a huge problem:

1.  The built-in ''SoundPlay'' works without problem on these files.  The Windows media files are basically short and ''Sound.au3'' is designed to work with longer files.

2.  With a small change to ''Sound.au3'' the files can be played if they are opened first as the DLL '''will''' accept filenames with spaces in the ""''open...alias''"" call used in ''_SoundOpen''.  If these Windows media files can be correctly opened with ''_SoundOpen'', subsequent ''_SoundPlay'' commands work without problem using the ID array returned by ''_SOundOpen''.

Rewriting the ''_SoundPlay'' function to cope with these ""spaced-out"" file names would mean opening and closing each sound file for each call and as there are 2 valid solutions outlined above to play these files I do not believe it is worth the effort.  In the thread AdmiralAlkex has proposed a solution involving Adlib functions but do we really want a permanently running Adlib function just to play a short sound?

So in summary, to resolve this problem I would like to propose a small change to the ''Sound.au3'' UDF and an addition to the Help page for ''_SoundPlay'':

'''Sound.au3''':  In ''_SoundOpen'', change the line:
{{{

__SoundMciSendString(""open "" & FileGetShortName($sFile) & "" alias "" & $aSndID[0])

}}}
to read
{{{

__SoundMciSendString(""open """""" & $sFile & """""" alias "" & $aSndID[0])

}}}
This passes the full file name in quotes (they must be double quotes for the call to work) and enables any sound file (with spaces or not) to be successfully opened for subsequent use with the other ''_Sound*'' functions using the returned ID array.

'''_SoundPlay help page''':  Add a remark:

In Vista and above, ""\Windows\Media\..."" files containing spaces must be opened with _SoundOpen before using this command with the returned Sound ID array.

As always happy to discuss or explain further here or via PM.

M23"	Bug	closed	3.3.7.0	Standard UDFs	3.3.6.0	None	Fixed		
