[RESOLVED] Play .wav from .res with Windows Media Player control...
...without extracting it and creating a new file to play from. Ideas on how to achieve this?
Re: Play .wav from .res with Windows Media Player control...
Use the Res: protocol for this. Example:
Code:
WindowsMediaPlayer1.URL = "res://" & App.EXEName & ".exe/WAVE/1"
See INFO: Syntax of the Res: Protocol and Some Known Related Issues.
Re: Play .wav from .res with Windows Media Player control...
That doesn't seem to work. I created the .rc file with theSound as my id, and then created the .RES file. I called it, as your example states to, replacing the "/1" with "/theSound", yet it does not work. It doesn't even provide an error. I tried several different sound ID's, but to no avail. I'm using Windows 7.
Re: Play .wav from .res with Windows Media Player control...
This works for me
Code:
MediaPlayer1.Stop
MediaPlayer1.FileName = "res://" & App.Path & "\" & App.EXEName & ".exe/CUSTOM/#101"
Re: Play .wav from .res with Windows Media Player control...
BTW: The example I posted is for the older style WMP.
If you can't get the URL to work for the newer WMP (as Bonnie posted) you probably will have to first convert the res data to a byte array and then save it to a file then set the URL to that file
Re: Play .wav from .res with Windows Media Player control...
Just FYI: The app has to be compiled to use the "res" protocol, correct? Not my area of expertise, but App.ExeName doesn't really exist until the app is compiled. Not sure whether OP is using on compiled copy or not.
Re: Play .wav from .res with Windows Media Player control...
You can run from IDE as long as there is a Compiled copy in the folder but that is not the problem. I have only been able to get it to work from a disk file.
Re: Play .wav from .res with Windows Media Player control...
LaVolpe: I tested your theory and it does not seem to matter whether it is compiled or not.
jms: I tried your code and it doesn't seem to work, either. Also, I'd really rather not convert it to a file and then save it to disk. Doing so would defeat the purpose of using the .res file.
Re: Play .wav from .res with Windows Media Player control...
My method works its just you need to use earlier version of WMP
Re: Play .wav from .res with Windows Media Player control...
True, but I would like it to work with a more "modern" version, as in what most users have now.
Re: Play .wav from .res with Windows Media Player control...
Maybe you can show us exactly the line you used to try to run it from the res file?
In the mean time, if you can find a way to play a file by a byte array, you can always use LoadResData() to return a byte array. And as a last resort, write the byte array to a file & pass the path/file name to WMP
Re: Play .wav from .res with Windows Media Player control...
Code:
WindowsMediaPlayer1.URL = "res://" & App.Path & "\" & App.EXEName & ".exe/CUSTOM/theSound"
WindowsMediaPlayer1.Controls.play
I've also used it without adding the "App.Path" part and used "WAVE" instead of "CUSTOM". No difference.
And if I'm going to write the information to a file (which I'm trying to stay away from), I mind as well just use the .wav files instead of combining them into a .res file.
1 Attachment(s)
Re: Play .wav from .res with Windows Media Player control...
The path in the "..../CUSTOM/theSound" part has to match the actual res name and number assigned to it. Are you doing that?
Do you have to use Windows Media Player? You can play from the res file using other means which I have apps that do that
MediaPlayer1.FileName = "res://" & App.Path & "\" & App.EXEName & ".exe/CUSTOM/#101"
Re: Play .wav from .res with Windows Media Player control...
Yes, it matches exactly. I would think it would cause a path/file error if not. And yes, I would really like to use WMP. If this is not possible, (which it is beginning to seem, as I can't find an answer anywhere) I will probably just go ahead and include the actual .wav files and just call it from WMP that way. I hate to do that, but oh well.
Re: Play .wav from .res with Windows Media Player control...
Okay. It worked. I used the
Code:
WindowsMediaPlayer1.URL = "res://" & App.EXEName & ".exe/WAVE/theSound"
as before, but this time it worked. And it DOES need to be compiled before it will work. I'm really not sure why it worked this time and not before. Very strange. Anyway, thank you all.
Re: [RESOLVED] Play .wav from .res with Windows Media Player control...
It won't cause a path/file error; it just won't play
Re: Play .wav from .res with Windows Media Player control...
Quote:
Originally Posted by
Conroy Vanderbluff
Okay. It worked. I used the
Code:
WindowsMediaPlayer1.URL = "res://" & App.EXEName & ".exe/WAVE/theSound"
as before, but this time it worked. And it DOES need to be compiled before it will work. I'm really not sure why it worked this time and not before. Very strange. Anyway, thank you all.
Good, happy it works for you but still I cannot get .URL to read res data to work for me and I am using newer version of WMP or my version is still not the latest. I'm using wmp.dll version 9.0.0.4503