Solved

play wave in database

Posted on 1998-07-23
9
256 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
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…

930 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