Solved

Play Mp3

Posted on 2002-03-14
17
326 Views
Last Modified: 2010-04-05
how can i make my programme play .wav and .mp3s ? Points easily negotiable.
0
Comment
Question by:tyfing
  • 5
  • 3
  • 2
  • +6
17 Comments
 
LVL 1

Expert Comment

by:amebikes
ID: 6864843
Hello,
try this:
- in your uses clause add mmsystem
- execute this line:
 PlaySound(Pchar('filename.wav'), 0,  SND_FILENAME + SND_ASYNC);

it works with .wav files, maybe also with .mp3 ??
0
 
LVL 1

Expert Comment

by:amebikes
ID: 6864992
Hello,
try this:
- in your uses clause add mmsystem
- execute this line:
 PlaySound(Pchar('filename.wav'), 0,  SND_FILENAME + SND_ASYNC);

it works with .wav files, maybe also with .mp3 ??
0
 
LVL 7

Expert Comment

by:Motaz
ID: 6865005
Drop MediaPlayer component:

MediaPlayer1.FileName:= 'Your filename.wav or .mp3';
MediaPlayer1.Open;
MediaPlayer1.Play;

In case of opening MP3 I think that you whould have the libraries that run MP3, this libraries will be installed in Windows if you install MP3 player such as Windows media player.

Motaz
0
 
LVL 5

Expert Comment

by:alanwhincup
ID: 6865033
To play a .WAV just do as amebikes said.
To play an .MP3 have a look at the following sites:

http://www.undu.com/Articles/991125a.html
http://www.xaudio.com/

Cheers,

Alan
0
 
LVL 3

Expert Comment

by:tongalite
ID: 6865368
Hi...
To play an mp3 do this....

New project:
drop a TMediaplayer, a button and an OpenDialog comp.

add this code in the button Begin / End block

//USES MMSystem//
----------------------------------------
  OpenDialog1.DefaultExt := 'mp3';
  OpenDialog1.Filename := '*.mp3';
  if OpenDialog1.Execute then
  begin
    MediaPlayer1.Filename := OpenDialog1.Filename;
    MediaPlayer1.Open;
    Mediaplayer1.play;
  end;
  end;
-----------------------------------------
when you click the button, the OpenDialog box opens,
navigate to an mp3 file on your system and click OK,
play it!
easy as that. Have fun!
tongalite

your entire Unit should look like this:

------------------------------------------
unit Unit1;

interface

uses
  Windows, Messages,MMSystem, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, MPlayer;

type
  TForm1 = class(TForm)
    MediaPlayer1: TMediaPlayer;
    Button1: TButton;
    OpenDialog1: TOpenDialog;
    procedure Button1Click(Sender: TObject);

  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);

begin
  OpenDialog1.DefaultExt := 'mp3';
  OpenDialog1.Filename := '*.mp3';
  if OpenDialog1.Execute then
  begin
    MediaPlayer1.Filename := OpenDialog1.Filename;
    MediaPlayer1.Open;
    Mediaplayer1.play;
  end;
  end;


end.
------------------------------------------------
0
 
LVL 3

Expert Comment

by:Mathias
ID: 6870473
I can give you a working Example for playing mp3's and wav's without TMediaPlayer and with full source code. It's a small example of using nothing from within windows like codecs or system dll's. You are independent :-)

Give me your email address an I will send it to you (hope you will give me the points *g).

Bye, TDS.
0
 

Expert Comment

by:DelFreak
ID: 6871348
TDS, sounds interesting. Can you please send it to me too. Thanks! delfreak@thedoghousemail.com
0
 
LVL 3

Expert Comment

by:tongalite
ID: 6871695
Hi,
I too am interested in this....
Could you please mail me a copy?
tongalite@ic24.net
TIA
T.
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Expert Comment

by:classic_gaming
ID: 6872221
hi i'm also intrested in playing mp3's without tmediaplayer

email me r.nash@ntlworld.com

cheers
classic_gaming
0
 
LVL 3

Expert Comment

by:Mathias
ID: 6872445
Okay, I will send you a link where you can download the code from my homepage. I will pack it till tommorow because I'm tired now :-)

Bye, TDS.
0
 
LVL 3

Expert Comment

by:Mathias
ID: 6873831
Here is the link. The source code for the DLL is written in C/C++ but can easy change the code (I hope)

http://www.tds-net.de/experts/mp3.zip

All files should be included, if not mail me:
webmaster@tds-net.de

If you grade this question, please give me a "A" :-)

Bye, TDS.
0
 

Author Comment

by:tyfing
ID: 6873905
i'm very confused about .dlls, how do i use them ?
0
 
LVL 3

Expert Comment

by:tongalite
ID: 6874090
Hi tyfing
You are getting some mileage out of this question... I like your style ;-)
t.
0
 
LVL 3

Expert Comment

by:Mathias
ID: 6874665
Hmm, you don't have to think about dll's. The only thing is that you have to register all needed component and that the mpegdll.dll is in the directory you'll start your program.

Bye, TDS.
0
 
LVL 3

Accepted Solution

by:
Mathias earned 50 total points
ID: 6886759
I think my program works fine and you get the full source. Please give me the points for a working example.

Bye, TDS.
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6975963
You have 12 open questions, some of which date back to the year 2000.  ADMINISTRATION WILL BE CONTACTING YOU SHORTLY.  Moderators Computer101 or Netminder will return to finalize these if they are still open in 14 days.  Experts, please post closing recommendations before that time.

Below are your open questions as of today.  Questions which have been inactive for 21 days or longer are considered to be abandoned and for those, your options are:
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you, but may help others. You must tell the participants why you wish to do this, and allow for Expert response.  This choice will include a refund to you, and will move this question to our PAQ (Previously Asked Question) database.  If you found information outside this question thread, please add it.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question (if it has no potential value for others).
   --> Post comments for expert of your intention to delete and why
   --> YOU CANNOT DELETE A QUESTION with comments; special handling by a Moderator is required.

For special handling needs, please post a zero point question in the link below and include the URL (question QID/link) that it regards with details.
http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
 
Please click this link for Help Desk, Guidelines/Member Agreement and the Question/Answer process.  http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp

Click you Member Profile to view your question history and please keep them updated. If you are a KnowledgePro user, use the Power Search option to find them.  

Questions which are LOCKED with a Proposed Answer but do not help you, should be rejected with comments added.  When you grade the question less than an A, please comment as to why.  This helps all involved, as well as others who may access this item in the future.  PLEASE DO NOT AWARD POINTS TO ME.

To view your open questions, please click the following link(s) and keep them all current with updates.
http://www.experts-exchange.com/questions/Q.11700099.html
http://www.experts-exchange.com/questions/Q.11762279.html
http://www.experts-exchange.com/questions/Q.11872738.html
http://www.experts-exchange.com/questions/Q.20080036.html
http://www.experts-exchange.com/questions/Q.20106355.html
http://www.experts-exchange.com/questions/Q.20108005.html
http://www.experts-exchange.com/questions/Q.11610182.html
http://www.experts-exchange.com/questions/Q.20239389.html
http://www.experts-exchange.com/questions/Q.20244108.html

To view your locked questions, please click the following link(s) and evaluate the proposed answer.
http://www.experts-exchange.com/questions/Q.20108209.html
http://www.experts-exchange.com/questions/Q.20267321.html
http://www.experts-exchange.com/questions/Q.20276914.html

*****  E X P E R T S    P L E A S E  ******  Leave your closing recommendations.
If you are interested in the cleanup effort, please click this link
http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=commspt&qid=20274643
POINTS FOR EXPERTS awaiting comments are listed in the link below
http://www.experts-exchange.com/commspt/Q.20277028.html
 
Moderators will finalize this question if in @14 days Asker has not responded.  This will be moved to the PAQ (Previously Asked Questions) at zero points, deleted or awarded.
 
Thanks everyone.
Moondancer
Moderator @ Experts Exchange
0
 

Author Comment

by:tyfing
ID: 6977122
ok
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

746 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

13 Experts available now in Live!

Get 1:1 Help Now