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

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
风儿累了
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2006-8-19
收藏
得分:0 

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

2006-08-20 16:58
快速回复:[求助]我是新手,请问下面的代码问题出在哪里?
数据加载中...
 
   



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

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