delphi3
asked on
Using Opendialog to select AVI.
Hello,
I am using a modified sample that is provided in D4 help to show a video clip.
If I list the in the File Name, Properties of TMediaPlayer the name of the
desired selection then that one plays. While NOT Running Clicking on the form allows me to select
the xx.avi.
With modifications my unit looks like:
unit VideoPlayerUnit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls, MPlayer, StdCtrls;
type
TVideoPlayer = class(TForm)
VideoPlayer1: TMediaPlayer;
Animate1: TAnimate;
Close: TButton;
procedure FormActivate(Sender: TObject);
procedure CloseClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
VideoPlayer: TVideoPlayer;
implementation
{$R *.DFM}
procedure TVideoPlayer.FormActivate( Sender: TObject);
begin
Videoplayer1.Play;
end;
procedure TVideoPlayer.CloseClick(Se nder: TObject);
begin
Application.Terminate;
end;
end.
Form as text:
object VideoPlayer: TVideoPlayer
Left = 288
Top = 141
Width = 473
Height = 459
Caption = 'Video Player'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
OnActivate = FormActivate
PixelsPerInch = 120
TextHeight = 16
object VideoPlayer1: TMediaPlayer
Left = 56
Top = 8
Width = 253
Height = 30
AutoOpen = True
DeviceType = dtAVIVideo
Display = Animate1
FileName = 'C:\Documents and Settings\Delphi3\Desktop\G LOBE.AVI'
TabOrder = 0
end
object Animate1: TAnimate
Left = 24
Top = 48
Width = 321
Height = 321
Active = False
StopFrame = 12
end
object Close: TButton
Left = 368
Top = 56
Width = 75
Height = 25
Caption = 'Close'
TabOrder = 2
end
end
Is it possible to show a video that is not named in the File Name, Properties of TMediaPlayer but select it with OpenDialog1 and the program is running?
I need an example or a snip.
Thanks,
Delphi3
I am using a modified sample that is provided in D4 help to show a video clip.
If I list the in the File Name, Properties of TMediaPlayer the name of the
desired selection then that one plays. While NOT Running Clicking on the form allows me to select
the xx.avi.
With modifications my unit looks like:
unit VideoPlayerUnit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls, MPlayer, StdCtrls;
type
TVideoPlayer = class(TForm)
VideoPlayer1: TMediaPlayer;
Animate1: TAnimate;
Close: TButton;
procedure FormActivate(Sender: TObject);
procedure CloseClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
VideoPlayer: TVideoPlayer;
implementation
{$R *.DFM}
procedure TVideoPlayer.FormActivate(
begin
Videoplayer1.Play;
end;
procedure TVideoPlayer.CloseClick(Se
begin
Application.Terminate;
end;
end.
Form as text:
object VideoPlayer: TVideoPlayer
Left = 288
Top = 141
Width = 473
Height = 459
Caption = 'Video Player'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
OnActivate = FormActivate
PixelsPerInch = 120
TextHeight = 16
object VideoPlayer1: TMediaPlayer
Left = 56
Top = 8
Width = 253
Height = 30
AutoOpen = True
DeviceType = dtAVIVideo
Display = Animate1
FileName = 'C:\Documents and Settings\Delphi3\Desktop\G
TabOrder = 0
end
object Animate1: TAnimate
Left = 24
Top = 48
Width = 321
Height = 321
Active = False
StopFrame = 12
end
object Close: TButton
Left = 368
Top = 56
Width = 75
Height = 25
Caption = 'Close'
TabOrder = 2
end
end
Is it possible to show a video that is not named in the File Name, Properties of TMediaPlayer but select it with OpenDialog1 and the program is running?
I need an example or a snip.
Thanks,
Delphi3
ASKER
kretzschmar,
It must not work that way because if I remove the name of the file stored in the object insector then I get a message that it wants apath to the file back in again.
Then if Iclick on the button to activate this procedure:
procedure TVideoPlayer.SelectClick(S ender: TObject);
begin
if Opendialog1.Execute then
Videoplayer1.Filename := Opendialog1.Filename;
Videoplayer1.Play;
end;
And there is no chage to the one selected.
Delphi3
Delphi3
It must not work that way because if I remove the name of the file stored in the object insector then I get a message that it wants apath to the file back in again.
Then if Iclick on the button to activate this procedure:
procedure TVideoPlayer.SelectClick(S
begin
if Opendialog1.Execute then
Videoplayer1.Filename := Opendialog1.Filename;
Videoplayer1.Play;
end;
And there is no chage to the one selected.
Delphi3
Delphi3
I don't know if this solves your problem, but I think it would be better if you did this:
procedure TVideoPlayer.SelectClick(S ender: TObject);
begin
if Opendialog1.Execute then begin
Videoplayer1.Filename := Opendialog1.Filename;
Videoplayer1.Play;
end;
end;
procedure TVideoPlayer.SelectClick(S
begin
if Opendialog1.Execute then begin
Videoplayer1.Filename := Opendialog1.Filename;
Videoplayer1.Play;
end;
end;
>And there is no chage to the one selected.
to which selected?
to which selected?
ASKER
scrapdog, and kretzschmar,
Scrapdog, Still even with this change it makes no difference. Programmatically there is no difference. Is there??
To state the errors more explicitly and trying it both ways:
With the FileName empty in the Properties of theTMediaPlayer on the start up the message
appears reads:
Error:
Project VideoPlayerProject 1.exe raised exception class EMCIDeviceError with the message 'the MCI device
you are using does not support the command.', Process stopped. Use Step or Run to continue. [OK]
With the FileName having the name filled in the Properties of theTMediaPlayer on the start up the selection
plays BUT no selection from the openDialog1 makes that selection appear.
Delphi3
Scrapdog, Still even with this change it makes no difference. Programmatically there is no difference. Is there??
To state the errors more explicitly and trying it both ways:
With the FileName empty in the Properties of theTMediaPlayer on the start up the message
appears reads:
Error:
Project VideoPlayerProject 1.exe raised exception class EMCIDeviceError with the message 'the MCI device
you are using does not support the command.', Process stopped. Use Step or Run to continue. [OK]
With the FileName having the name filled in the Properties of theTMediaPlayer on the start up the selection
plays BUT no selection from the openDialog1 makes that selection appear.
Delphi3
>Scrapdog, Still even with this change it makes no
>difference. Programmatically there is no difference.
>Is there??
The difference is that the video doesn't play when the user hits "cancel" in the Open Dialog.
>difference. Programmatically there is no difference.
>Is there??
The difference is that the video doesn't play when the user hits "cancel" in the Open Dialog.
ASKER
Scrapdog,
Thanks, for the correction about my programming statement. .Earlier however, I thought it was 'the solution' that might make it work, but obviously it does not.
So I am still in need of help getting this to work.
Delphi3
Thanks, for the correction about my programming statement. .Earlier however, I thought it was 'the solution' that might make it work, but obviously it does not.
So I am still in need of help getting this to work.
Delphi3
ASKER
scrapdog, and kretzschmar,
I have discovered my help in the D4 help.
Here is the solution:
var
VideoPlayer: TVideoPlayer;
implementation
{$R *.DFM}
procedure TVideoPlayer.FormActivate( Sender: TObject);
begin
Videoplayer1.Play;
end;
procedure TVideoPlayer.SelectClick(S ender: TObject);
begin
OpenDialog1.DefaultExt := 'AVI';
OpenDialog1.Filename := '*.avi';
if OpenDialog1.Execute then
begin
Videoplayer1.Filename := OpenDialog1.Filename;
Videoplayer1.Open;
end;
Animate1.Repaint; // set Color to ClMenu in the object Inspector.
end;
procedure TVideoPlayer.CloseClick(Se nder: TObject);
begin
Application.Terminate;
end;
end.
Form as text:
object VideoPlayer: TVideoPlayer
Left = 288
Top = 141
Width = 427
Height = 389
AutoSize = True
Caption = 'Video Player'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
OnActivate = FormActivate
PixelsPerInch = 120
TextHeight = 16
object VideoPlayer1: TMediaPlayer
Left = 32
Top = 0
Width = 253
Height = 30
AutoOpen = True
DeviceType = dtAVIVideo
Display = Animate1
FileName = 'C:\Documents and Settings\Delphi3\Desktop\S hoVideo\cl ock.avi'
TabOrder = 0
end
object Animate1: TAnimate
Left = 0
Top = 40
Width = 321
Height = 321
Active = False
Color = clMenu
ParentColor = False
StopFrame = 12
end
object Select: TButton
Left = 344
Top = 48
Width = 75
Height = 25
Caption = 'Select'
TabOrder = 2
OnClick = SelectClick
end
object Close: TButton
Left = 344
Top = 104
Width = 75
Height = 25
Caption = 'Close'
TabOrder = 3
OnClick = CloseClick
end
object OpenDialog1: TOpenDialog
Left = 368
Top = 208
end
end
What about the points? I could leave the solution here for others. But since you are outstanding 'pro's' you have any idea how to leave it here and still get rid of the points.
Delphi3
I have discovered my help in the D4 help.
Here is the solution:
var
VideoPlayer: TVideoPlayer;
implementation
{$R *.DFM}
procedure TVideoPlayer.FormActivate(
begin
Videoplayer1.Play;
end;
procedure TVideoPlayer.SelectClick(S
begin
OpenDialog1.DefaultExt := 'AVI';
OpenDialog1.Filename := '*.avi';
if OpenDialog1.Execute then
begin
Videoplayer1.Filename := OpenDialog1.Filename;
Videoplayer1.Open;
end;
Animate1.Repaint; // set Color to ClMenu in the object Inspector.
end;
procedure TVideoPlayer.CloseClick(Se
begin
Application.Terminate;
end;
end.
Form as text:
object VideoPlayer: TVideoPlayer
Left = 288
Top = 141
Width = 427
Height = 389
AutoSize = True
Caption = 'Video Player'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
OnActivate = FormActivate
PixelsPerInch = 120
TextHeight = 16
object VideoPlayer1: TMediaPlayer
Left = 32
Top = 0
Width = 253
Height = 30
AutoOpen = True
DeviceType = dtAVIVideo
Display = Animate1
FileName = 'C:\Documents and Settings\Delphi3\Desktop\S
TabOrder = 0
end
object Animate1: TAnimate
Left = 0
Top = 40
Width = 321
Height = 321
Active = False
Color = clMenu
ParentColor = False
StopFrame = 12
end
object Select: TButton
Left = 344
Top = 48
Width = 75
Height = 25
Caption = 'Select'
TabOrder = 2
OnClick = SelectClick
end
object Close: TButton
Left = 344
Top = 104
Width = 75
Height = 25
Caption = 'Close'
TabOrder = 3
OnClick = CloseClick
end
object OpenDialog1: TOpenDialog
Left = 368
Top = 208
end
end
What about the points? I could leave the solution here for others. But since you are outstanding 'pro's' you have any idea how to leave it here and still get rid of the points.
Delphi3
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Points reduced for adding Q to PAQ.
Lunchy
Friendly Neighbourhood Community Support Moderator
Lunchy
Friendly Neighbourhood Community Support Moderator
If opendialog1.execute then
TMediaplayer1.Filename := opendialog1.filename;