Solved

play wave in database

Posted on 1998-07-23
9
254 Views
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
tanks
0
Comment
Question by:marc39
  • 4
  • 4
9 Comments
 
LVL 2

Expert Comment

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

Author Comment

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

Accepted Solution

by:
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:

Example:

         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.
Regards
0
 

Author Comment

by:marc39
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)

0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 7

Expert Comment

by:kamall
ID: 1466562
Well...
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.
0
 

Author Comment

by:marc39
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
p.ps if it can help i can send you the project i'm working on
tanks
0
 
LVL 7

Expert Comment

by:kamall
ID: 1466564
Well,
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.
0
 

Author Comment

by:marc39
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
0
 
LVL 7

Expert Comment

by:kamall
ID: 1466566
marc39,
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.

Regards
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library 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.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now