play wave in database

Posted on 1998-07-23
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 100 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.
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.


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

Technology Partners: 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!

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month10 days, 11 hours left to enroll

632 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