Solved

play wave in database

Posted on 1998-07-23
9
258 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

777 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