| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 626 人关注过本帖
标题:[求助]我是新手,请问下面的代码问题出在哪里?
只看楼主 加入收藏
风儿累了
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2006-8-19
收藏
 问题点数:0 回复次数:3 
[求助]我是新手,请问下面的代码问题出在哪里?

unit Unit1;

interface

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

type
TForm1 = class(TForm)
MediaPlayer1: TMediaPlayer;
OpenMbt: TButton;
PauseMbt: TButton;
PlayMbt: TButton;
StopMbt: TButton;
OpenDialog1: TOpenDialog;
Timer1: TTimer;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
TB_vol: TTrackBar;
TB_mm: TTrackBar;
TB_r: TTrackBar;
TB_l: TTrackBar;
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure MediaPlayer1Click(Sender: TObject; Button: TMPBtnType;
var DoDefault: Boolean);
procedure PlayMbtClick(Sender: TObject);
procedure StopMbtClick(Sender: TObject);
procedure OpenMbtClick(Sender: TObject);
procedure PauseMbtClick(Sender: TObject);
procedure TB_lChange(Sender: TObject);
procedure TB_rChange(Sender: TObject);
procedure TB_volChange(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
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.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;
var DoDefault: 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;

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;
domediaopen;
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.StopMbtClick(Sender: TObject);
begin
tb_mm.Position:=0;
stopmbt.Enabled:=false;
pausembt.Enabled:=false;
playmbt.Enabled:=true;
mediaplayer1.stop;
end;

procedure TForm1.OpenMbtClick(Sender: TObject);
begin
if not opendialog1.Execute then
exit;
mediapayer1.filename:=opendialog1.filename;
dowediaopen;
playmbt.Click;
end;

procedure TForm1.PauseMbtClick(Sender: TObject);
begin
mediaplayer1.Pause;
pausembt.Enabled:=not pausembt.Enabled;
playmbt.Enabled:=not playmbt.Enabled;
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.positions;
vol:=(pos shl 8)or(pos shl 24);
waveoutsetvolme(0,vol);
end;

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

end.

麻烦你留下QQ可以吗,我想和你多交流。
你也可以加我。QQ:285822027

搜索更多相关主题的帖子: 代码 
2006-08-19 19:01
xu2000
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:51
帖 子:3890
专家分:56
注 册:2006-4-8
收藏
得分:0 

这么代码,一点注解都没有,你考我们呢?


我会拿出我全部的钱财,以保你衣食无忧。我会献出我所有的智慧,以助你一帆风顺。我会想到所有的笑语,以令你展眉开颜。我会挤出最长的时间,以使你终生幸福。        [本人原创的结婚宣言]
2006-08-19 22:08
风儿累了
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2006-8-19
收藏
得分:0 

呵呵,不好意思,这是多媒体播放器的程序,运行后,总是出问题。请指出。
楼上的老兄,能留下QQ号吗,到时候我想和你多多交流,看来您是热心肠。

2006-08-20 16:58
baoxuelan
Rank: 1
等 级:新手上路
帖 子:39
专家分:0
注 册:2006-1-17
收藏
得分:0 
18506882 delpi群高手之路,欢迎各位学习delphi的朋友,此群刚刚成立!

18506882 delpi群高手之路,欢迎各位学习delphi的朋友,此群刚刚成立!
2006-08-24 23:34
快速回复:[求助]我是新手,请问下面的代码问题出在哪里?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.059524 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved