MediaPlayer1是不是不可以播放.rmvb格式的文件,我的代码如下,现在的问题是不能播放视频文件了,郁闷中呀
unit UPlayer;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, MPlayer, Buttons, OleCtrls, RealAudioObjects_TLB,
ComCtrls;
type
TForm1 = class(TForm)
Panel1: TPanel;
MediaPlayer1: TMediaPlayer;
SpeedButton1: TSpeedButton;
RealAudio1: TRealAudio;
Panel2: TPanel;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
OpenDialog1: TOpenDialog;
TrackBar2: TTrackBar;
TrackBar1: TTrackBar;
procedure MediaPlayer1Click(Sender: TObject;
Button: TMPBtnType;
vardo
Default: Boolean);
procedure TrackBar1Change(Sender: TObject);
procedure TrackBar2Change(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
procedure MediaPlayer1Notify(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.MediaPlayer1Click(Sender: TObject;
Button: TMPBtnType;
vardo
Default: Boolean);
begin
mediaplayer1.Notify:=true;
//触发onnotify事件
mediaplayer1.DisplayRect:=panel1.ClientRect;
//将媒体在display对象的全屏播放
end;
procedure TForm1.TrackBar1Change(Sender: TObject);
begin
mediaplayer1.Stop;
//停止播放
mediaplayer1.Position:=trackbar1.Position;//将媒体位置设置为拖动的位置
mediaplayer1.Play;
//继续从当前位置播放
end;
procedure TForm1.TrackBar2Change(Sender: TObject);
begin
//如果speedbutton1按下,表示已经设置为静音
if not self.SpeedButton1.Down then
//将系统音量设置为trackbar拖动的位置大小
realaudio1.SetVolume(trackbar2.Position);
end;
procedure TForm1.SpeedButton2Click(Sender: TObject);
begin
self.SpeedButton1.Down:=true;
//按钮设置为按下状态
//realaudio1.SetVolume(0);
//静音,0代表静音
end;
procedure TForm1.SpeedButton3Click(Sender: TObject);
begin
if opendialog1.Execute then
begin
//将打开的媒体文件加载到媒体播放组件
mediaplayer1.FileName:=opendialog1.FileName;
end;
end;
procedure TForm1.MediaPlayer1Notify(Sender: TObject);
begin
if mediaplayer1.Notify and (mediaplayer1.Mode=mpstopped) then
begin
mediaplayer1.Stop;
mediaplayer1.Rewind;//将媒体回执到开始位置
mediaplayer1.Play;
//继续播放
end;
end;
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
begin
if mediaplayer1.Mode<>mpstopped then
mediaplayer1.Stop;//停止播放
form1.Close;
// 关闭窗体
end;
end;
end.