?
Solved

Embedding windows media / real player / quicktime in delphi 7 application

Posted on 2005-03-14
16
Medium Priority
?
1,110 Views
Last Modified: 2012-08-13
I would like to embed the 3 main media players in my D7 app.   I have NO experiance with this and while i've heard its easy I would like some assistance.

If possible i would love code samples / instructions for all 3 but a simple walkthrough will do :)
0
Comment
Question by:hibbidiji
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 3
  • +3
16 Comments
 
LVL 17

Expert Comment

by:TheRealLoki
ID: 13541280
http://delphi.about.com/od/objectpascalide/l/aa021301a.htm

or, if you can't read that, it's like this

First, I create an RC project with NOTEPAD.EXE and ARJ.EXE in it as follows (we'll call it RESJUNK.RC):

 NOTEPAD EXEFILE C:\WINDOWS\NOTEPAD.EXE
 ARJ EXEFILE C:\UTILS\ARJ.EXE
then I compile it with BRCC32 into a RES file. After this I include it in my Delphi project by using the $R compiler directive like this:

{$R RESJUNK.RES}
and extract this files by using the TResourceStream class.

      procedure ExtractRes(ResType, ResName, ResNewName : String);
       var
         Res : TResourceStream;
       begin
         Res := TResourceStream.Create(Hinstance, Resname, Pchar(ResType));
         Res.SavetoFile(ResNewName);
         Res.Free;
       end;
0
 
LVL 1

Author Comment

by:hibbidiji
ID: 13541300
I'm horrifically confused.  I've never made an RC project. I will start it and see what I can figure out, but can you make an example that uses windows media player?
0
 
LVL 34

Expert Comment

by:Slick812
ID: 13541902
I wonder what you mean by - "embed the 3 main media players in my D7 app" - what is Embed mean for you? ? I can not figure embed?

To just have 3 TMediaPlayers, you click the TMediaPlayer button and then click your form where you want them, three times


procedure TForm1.but_PlayClick(Sender: TObject);
begin
MediaPlayer1.FileName := 'C:\Song1.mp3';
MediaPlayer1.Open;
MediaPlayer1.Play;
end;
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 16

Expert Comment

by:CodedK
ID: 13543514
Hi.
You want to play these files from ur application?
Play an mp3 ?  Or just embed them inside the app and extract them somewhere?


1.) Go to this directory:

C:\Program Files\Borland\Delphi7\Bin
Copy the file Brcc32.exe to the directory of ur application.

2.) Here is a guide with all the info you need.
http://delphi.about.com/od/objectpascalide/l/aa021301a.htm

3.) As mentioned above u create a txt file, rename the extension to ".rc" and then open command window
(Start-Run-Cmd) and execute brcc32 like this :

"Brcc32 YourFile.Rc"

4.) In YourFile.Rc (the txt file...) you should type this :

Resource name, resource type, resource file name with the path
Ex:
Mypicture    IMAGE  "C:\My Delphi Programs\Test1\Mypicture.bmp"

This is for an image file.  IMAGE = Resource type.
To see the several Resource types just go to delphi help and type ResType.

Another example of what u shoul type in the txt before renaming it to Something.Rc :

Clock WAVE "c:\mysounds\projects\clock.wav"
MailBeep WAVE "c:\windows\media\newmail.wav"
Cool AVI cool.avi
Intro RCDATA introsong.mp3

5.) When u execute brcc32, "Brcc32 YourFile.rc"
a file will be created ----> YourFile.RES

6.) Write this :         {$R YourFile.RES}
exactly under implementation under
{$R *.dfm}

7.) Like this :

implementation
{$R *.dfm}
{$R YourFile.RES}

------------------------------------------
Inside the link i gave u, u'll find everything u need

Hope this will help u :)




0
 
LVL 17

Expert Comment

by:TheRealLoki
ID: 13547550
Windows Media Player has an awful lot of baggage (dll's codecs, etc)
it is after all, several meg as an install from microsoft, and you will need to make sure you have it for the correct OS
but if you still want to do this, for a start your RC would look like this
MediaPlayer.RC
------------------
MPlayer EXEFILE "C:\Program Files\Windows Media Player\mplayer2.exe"

then you'll need to find all the dlls and codecs
0
 
LVL 1

Author Comment

by:hibbidiji
ID: 13548467
I think everyone is missing the point.  the title of the question referes to windows media player, real player and quicktime,  Slick,
imagine a web page with an embedded windows media player.  the browser is using the ocx in at least internet explorer's case.     I'm writing an application that will play windows media (including DRMd files), quicktime and real player files inside it.   In visual basic its quite easy to do this, practically drag and drop.     I also do not intend on distrobuting the files with the application.   to begin, its illegal, against all the TOSs that accompany these apps.  I will require that the user install the apps they want to access.  

Is there not an easy way to embed activex or somesuch in delphi?
0
 
LVL 17

Expert Comment

by:TheRealLoki
ID: 13548492
just drop a TMediaPlayer component (system tab) onto the form Not sure about real or quicktime files though.
0
 
LVL 16

Expert Comment

by:CodedK
ID: 13549709
Hi.
U said embed those applications.
Thats why i was confused.
There is no need to embed the applications to play those files.

Just google and search for components.

This is the code for playing wma and mp3 like Slick812 said:

 MediaPlayer1.FileName:=the file name;
 MediaPlayer1.Open;
 MediaPlayer1.Play;

0
 
LVL 1

Author Comment

by:hibbidiji
ID: 13550492
Codedk,
you're saying that playing a real player streaming video stream is possible using the code above?  
0
 
LVL 16

Expert Comment

by:CodedK
ID: 13550651
------->
This is the code for playing " wma and mp3 ".
Like i said there is no need to embed the applications to play those files.
Just google and search for components....
This will simplify ur code.

Yes u can play real player streaming video if u embed all the application with the code i gave you using RCData as a type
then extract in runtime and give the order to the app extracted to play a file that user wants.
BUT this will make the application size huge.
However with delphi u can use windows api so you can play wma and mp3 without embeding anything.

The only solution, is using a component.

0
 
LVL 34

Expert Comment

by:Slick812
ID: 13550694
I am almost certain that if you just import the Real player .EXE program it will not run on a puter that does not have that version installed (needs supporting DLLs and support files), and if it is already installed, why store it as a resource?
????
I have been able to use the TMediaPlayer for any files that I needed to play, but it is true that there are a few media files that it will not play?
This is just my "Idea" about doing this type of thing, I have not tried to do this for any type of Media Player,
On the Delphi IDE menu bar, go to the Component menu and then click the "Import ActiveX Control" Im mine there is a  "Windows Media Player" and there is also a  "Real Player ActiveX Library", you can choose one (you may see other ActiveX that you are interested in) and then click the "Add" button, this should place that imported ActiveX control in the ActiveX Tab of the component library, you can then click That activeX onto your Form and look in the object inspector for the properties and events that it supports, , , do not ask me about how to use these ActiveX controls, because I have not used them. . . For some activeX I have imported the properties and method names are enough for me to start to use them, , ,  I am not sure if this is what you mean? just an Idea, maybe there are better ways?
0
 
LVL 34

Expert Comment

by:Slick812
ID: 13550722
It is posible to start and existing program (Like NotePad) and set it as a "Child Control" so it appears On your Form, but it is a tough thing to then "Control" this program from your apps code, unless there is a "COM" link or DDE you can use to control it, I think that Windows media player has a Com link (or some Kind of control connection), but I am not familar with it
0
 
LVL 16

Expert Comment

by:CodedK
ID: 13553193
Hi.
I think that the decoding of Rm (Real media) and Mov (Quicktime) video streams is a protected code.
Its not an open source. Thats why no player can play those files...
So thats why i think the only way to play those files is to insert a component (not freeware) that pays money to
Real and Quicktime.
0
 
LVL 3

Accepted Solution

by:
BJThomsen earned 2000 total points
ID: 13557480
For the Windows Media player at least you can import the active X control into delphi.

Goto the Component/Import Active X and select the Windows Media Player. This will let you place a TWindowsMediaPlayer on your form. It's possible you could do the same for RM and QT.
0
 
LVL 3

Expert Comment

by:gandalf_the_white
ID: 13590769
you didnt tell us, why you want to have the three players in your programm,
but if you want the user to play his own files then you'll get a whole new
dimension to the problem.
if the video is divx then it can have the extension avi and the user wont be
able to play it in your program. and there are enough systems out there
that have problems with playing videos because of wrong or missing
or otherwise not working codecs.
especially with divx there is a whole bunch of codecs running around
but there are also enough avi codecs that take their share into the problem.
0
 
LVL 1

Author Comment

by:hibbidiji
ID: 13594112
I have found an appliation that appears to do what I want:

http://www.ahusoft.com/

They have done the same thing.   Someone on a message board where I posted this question as well pointed it out.  

I also want to use it for vaguely similar reasons
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses
Course of the Month11 days, 7 hours left to enroll

752 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