Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Make Media Player in Delphi
11-29-2009, 06:37 AM
Post: #1
Make Media Player in Delphi
I am going to explain how to make a Media Player in Delphi in a few easy steps. Don't expect too much, because really good players need lots of coding. This is the simple one with only a few functions.
First of all, open Delphi (i will be using Delphi 7) and drag Media Player form System Palette on to form. Also drag XPManifest from Win32 Palette.
If you don't want to use Delphi manifest you can generate manifest file with this program :
http://www.pro9ramming.com/xp-manifest-t-145.html
So now you should have something like this on your form :

[Image: 21654_mediaplayer1.jpg]

Now let's make an sizeable form. Drag & drop one Panel from standard Delphi palette. Go to Object Inspector of Delphi and set Align of that Panel "alBottom".
Now go to Object Tree view which is by default over Object Inspector and drag Media Player on that Panel, so Media Player will be inside Panel1.
Now drag & drop second Panel (Panel2) and set it's Align to "alClient".
Now you should have something like this :

[Image: 21655_mediaplayer2.jpg]

If you compile this you will see that Panels will move with form.
Now first Panel is for commands and second is for screen or display.
Now you can go to Object Inspector of Media Player and set Display to Panel2. That should look like this :

[Image: 21656_mediaplayer3.jpg]

And you need to write the code for Auto Open of Media Player on Creation of the program, like this :
Code:
procedure TForm1.FormCreate(Sender: TObject);
begin
  MediaPlayer1.AutoOpen:=true;
end;
Now drag & drop 2 buttons on Panel 1 under the Media Player. First one call "Open File" and second one "Close" for closing the program.
Make the form look like this :

[Image: 21657_mediaplayer4.jpg]

Now we need to make Dialog for opening the file.
Go to Standard palette and drag & drop ActionList on form and go to new standard action, lie on the picture :

[Image: 21658_mediaplayer5.jpg]

And choose TFileOpen, like on this picture :

[Image: 21659_mediaplayer6.jpg]

Okay after doing that we have made a "FileOpen1".
Now we need to run that dialog, so go to Button with Label "Open File" that we made and write this code inside :
Code:
procedure TForm1.Button1Click(Sender: TObject);
begin
  FileOpen1.Execute;
end;

Now we need to set File Name of Media Player as it is in Dialog.
So go to Object Inspector of FileOpen1 and go to Events and find "OnAccept" and paste this code inside :
Code:
procedure TForm1.FileOpen1Accept(Sender: TObject);
begin
   MediaPlayer1.FileName:=fileopen1.Dialog.FileName;
   MediaPlayer1.Open;
end;
Now find the second button and paste this code inside of that button :
Code:
procedure TForm1.Button2Click(Sender: TObject);
begin
  Application.Terminate;
end;
That is the button with Label "Close" and it should close program (terminate application).
Also you can change Label of Form1 to "Media Player" if you want.
Now you can compile your program and that should look like this :

[Image: 21660_mediaplayer7.jpg]

That is everything. You can add certain functions more, but this is okay too.
I'll add some more explanations to this tut surely and extend possibilities of this Player.
This is tutorial for people who know something about Delphi & programming in general. You have source attached in rar file.
Hope that you like it !


Attached File(s)
.rar  mediaplayer.rar (Size: 172.4 KB / Downloads: 27)

There's a fine line between genius and insanity. I have erased this line.
Oscar Levant
There's a fine line between an administrator and black hat hacker. I have erased this line.
Dr DEBCOL
Visit this user's website Find all posts by this user
Quote this message in a reply
11-29-2009, 08:31 AM
Post: #2
RE: Make Media Player in Delphi
No error checking? Tongue nice tutorial.
Visit this user's website Find all posts by this user
Quote this message in a reply
11-29-2009, 07:54 PM
Post: #3
RE: Make Media Player in Delphi
Well this is only the beginning for beginners. I didn't post any complicated code.
It is good like this. I'll post more soon with some more functions.

There's a fine line between genius and insanity. I have erased this line.
Oscar Levant
There's a fine line between an administrator and black hat hacker. I have erased this line.
Dr DEBCOL
Visit this user's website Find all posts by this user
Quote this message in a reply
11-30-2009, 01:10 AM
Post: #4
RE: Make Media Player in Delphi
Alright cool Smile
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


 Quick Theme: