程序老是报错,气死了!(100分)

  • 主题发起人 主题发起人 zhlwyy
  • 开始时间 开始时间
Z

zhlwyy

Unregistered / Unconfirmed
GUEST, unregistred user!
我做了一个简单的媒体播放器,可是老是有三处报错,各位大虾帮帮忙吧![:(]
出错的是再45,66,127[Error] Unit1.pas(66): Missing operator or semicolon
[Warning] Unit1.pas(127): Combining signed and unsigned types - widened both operands
[Error] Unit1.pas(45): Unsatisfied forward or external declaration: 'TForm1.DomediaOpen'
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, ComCtrls, MPlayer,buttons,Mmsystem;

type
TForm1 = class(TForm)
MediaPlayer1: TMediaPlayer;
TrackBar1: TTrackBar;
Timer1: TTimer;
OpenDialog1: TOpenDialog;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
TrackBar2: TTrackBar;
TrackBar3: TTrackBar;
TrackBar4: TTrackBar;
procedure FormClose(Sender: TObject;
var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure TrackBar2Change(Sender: TObject);
procedure TrackBar3Change(Sender: TObject);
procedure TrackBar1Change(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure MediaPlayer1Click(Sender: TObject;
Button: TMPBtnType;
vardo
Default: Boolean);
private
{ Private declarations }
public
{ Public declarations }
//音量控制中用到的全局变量
vol:longint;
//程序中用到的自定义函数
proceduredo
mediaOpen;
end;


var
Form1: TForm1;

implementation

{$R *.dfm}

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

close;
end;


procedure TForm1.FormCreate(Sender: TObject);
begin

waveoutgetvolume(0,@vol);
trackbar2.Position:=hi(vol);//设置左声道音量
trackbar3.Position:=hi(vol shr 16);//设置右声道音量
trackbar1.Position:=hi(vol)or hi(vol shr 16)
TrackBar2.Max:=trackbar1.Position;
TrackBar3.Max:=trackbar1.Position;
end;


procedure TForm1.Button4Click(Sender: TObject);
begin

if not opendialog1.Execute then

exit;
mediaplayer1.FileName:=opendialog1.FileName;
do
mediaopen;
button1.Click;
end;


procedure TForm1.Button2Click(Sender: TObject);
begin

trackbar4.Position:=0;
button2.Enabled:=false;
button3.Enabled:=false;
button1.Enabled:=false;
mediaplayer1.Stop;
end;


procedure TForm1.Button3Click(Sender: TObject);
begin

mediaplayer1.Pause;
button3.Enabled:=not button3.Enabled;
button1.Enabled:=not button1.Enabled;
end;


procedure TForm1.Button1Click(Sender: TObject);
begin

if mediaplayer1.Mode=mppaused then

begin

button1.Enabled:=false;
button2.Enabled:=false;
button3.Enabled:=false;
mediaplayer1.Resume;
timer1.Enabled:=true;
end
else

begin

mediaplayer1.Open;
trackbar4.Max:=mediaplayer1.Length;
do
mediaopen;
mediaplayer1.Play;
timer1.Enabled:=false;
if mediaplayer1.Mode<>mpplaying then

mediaplayer1.Play;
button1.Enabled:=false;
button2.Enabled:=true;
button3.Enabled:=true;
end
end;


procedure TForm1.TrackBar2Change(Sender: TObject);
var
pos,vol:longint;
begin
//设置左声道的音量
trackbar2.Max:=trackbar1.Position;
pos:=trackbar2.Position;
waveoutgetvolume(0,@vol);
vol:=vol and $ffff0000 or (pos shl 8);
waveoutsetvolume(0,vol);
end;


procedure TForm1.TrackBar3Change(Sender: TObject);
var
pos,vol:longint;
begin
//设置右声道的音量
trackbar3.Max:=trackbar1.Position;
pos:=trackbar3.Position;
waveoutgetvolume(0,@vol);
vol:=vol and $0000ffff or (pos shl 24);
waveoutsetvolume(0,vol);

end;


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

pos:=trackbar1.Position;
vol:=(pos shl 8)or(pos shl 24);
waveoutsetvolume(0,vol);

end;


procedure TForm1.Timer1Timer(Sender: TObject);
begin

if mediaplayer1.Mode=mpplaying then

begin

trackbar4.Position:=mediaplayer1.Position;

end
else

begin

if mediaplayer1.Mode=mpstopped then

button2click(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:='stopped';
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;

end.
 
procedure TForm1.FormCreate(Sender: TObject);
begin

waveoutgetvolume(0,@vol);
trackbar2.Position:=hi(vol);//设置左声道音量
trackbar3.Position:=hi(vol shr 16);//设置右声道音量
trackbar1.Position:=hi(vol)or hi(vol shr 16)
TrackBar2.Max:=trackbar1.Position;
TrackBar3.Max:=trackbar1.Position;
end;

中trackbar1.Position:=hi(vol)or hi(vol shr 16)少分号
应该为trackbar1.Position:=hi(vol)or hi(vol shr 16);
proceduredo
mediaOpen;函数没有定义
 
代码太长了,还用了很多控件
最好将dfm的文本贴出来,好放到DELPHI中给楼主试试[8D]
 
上面就是程序的源代码
 
proceduredo
mediaOpen;函数没有定义
 
[Error] Unit1.pas(66): Missing operator or semicolon
[Warning] Unit1.pas(127): Combining signed and unsigned types - widened both operands
[Error] Unit1.pas(45): Unsatisfied forward or external declaration: 'TForm1.DomediaOpen'
unit Unit1;
66行出错,缺操作符或分号
127行警告(不一定是错误),有符号和无符号操作数组合
45行错,TForm1.DomediaOpen没有定义
 
我还是有一些不明白,请高手给我写出来!
那函数怎么定义呀?
 
多人接受答案了。
 
后退
顶部