Modify

Opened 10 years ago

Closed 10 years ago

#1707 closed Bug (Fixed)

_SoundPlay fails with Windows Media files in Vista/Win7

Reported by: Melba23 Owned by: Jpm
Milestone: 3.3.7.0 Component: Standard UDFs
Version: 3.3.6.0 Severity: None
Keywords: Cc:

Description

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.
  1. 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

Attachments (0)

Change History (4)

comment:1 Changed 10 years ago by AdmiralAlkex

I wouldn't call it a permanent Adlib, as it is enabled only when necessary and disables itself when all sounds is _SoundClosed'ed.

I would be willing to improve the proof-of-concept to UDF standards if anyone is interested in seeing this.

Only real question is what size the Array should be (or make it grow/shrink dynamically, I have no problems with either) and what would be a fitting time for the Adlib.
Rebuilding it with a dynamic Array would make the Adlib-time mostly irrelevant (could be seconds or hours) so dynamic is probably the wisest.
I also have some ideas to reduce the impact on the rest of the script (in the proof-of-concept the whole array is walked through, so it could be running up to 100 SoundClose() every second, which shouldn't really be necessary at all).

comment:2 Changed 10 years ago by Melba23

AdmiralAlkex,

My apologies if I misrepresented your proposed solution.

Let us see what the Devs decide - I would be more than happy if we could work together on refining the UDF if they go for your solution.

comment:3 Changed 10 years ago by Jpm

I will just add a the slight modification for the FileGetShortName() removal.
It will not solve all issue when acessing .wav with space in it. At least under Win7/FR it is not solve as the file is not really accessible with FileExists() Certainly related on how Windows map Theme files.
For the Adlib please open a "Feature request" ticket.
Thanks

comment:4 Changed 10 years ago by Jpm

  • Milestone set to 3.3.7.0
  • Owner changed from Gary to Jpm
  • Resolution set to Fixed
  • Status changed from new to closed

Fixed by revision [5907] in version: 3.3.7.0

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The owner will remain Jpm.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.