打开媒体时设置:
procedure TForm1.OpenPlayMedia;
begin
if OpenDialog1.Execute then
begin
if MediaPlayer1.State=msOpened then
MediaPlayer1.Close;
MediaPlayer1.FileName:=OpenDialog1.FileName;
MediaPlayer1.Open;
MediaPlayer1.DeviceType:=dtAutoSelect;
TrackBar1.Max:=MediaPlayer1.Length;
MediaPlayer1.Play;
end;
end;
procedure TForm1.TrackBar1Change(Sender:TObject);
begin
MediaPlayer1.Position:=TrackBar1.Position;
end;