Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


play wave in database

Posted on 1998-07-23
Medium Priority
Last Modified: 2010-05-03
i'm trying to play wave that are in a database in a ole record type.can i do that and how
Question by:marc39
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4

Expert Comment

ID: 1466558
you mean you will read the wav filename from the database
andthen play it ? am I right ?

Author Comment

ID: 1466559
yeah, i want to read the wav file from the database and then
play it, but i dont know how

Accepted Solution

kamall earned 300 total points
ID: 1466560
A much better way is to only store the file name of the WAV file in the database and then play it as you play any other WAV file from disk.
This example will play a WAV file without using any controls:


         SoundName$ = "c:\windows\mywave.wav"   'Get this file name from the database
         wFlags% = SND_ASYNC Or SND_NODEFAULT
         x% = sndPlaySound(SoundName$,wFlags%)

The wFlags are as follows:

         Const SND_SYNC = &H0
         Const SND_ASYNC = &H1
         Const SND_NODEFAULT = &H2
         Const SND_LOOP = &H8
         Const SND_NOSTOP = &H10

Hope that helps.
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 1466561
i need to read the file from the database because my app will be share by many people that wont have access to my disk (only to the database)
p.s hope you've understand  (i am not very good in english)


Expert Comment

ID: 1466562
I understand that other people will not have access to your disk.
However, I asume that you are distributing your database with a setup diskettes volume or CD-ROM with your application files, right?. Hence, you can include your WAV files with the application files, and they will be put in the installation directory of your application on the user's machine. You can then easily play the WAV files using the code I gave you above.
To be able to get the name of the directory where your application is installed on the user's system, use  MyDir = App.Path  in your code (MyDir will give you the name of the directory).

Hope that helps.

Author Comment

ID: 1466563
....not exactly,in fact my programm is a kind of "chat" that i want to use at school.
this is how it would work.
the database would be on a disk that everybody have access but the apps would be on a disk that only the user can access.
when the programm open, it connect to the database.
When someone whant to send a message to others,the text is store on the database at the end of the table.then  others people  programms  read the last row of the database and display it.

(it worked i tried it) i want to do the same with sound without having to copy each file on the "sharing disk" each time i want to send one.
i hope again you understand. (like i says i'm not good in english)
i'm french if it can help i can send you the project i'm working on

Expert Comment

ID: 1466564
In that case, you have to use the OLE control.
Put one OLE control on your form, set its Class property to 'mplayer', and set its DataSource and DataField properties at run-time when you initialize your data control and connect to the database.

Now, to play the sound data stored in the database, execute the command:

OLE1.Action = 7    ' 7 means 'activate'

And when you want to stop the sound, execute

OLE1.Action = 9

Hope that helps.

Author Comment

ID: 1466565
is there any way to read the fille without using the ole serveur
like using an api call?
this would help cause the sound recorder would 'nt have to load
and hide the program

Expert Comment

ID: 1466566
As far as I know, there is no simple way to read the data as a 'file' because the data are stored in the OLE format.
Regarding what you mentioned about the loading of the sound recorder,
We are using the 'mplayer' class (Media Player) not the sound recorder. When you play a sound using the OLE control, the Media Player will not be shown but only the necessary driver(s) will be loaded to play the sound.


Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question