![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Jul 2007
Posts: 16
Rep Power: 0
![]() |
Which control i should use to play sound??
Hi all...
My question is much like previous one but with little difference.. This time i am developing an application which browses file having .wav or .avi extention.... Pls also tell me in which control i can play selected sound... Regards... |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
Join Date: Jan 2006
Location: UK
Posts: 215
Rep Power: 3
![]() |
What libraries are you currently using for your application ?
|
|
|
|
|
|
#3 |
|
Newbie
Join Date: Jul 2007
Posts: 16
Rep Power: 0
![]() |
Hi .. Following is code behind three buttons like Load, Play n Stop:-
void Sound::LoadSound() { char path[255]; GetCurrentDirectory(255, path); CFileDialog dialog(TRUE,NULL,NULL,OFN_OVERWRITEPROMPT,"WAV Files (*.wav)|*.wav||"); INT_PTR ptr= dialog.DoModal(); SetCurrentDirectory(path); if (ptr==IDOK) { UpdateData(); CString str=dialog.GetPathName(); m_snd_ext = dialog.GetFileExt(); m_snd_filename=str; PlaySnd(); UpdateData(FALSE); } } void Sound: laySnd(){ m_valid_snd = PlaySound(m_snd_filename,NULL,SND_ASYNC|SND_FILENAME|SND_LOOP); if(m_valid_snd) { this->GetDlgItem(IDC_SND_PLAY)->EnableWindow(FALSE); this->GetDlgItem(IDC_SND_STOP)->EnableWindow(TRUE); } } void Sound: topSound(){ PlaySound(NULL,NULL,SND_PURGE); this->GetDlgItem(IDC_SND_STOP)->EnableWindow(FALSE); this->GetDlgItem(IDC_SND_PLAY)->EnableWindow(TRUE); } One may select a sound (.wav file)which may be corrupted. Its better to check the file in advance then Call PlaySound(). Can we have check on corrupted wav file ?? |
|
|
|
|
|
#4 | |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Have a look:
Quote:
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
|
#5 |
|
Newbie
Join Date: Jul 2007
Posts: 16
Rep Power: 0
![]() |
Following is code behind three buttons like Load, Play n Stop:-
code behind LoadSound Button... void Sound::LoadSound()
{
char path[255];
GetCurrentDirectory(255, path);
CFileDialog dialog(TRUE,NULL,NULL,OFN_OVERWRITEPROMPT,"WAV Files (*.wav)|*.wav||");
INT_PTR ptr= dialog.DoModal();
SetCurrentDirectory(path);
if (ptr==IDOK)
{
UpdateData();
CString str=dialog.GetPathName();
m_snd_ext = dialog.GetFileExt();
m_snd_filename=str;
PlaySnd();
UpdateData(FALSE);
}
}code behind PlaySnd Button... void Sound::PlaySnd()
{
m_valid_snd = PlaySound(m_snd_filename,NULL,SND_ASYNC|SND_FILENAME|SND_LOOP);
if(m_valid_snd)
{
this->GetDlgItem(IDC_SND_PLAY)->EnableWindow(FALSE);
this->GetDlgItem(IDC_SND_STOP)->EnableWindow(TRUE);
}
}Code behind StopSound button... void Sound::StopSound()
{
PlaySound(NULL,NULL,SND_PURGE);
this->GetDlgItem(IDC_SND_STOP)->EnableWindow(FALSE);
this->GetDlgItem(IDC_SND_PLAY)->EnableWindow(TRUE);
}Its better to check the file in advance and then Load it or Call PlaySound(). Can we have check on corrupted wav file ?? |
|
|
|
|
|
#6 |
|
Newbie
Join Date: Jul 2007
Posts: 16
Rep Power: 0
![]() |
Thansk Dawei for your suggestion....
|
|
|
|
|
|
#7 |
|
Newbie
Join Date: Jul 2007
Posts: 16
Rep Power: 0
![]() |
Updated now
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Vista Sound Driver Issues (Creative Cards) | Ghost | Coder's Corner Lounge | 3 | May 31st, 2007 2:36 PM |
| Streaming Sound Over a Socket | King | C++ | 3 | Apr 7th, 2007 5:29 PM |
| How to add inherited control to toolbox. | InfoGeek | C# | 3 | Feb 8th, 2007 9:12 PM |
| Play sound in TurboC++ | sayu | C++ | 4 | Nov 16th, 2006 8:42 AM |
| C programing control of the Serial Port. | Light | C++ | 5 | Feb 24th, 2005 2:14 PM |