andrewyu
asked on
TMediaPlayer
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
MediaPlayer1.Close;
MediaPlayer1.Filename:= GetCurrentDir + '\17.avi';
MediaPlayer1.DeviceType := dtAVIVideo;
MediaPlayer1.Display:= Panel1;
MediaPlayer1.Open;
MediaPlayer1.Play;
thanks,
Andrew
rename .avi to .mpg, may be it will help
ASKER
No, it cannot help.
However, the file can open in Windows Medai Player.
Thanks,
Andrew
However, the file can open in Windows Medai Player.
Thanks,
Andrew
ASKER
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
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:=
MediaPlayer1.Rewind;
MediaPlayer1.Play;
Thanks,
Andrew
Can you post the AVI somewhere where we can get it?
ASKER
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
BUT, both can play smooth in Windows Media Player.
How can I solve this problem ?
Thanks,
Andrew
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(Sende r: 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;
if i tried to play some .AVI files, i had error something like "compression not found"
procedure TMainForm.FormCreate(Sende
begin
mp := TMediaPlayer.Create(Self);
mp.Visible := false;
mp.VisibleButtons := [];
mp.Parent := Panel1;
mp.Display := Panel1;
end;
procedure TMainForm.DoPlay(filename:
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;
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?
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?
ASKER
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
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
ASKER
Hi, StevenB,
Wooo. It can play the video now.
But, how can I IN-VISIBLE the button ?
Thanks,
Andrew
Wooo. It can play the video now.
But, how can I IN-VISIBLE the button ?
Thanks,
Andrew
ASKER
Hi, StevenB,
Wooo. It can play the video now.
But, how can I IN-VISIBLE the button and REPEATLY ?
Thanks,
Andrew
Wooo. It can play the video now.
But, how can I IN-VISIBLE the button and REPEATLY ?
Thanks,
Andrew
ASKER
Hi, StevenB,
Wooo. It can play the video now.
But, how can I IN-VISIBLE the button and play REPEATLY ?
Thanks,
Andrew
Wooo. It can play the video now.
But, how can I IN-VISIBLE the button and play REPEATLY ?
Thanks,
Andrew
" IN-VISIBLE the button"
Which button?
Which button?
ASKER
I mean those button on the bottom, i.e. Play, slider, volume, pause, stop ...
In TMediaPlayer or the the Media Player ActiveX? Please be more specific which you are using, here.
I'd still like to have a copy of the AVI to test, if possible.
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)
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.
but can not find out how to do it in the ActiveX.
ASKER
hi, EddieShipman,
Sorry ! I cannot give you the AVI at this moment.
Anyway, what do you mean by UI_MODE ?
Thanks,
Andrew
Sorry ! I cannot give you the AVI at this moment.
Anyway, what do you mean by UI_MODE ?
Thanks,
Andrew
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.
I can find no way to tell WMP to go fullscreen from the OCX.
ASKER
What is value for Set_UIMoid (I guess it is Set_UIMode) and "none" ?
Thanks,
Andrew
Thanks,
Andrew
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yeah, no worries mate.
So, did you get it working? If so, please post your result.
ASKER
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
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