The load method of wxMediaCtrl takes a file name argument.
I want to know if there is a way to somehow redirect this to memory.
I am storing my mp3 files in a database.
In order to play a clip, I would have to extract from the database and write to disk the individual clip, then call the wxMediaCtrl::Load method to load the file in order to play it.
Since I have to extract the file from the database - I will already have the contents in a memory buffer...I would rather load from the memory buffer because it would be faster if I could skip writing to disk only to have to read it again...
Is this possible?
Could someone please provide a brief code clip on how I would do this if it were possible?
Thanks in advance.
Jim
wxMediaCtrl Load - from memory instead of file
-
- Knows some wx things
- Posts: 30
- Joined: Sun May 04, 2008 6:41 pm
Re: wxMediaCtrl Load - from memory instead of file
There are wxMediaCtrl::Load( const wxURI& uri ) and wxMediaCtrl::LoadURI( const wxString& fileName ) and undocumented constructor and Create() that take wxURI argument.
These should work with something like "memory:myfile.mp3". See Virtual File System.
I've never used it and I can't give you a code snippet, but I did read about this being used so I can only advice you to try it.
These should work with something like "memory:myfile.mp3". See Virtual File System.
I've never used it and I can't give you a code snippet, but I did read about this being used so I can only advice you to try it.
Re: wxMediaCtrl Load - from memory instead of file
Good idea, catalin, but i don't think this will work. At least under Windows, the filename is directly passed to the underlying ActiveMovie/WMP control which doesn't know about wxWidgets filesystems.
I think this is not possible at all with wxMediaCtrl.
I think this is not possible at all with wxMediaCtrl.
Use the source, Luke!
Re: wxMediaCtrl Load - from memory instead of file
May be, I really don't know how wx-VFS works, but shouldn't something like wxFileSystem::AddHandler( new wxMemoryFSHandler ) register somehow a relevant uri handler? I did not check any code, just a quick, late night thought..doublemax wrote:i don't think this will work. At least under Windows, the filename is directly passed to the underlying ActiveMovie/WMP control which doesn't know about wxWidgets filesystems.
Re: wxMediaCtrl Load - from memory instead of file
Yes, but this works only inside wxWidgets and for classes that are written to support it.May be, I really don't know how wx-VFS works, but shouldn't something like wxFileSystem::AddHandler( new wxMemoryFSHandler ) register somehow a relevant uri handler?
But wxWidgets has no own audio/video codecs etc. wxMediaCtrl just embeds an ActiveX control under windows and Windows itself can't deal with paths like "memory:file.mp3" or something like this.
Use the source, Luke!
-
- Knows some wx things
- Posts: 30
- Joined: Sun May 04, 2008 6:41 pm
Re: wxMediaCtrl Load - from memory instead of file
Thanks for the replies. I suspected I could not do what I wanted to do. I also searched for a class that implemented simple functionality of loading and playing a mp3 audio clip from a buffer so I could bypass wxMediaCtrl - but couldn't find anything that was simple...I don't really understand the techs that go with audio programming (like sample rates, etc) and wanted to keep it simple...like here is the buffer already loaded with mp3 data now just play it.. Oh well! Thanks again!
Re: wxMediaCtrl Load - from memory instead of file
Depending on your platform and licence requirements, i'm sure there are several solutions.
If your application is non-commercial, check http://www.fmod.org
If your application is non-commercial, check http://www.fmod.org
Use the source, Luke!
Re: wxMediaCtrl Load - from memory instead of file
How about this? Unless I am way off here. It is not wxWidgets but it plays an MP3.
then to close it
Code: Select all
mciSendString(TEXT("open sounds\\dualtrax&nagz-neverland.mp3"),NULL,0,NULL);
mciSendString(TEXT("play sounds\\dualtrax&nagz-neverland.mp3"), NULL, 0, 0);
Code: Select all
mciSendString(TEXT("stop sounds\\dualtrax&nagz-neverland.mp3"), NULL, 0, 0);
mciSendString(TEXT("close sounds\\dualtrax&nagz-neverland.mp3"), NULL, 0, 0);