Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 1st, 2007, 4:43 AM   #1
Tajinder Singh
Newbie
 
Join Date: Jul 2007
Posts: 16
Rep Power: 0 Tajinder Singh is on a distinguished road
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...
Tajinder Singh is offline   Reply With Quote
Old Aug 1st, 2007, 7:11 AM   #2
Seif
Hobbyist Programmer
 
Seif's Avatar
 
Join Date: Jan 2006
Location: UK
Posts: 215
Rep Power: 3 Seif is on a distinguished road
What libraries are you currently using for your application ?
Seif is offline   Reply With Quote
Old Aug 2nd, 2007, 7:49 AM   #3
Tajinder Singh
Newbie
 
Join Date: Jul 2007
Posts: 16
Rep Power: 0 Tajinder Singh is on a distinguished road
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 ??
Tajinder Singh is offline   Reply With Quote
Old Aug 2nd, 2007, 8:46 AM   #4
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Have a look:
Quote:
Originally Posted by Rules - Code Tags
Code Tags
When posting code please put all code between the tags. This makes reading source code alot easier for everyone trying to read the code. If you haven't used code tags in a post, moderators may add them in for you, but it would make our job a lot easier were you to use them yourself. There are addition ways to put your code in tags that makes it easy this will add syntax highlighting which makes things easier on the people trying to help you.
__________________
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
DaWei is offline   Reply With Quote
Old Aug 3rd, 2007, 1:36 AM   #5
Tajinder Singh
Newbie
 
Join Date: Jul 2007
Posts: 16
Rep Power: 0 Tajinder Singh is on a distinguished road
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);
}
One may select a sound (.wav file)which may be corrupted.
Its better to check the file in advance and then Load it or Call PlaySound().

Can we have check on corrupted wav file ??
Tajinder Singh is offline   Reply With Quote
Old Aug 3rd, 2007, 1:37 AM   #6
Tajinder Singh
Newbie
 
Join Date: Jul 2007
Posts: 16
Rep Power: 0 Tajinder Singh is on a distinguished road
Thansk Dawei for your suggestion....
Tajinder Singh is offline   Reply With Quote
Old Aug 14th, 2007, 9:26 AM   #7
Tajinder Singh
Newbie
 
Join Date: Jul 2007
Posts: 16
Rep Power: 0 Tajinder Singh is on a distinguished road
Updated now
Tajinder Singh is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:26 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC