?
Solved

TMediaPlayer

Posted on 2005-05-02
24
Medium Priority
?
547 Views
Last Modified: 2010-04-16
How come i cannoty play a AVI file with following code ?

  MediaPlayer1.Close;
  MediaPlayer1.Filename:= GetCurrentDir + '\17.avi';
  MediaPlayer1.DeviceType := dtAVIVideo;
  MediaPlayer1.Display:= Panel1;
  MediaPlayer1.Open;
  MediaPlayer1.Play;

thanks,
Andrew
0
Comment
Question by:andrewyu
  • 11
  • 8
  • 3
  • +1
24 Comments
 
LVL 6

Expert Comment

by:vadim_ti
ID: 13913077
rename .avi to .mpg, may be it will help
0
 

Author Comment

by:andrewyu
ID: 13913111
No, it cannot help.

However, the file can open in Windows Medai Player.

Thanks,
Andrew
0
 

Author Comment

by:andrewyu
ID: 13913288
After I change the code as follownig, the ediaPlayer1.Position is moving (i.e. the number is increasing).
However, I cannot see any MOVIE from its popup window.
What seems to be the problem ?

  MediaPlayer1.Close;
  MediaPlayer1.DeviceType := dtAutoSelect;
//  MediaPlayer1.Display:= Panel1;
  MediaPlayer1.Filename:= GetCurrentDir + '\17.avi';
  MediaPlayer1.Open;
  MediaPlayer1.DisplayRect:= Rect(0, 0, 400, 400);
  MediaPlayer1.Rewind;
  MediaPlayer1.Play;

Thanks,
Andrew
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 26

Expert Comment

by:Eddie Shipman
ID: 13913374
Can you post the AVI somewhere where we can get it?
0
 

Author Comment

by:andrewyu
ID: 13913577
I found I can only play file with compression on "Mcrosoft MPEG-4 Video Codec" and cannot play file with compression on "XviD MPEG-4 Codec".

BUT, both can play smooth in Windows Media Player.

How can I solve this problem ?

Thanks,
Andrew
0
 
LVL 6

Expert Comment

by:vadim_ti
ID: 13913755
see code below worked for me after renaming file from .AVI to .MPG
if i tried to play some .AVI files, i had error something like "compression not found"


procedure TMainForm.FormCreate(Sender: TObject);
begin
    mp := TMediaPlayer.Create(Self);
    mp.Visible := false;
    mp.VisibleButtons := [];
    mp.Parent := Panel1;
    mp.Display := Panel1;
end;


procedure TMainForm.DoPlay(filename: String; loop, fullScreen: Boolean);
var
  rect, fRect: TRect;
  h, w: Integer;
begin
  if not inPlay then begin
    fRect := GetClientRect;
    inPlay := true;
    inLoop := loop;


    mp.Wait := true; mp.Notify := false;
    mp.Close;
    mp.FileName := filename;
    mp.Wait := true; mp.Notify := false;
    mp.Open;

    FillChar(Rect, sizeof(TRect), 0);
    rect := mp.DisplayRect;
    h := rect.Bottom - rect.Top;
    w := rect.Right - rect.Left;
    if (h > 0) and (w > 0) then begin
      if fullScreen then begin
        Panel1.Align := alClient;
        mp.DisplayRect := fRect;
      end
      else begin
        Panel1.Align := alNone;
        Panel1.height := h; Panel1.Width := w;
        Panel1.Top := (frect.Bottom - frect.Top - h) div 2;
        Panel1.Left := (frect.Right - frect.Left - w) div 2;
      end;
      Panel1.Visible := true;
    end;
    mp.Wait := false; mp.Notify := true;
    mp.Play;
  end;
end;
0
 
LVL 4

Expert Comment

by:StevenB
ID: 13913855
The TMediaPlayer component struggles with many compressions. You can try importing the Windows Media Player ActiveX control to play your file instead:

1) From the Delphi main menu click Component->Import ActiveX Control
2) Select Windows Media Player from the list of controls and click the Install button
3) The Windows Media Player Control should be installed on your palette (probably on the ActiveX tab)

Maybe that would work?
0
 

Author Comment

by:andrewyu
ID: 13915496
Hi, vadim_ti,

It still cannot work.

Hi, StevenB,

Do you have any sample code for that control and how can i IN-VISIBLE the button ?

Thanks,
Andrew
0
 

Author Comment

by:andrewyu
ID: 13915528
Hi, StevenB,

Wooo. It can play the video now.
But, how can I IN-VISIBLE the button ?

Thanks,
Andrew
0
 

Author Comment

by:andrewyu
ID: 13915547
Hi, StevenB,

Wooo. It can play the video now.
But, how can I IN-VISIBLE the button and REPEATLY ?

Thanks,
Andrew
0
 

Author Comment

by:andrewyu
ID: 13915551
Hi, StevenB,

Wooo. It can play the video now.
But, how can I IN-VISIBLE the button and play REPEATLY ?

Thanks,
Andrew
 
0
 
LVL 26

Expert Comment

by:Eddie Shipman
ID: 13917687
" IN-VISIBLE the button"

Which button?
0
 

Author Comment

by:andrewyu
ID: 13919301
I mean those button on the bottom, i.e. Play, slider, volume, pause, stop ...
0
 
LVL 26

Expert Comment

by:Eddie Shipman
ID: 13919591
In TMediaPlayer or the the Media Player ActiveX? Please be more specific which you are using, here.
0
 
LVL 26

Expert Comment

by:Eddie Shipman
ID: 13919599
I'd still like to have a copy of the AVI to test, if possible.
0
 
LVL 4

Expert Comment

by:StevenB
ID: 13931997
 To be honest andrew, I'm not sure how, if indeed it is possible, you hide the buttons on the Windows Media Player ActiveX. A nasty hack would be to hide them behind a panel, but I can't advocate this sort of dirty coding ;o)



0
 
LVL 26

Expert Comment

by:Eddie Shipman
ID: 13936257
I see no way to access the Players controls from the ActiveX. I know you can set the UI_MODE of the Player to NONE
but can not find out how to do it in the ActiveX.
0
 

Author Comment

by:andrewyu
ID: 13938340
hi, EddieShipman,

Sorry ! I cannot give you the AVI at this moment.

Anyway, what do you mean by UI_MODE ?

Thanks,
Andrew
0
 
LVL 26

Expert Comment

by:Eddie Shipman
ID: 13939940
When you select View Fullscreen, it sends a Set_UIMoid call to the WMP iwth the ui_mode flag of 'none'.

I can find no way to tell WMP to go fullscreen from the OCX.
0
 

Author Comment

by:andrewyu
ID: 13941844
What is value for Set_UIMoid (I guess it is Set_UIMode) and "none" ?

Thanks,
Andrew
0
 
LVL 26

Accepted Solution

by:
Eddie Shipman earned 100 total points
ID: 13944732
0
 
LVL 4

Expert Comment

by:StevenB
ID: 13950615
Yeah, no worries mate.
0
 
LVL 26

Expert Comment

by:Eddie Shipman
ID: 13959216
So, did you get it working? If so, please post your result.
0
 

Author Comment

by:andrewyu
ID: 13959890
I cannot test it at this moment (because i cannot upgrade my Media Player to version 10 now), however, it is right resources for me.

Anyway, I will test it completely 2 weeks later and I will tell you the result afterward !

Thank you very much for your help !

Best,
Andrew
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

840 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