Article View: borland.public.cppbuilder.multimedia
Article #661Re: Media Player with .wav files
From: Prof. Chuck Kelly
Date: Wed, 26 Mar 2003 23:44
Date: Wed, 26 Mar 2003 23:44
77 lines
3407 bytes
3407 bytes
"Steve McKewen" <stevemckewen@bigpond.com.au> wrote:
>I had an app written some time ago in V4 ro V5 that used a media player to
>play assorted wav files, but now I can't do it.
>
>I have a media player component , that I want to assign .wav files to the
>FileName property programmatically, and then play them using a call to
>MediaPlayer1->Play().
>
>Its not working but.
>If I assign the FileName at design time, then I can play that file, but once
>I reassign the FileName it doesn't work anymmore.
>
>
>I click btnBrowse and it preloads an OpenDialog with the current filename
>and on completion write the new filename back to a editbox (eAudioFile)
>
>//--------------------------------------------------------------------------
>-
>void __fastcall TAlarmOptions::btnBrowseClick(TObject *Sender)
>{
> //Use the open file dialog ODSounds
> //Load the filename with the current value
> ODSounds->FileName = eAudioFile->Text;
> //Show the dialog
> if (ODSounds->Execute())
> {
> //Save the filename selected to the alarm option
> eAudioFile->Text = ODSounds->FileName;
> }
>}
>
>When eAudioFile is changed it copies its text into the media player
>MPAudioFile FileName property.
>
>//--------------------------------------------------------------------------
>-
>void __fastcall TAlarmOptions::eAudioFileChange(TObject *Sender)
>{
> //Setup the media player
> MPAudioFile->FileName = eAudioFile->Text;
>}
>
>When you clik the play button it should play
>
>//--------------------------------------------------------------------------
>-
>void __fastcall TAlarmOptions::TestClick(TObject *Sender)
>{
> MPAudioFile->Notify = true;
> MPAudioFile->Wait = true;
> MPAudioFile->Play();
>}
>
>but it doesn't
>
>The Media Player is set up like this at design time.
>
>AutoOpen = true
>AutoEnable = true
>AutoRewind = true
>DeviceType = dtWaveAudio
>Enabled = true
>FileName = ""
>Shareable = true
>
>Any help would be greatly appreciated.
>
>
How about using PlaySound to play the sounds. Builder's help contains more info.
#include <vcl\mmsystem.hpp> // must have this for PlaySound() to work
if (FileExists(AnsiString(fileName))) {
PlaySound(fileName, NULL,
SND_ASYNC | SND_NOSTOP | SND_FILENAME);
Technical Details
Message-ID:
<3e823b59$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-04!sn-xit-01!sn-xit-08!supernews.com!216.166.71.14.MISMATCH!border3.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!ken-transit.news.telstra.net!news.telstra.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<3e6143b5@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10d0fc,d2d1de8fa03921dc X-Google-Attributes: gid10d0fc,public X-Google-ArrivalTime: 2003-03-26 15:51:06 PST From: "Prof. Chuck Kelly" <ckelly@monroeccc.edu> Sender: "Prof. Chuck Kelly" <ckelly@monroeccc.edu> Reply-To: "Prof. Chuck Kelly" <ckelly@monroeccc.edu> Subject: Re: Media Player with .wav files Newsgroups: borland.public.cppbuilder.multimedia X-User-Info: 198.108.21.3 198.108.21.3 References: <3e6143b5@newsgroups.borland.com> NNTP-Posting-Host: 207.105.83.65 Message-ID: <3e823b59$1@newsgroups.borland.com> Date: 26 Mar 2003 15:44:25 -0800 X-Trace: newsgroups.borland.com 1048722265 207.105.83.65 (26 Mar 2003 15:44:25 -0800) Lines: 79 Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-04!sn-xit-01!sn-xit-08!supernews.com!216.166.71.14.MISMATCH!border3.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!ken-transit.news.telstra.net!news.telstra.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail