[求助]关于制作多媒体播放器DodediaOpen函数 ( 积分: 50 )

  • 主题发起人 主题发起人 天使依依
  • 开始时间 开始时间

天使依依

Unregistered / Unconfirmed
GUEST, unregistred user!
我刚学DELPHI在一本书中发现了这个例子,但是编译通不过,好象DomediaOpen函数的问题,

请教高手。

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls, MPlayer, ExtCtrls,Buttons,Mmsystem;
type
TMPBtnType=(btplay,btpause,btstop,btnext,btprev,btstep,btback,btRecord,btEject);
TButtonSet = set of TMPBtnType;
type
TForm1 = class(TForm)
Panel1: TPanel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
PlayMbt: TButton;
StopMbt: TButton;
PauseMbt: TButton;
OpenMbt: TButton;
TB_vol: TTrackBar;
TB_l: TTrackBar;
TB_r: TTrackBar;
TB_mm: TTrackBar;
OpenDialog1: TOpenDialog;
Timer1: TTimer;
MediaPlayer1: TMediaPlayer;

procedure FormClose(Sender: TObject;
var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure OpenMbtClick(Sender: TObject);
procedure StopMbtClick(Sender: TObject);
procedure PauseMbtClick(Sender: TObject);
procedure PlayMbtClick(Sender: TObject);
procedure TB_lChange(Sender: TObject);
procedure TB_rChange(Sender: TObject);
procedure TB_volChange(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure MediaPlayer1Click(Sender: TObject;
Button: TMPBtnType;
vardo
Default: Boolean);
procedure TB_mmChange(Sender: TObject);
private
runed:boolean;{ Private declarations }
public
{ Public declarations }
end;


var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormClose(Sender: TObject;
var Action: TCloseAction);
begin

Close;
end;


procedure TForm1.FormCreate(Sender: TObject);
var vol:cardinal;
begin

waveoutgetvolume(0,@vol);
TB_l.Position:=hi(vol);
{设置左声道音量}
TB_r.Position:=hi(vol shr 16);
{设置右声道音量}
TB_vol.Position:=hi(vol) or hi(vol shr 16);
TB_l.Max:=TB_vol.Position;
TB_r.Max:=TB_vol.Position;

end;


procedure TForm1.OpenMbtClick(Sender: TObject);
begin

if not OpenDialog1.Execute then

exit;
MediaPlayer1.FileName:=OpenDialog1.FileName;
do
mediaOpen;
Playmbt.Click;
end;


procedure TForm1.StopMbtClick(Sender: TObject);
begin

tb_mm.Position:=0;
Stopmbt.Enabled:=false;
Pausembt.Enabled:=false;
Playmbt.Enabled:=true;
MediaPlayer1.stop;
end;


procedure TForm1.PauseMbtClick(Sender: TObject);
begin

MediaPlayer1.Pause;
PausemBt.Enabled:=not PausemBt.Enabled;
PlaymBt.Enabled:=not PlaymBt.Enabled;
end;


procedure TForm1.PlayMbtClick(Sender: TObject);
begin

if MediaPlayer1.Mode=mpPaused then

begin

PlaymBt.Enabled:=false;
StopmBt.Enabled:=true;
PausemBt.Enabled:=true;
MediaPlayer1.Resume;
Timer1.Enabled:=true;
end
else

begin

MediaPlayer1.Open;
TB_mm.Max:=mediaplayer1.Length;
do
mediaOpen;
Mediaplayer1.play;
Timer1.Enabled:=true;
if mediaplayer1.Mode<>mpplaying then

mediaplayer1.Play;
playmBt.Enabled:=false;
stopmBt.Enabled:=true;
pausemBt.Enabled:=true;
end;


end;


procedure TForm1.TB_lChange(Sender: TObject);
var
pos,vol:longint;
begin

TB_l.Max:=TB_vol.Position;
pos:=TB_l.Position;
waveoutgetvolume(0,@vol);
vol:=vol and $ffff0000 or (pos shl 8);
waveoutgetvolume(0,@vol);

end;


procedure TForm1.TB_rChange(Sender: TObject);
var
pos,vol:longint;
begin

TB_r.Max:=TB_vol.Position;
pos:=TB_r.Position;
waveoutgetvolume(0,@vol);
vol:=vol and $0000ffff or (pos shl 24);
waveoutgetvolume(0,@vol);
end;


procedure TForm1.TB_volChange(Sender: TObject);
var
pos,vol:longint;
begin

pos:=TB_vol.Position;
vol:=(pos shl 8)or(pos shl 24);
waveoutgetvolume(0,@vol);
end;


procedure TForm1.Timer1Timer(Sender: TObject);
begin

if mediaplayer1.Mode=mpplaying then

begin

TB_mm.Position:=mediaplayer1.Position;
end
else

begin

if mediaplayer1.Mode=mpstopped then

stopmbtclick(self);
Timer1.Enabled:=false;
end;

end;


procedure TForm1.MediaPlayer1Click(Sender: TObject;
Button: TMPBtnType;
vardo
Default: Boolean);
begin

case Button of
btPlay :
begin

caption:='Playing';
end;

btPause :
begin

caption:='Paused';
end;

btStop :
begin

caption:='Stoped';
end;

btNext :
begin

caption:='Next';
end;

btPrev :
begin

caption:='Previous';
end;

btStep :
begin

caption:='Step';
end;

btBack :
begin

caption:='Back';
end;

btRecord :
begin

caption:='Record';
end;

btEject :
begin

caption:='Eject';
end;

end;

end;

procedure TForm1.TB_mmChange(Sender: TObject);
begin

if runed then

mediaplayer1.Position:=TB_mm.Position;//如果进度条的位置被改动,则媒体文件跳到相应位置继续播放

end;


end.


出错提示:

[Error] Unit1.pas(80): Undeclared identifier: 'DomediaOpen'
[Error] Unit1.pas(114): Undeclared identifier: 'DomediaOpen'
[Warning] Unit1.pas(133): Combining signed and unsigned types - widened both operands
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'

好象是没有定义DomediaOpen这个函数,有谁能帮我写一下?
 
我刚学DELPHI在一本书中发现了这个例子,但是编译通不过,好象DomediaOpen函数的问题,

请教高手。

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls, MPlayer, ExtCtrls,Buttons,Mmsystem;
type
TMPBtnType=(btplay,btpause,btstop,btnext,btprev,btstep,btback,btRecord,btEject);
TButtonSet = set of TMPBtnType;
type
TForm1 = class(TForm)
Panel1: TPanel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
PlayMbt: TButton;
StopMbt: TButton;
PauseMbt: TButton;
OpenMbt: TButton;
TB_vol: TTrackBar;
TB_l: TTrackBar;
TB_r: TTrackBar;
TB_mm: TTrackBar;
OpenDialog1: TOpenDialog;
Timer1: TTimer;
MediaPlayer1: TMediaPlayer;

procedure FormClose(Sender: TObject;
var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure OpenMbtClick(Sender: TObject);
procedure StopMbtClick(Sender: TObject);
procedure PauseMbtClick(Sender: TObject);
procedure PlayMbtClick(Sender: TObject);
procedure TB_lChange(Sender: TObject);
procedure TB_rChange(Sender: TObject);
procedure TB_volChange(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure MediaPlayer1Click(Sender: TObject;
Button: TMPBtnType;
vardo
Default: Boolean);
procedure TB_mmChange(Sender: TObject);
private
runed:boolean;{ Private declarations }
public
{ Public declarations }
end;


var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormClose(Sender: TObject;
var Action: TCloseAction);
begin

Close;
end;


procedure TForm1.FormCreate(Sender: TObject);
var vol:cardinal;
begin

waveoutgetvolume(0,@vol);
TB_l.Position:=hi(vol);
{设置左声道音量}
TB_r.Position:=hi(vol shr 16);
{设置右声道音量}
TB_vol.Position:=hi(vol) or hi(vol shr 16);
TB_l.Max:=TB_vol.Position;
TB_r.Max:=TB_vol.Position;

end;


procedure TForm1.OpenMbtClick(Sender: TObject);
begin

if not OpenDialog1.Execute then

exit;
MediaPlayer1.FileName:=OpenDialog1.FileName;
do
mediaOpen;
Playmbt.Click;
end;


procedure TForm1.StopMbtClick(Sender: TObject);
begin

tb_mm.Position:=0;
Stopmbt.Enabled:=false;
Pausembt.Enabled:=false;
Playmbt.Enabled:=true;
MediaPlayer1.stop;
end;


procedure TForm1.PauseMbtClick(Sender: TObject);
begin

MediaPlayer1.Pause;
PausemBt.Enabled:=not PausemBt.Enabled;
PlaymBt.Enabled:=not PlaymBt.Enabled;
end;


procedure TForm1.PlayMbtClick(Sender: TObject);
begin

if MediaPlayer1.Mode=mpPaused then

begin

PlaymBt.Enabled:=false;
StopmBt.Enabled:=true;
PausemBt.Enabled:=true;
MediaPlayer1.Resume;
Timer1.Enabled:=true;
end
else

begin

MediaPlayer1.Open;
TB_mm.Max:=mediaplayer1.Length;
do
mediaOpen;
Mediaplayer1.play;
Timer1.Enabled:=true;
if mediaplayer1.Mode<>mpplaying then

mediaplayer1.Play;
playmBt.Enabled:=false;
stopmBt.Enabled:=true;
pausemBt.Enabled:=true;
end;


end;


procedure TForm1.TB_lChange(Sender: TObject);
var
pos,vol:longint;
begin

TB_l.Max:=TB_vol.Position;
pos:=TB_l.Position;
waveoutgetvolume(0,@vol);
vol:=vol and $ffff0000 or (pos shl 8);
waveoutgetvolume(0,@vol);

end;


procedure TForm1.TB_rChange(Sender: TObject);
var
pos,vol:longint;
begin

TB_r.Max:=TB_vol.Position;
pos:=TB_r.Position;
waveoutgetvolume(0,@vol);
vol:=vol and $0000ffff or (pos shl 24);
waveoutgetvolume(0,@vol);
end;


procedure TForm1.TB_volChange(Sender: TObject);
var
pos,vol:longint;
begin

pos:=TB_vol.Position;
vol:=(pos shl 8)or(pos shl 24);
waveoutgetvolume(0,@vol);
end;


procedure TForm1.Timer1Timer(Sender: TObject);
begin

if mediaplayer1.Mode=mpplaying then

begin

TB_mm.Position:=mediaplayer1.Position;
end
else

begin

if mediaplayer1.Mode=mpstopped then

stopmbtclick(self);
Timer1.Enabled:=false;
end;

end;


procedure TForm1.MediaPlayer1Click(Sender: TObject;
Button: TMPBtnType;
vardo
Default: Boolean);
begin

case Button of
btPlay :
begin

caption:='Playing';
end;

btPause :
begin

caption:='Paused';
end;

btStop :
begin

caption:='Stoped';
end;

btNext :
begin

caption:='Next';
end;

btPrev :
begin

caption:='Previous';
end;

btStep :
begin

caption:='Step';
end;

btBack :
begin

caption:='Back';
end;

btRecord :
begin

caption:='Record';
end;

btEject :
begin

caption:='Eject';
end;

end;

end;

procedure TForm1.TB_mmChange(Sender: TObject);
begin

if runed then

mediaplayer1.Position:=TB_mm.Position;//如果进度条的位置被改动,则媒体文件跳到相应位置继续播放

end;


end.


出错提示:

[Error] Unit1.pas(80): Undeclared identifier: 'DomediaOpen'
[Error] Unit1.pas(114): Undeclared identifier: 'DomediaOpen'
[Warning] Unit1.pas(133): Combining signed and unsigned types - widened both operands
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'

好象是没有定义DomediaOpen这个函数,有谁能帮我写一下?
 
DomediaOpen
只要换成mediaplayer.open就行了
 

Similar threads

后退
顶部