我刚开始用Mediaplayer控件,外加一个OPENDIALOG控件和一个checklistbox,一个button。在我点button时,打开几个.mp3格式的歌曲,将他们列在checklistbox里面,同时mediaplayer播放第一首歌。上面都没有问题,可是在我点击next按钮时,歌曲是跳到了下一首,可是不会自动播放,要再点一下播放按钮才会播放。请教各位高手,这要怎么解决。下面附代码:
unit Unitmp3;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, AppEvnts, StdCtrls, ComCtrls, MPlayer, CheckLst;type
  TForm1 = class(TForm)
    mp_1: TMediaPlayer;
    btn_1: TButton;
    OD_1: TOpenDialog;
    chklst_1: TCheckListBox;
    procedure btn_1Click(Sender: TObject);
    procedure mp_1Click(Sender: TObject; Button: TMPBtnType;
      var DoDefault: Boolean);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;implementation{$R *.dfm}procedure TForm1.btn_1Click(Sender: TObject);
var
  i:Integer;
begin
  if OD_1.Execute then
    begin
      mp_1.AutoEnable:=False;
      chklst_1.Items:=OD_1.Files;
      for i:=0 to chklst_1.Count-1 do
        begin
          chklst_1.Checked[i]:=True;
        end;
      mp_1.FileName:=chklst_1.Items[0];
      chklst_1.ItemIndex:=0;
      mp_1.Open;
      mp_1.Play;
      mp_1.EnabledButtons:=[btPause, btStop, btNext, btPrev, btStep, btBack];
    end;
end;procedure TForm1.mp_1Click(Sender: TObject; Button: TMPBtnType;
  var DoDefault: Boolean);
begin
  case Button of
    btPlay  :
      begin
        mp_1.Play;
        mp_1.EnabledButtons:=[btPause, btStop, btNext, btPrev, btStep, btBack];
      end;
    btPause :
      begin
        if mp_1.Mode=mpPaused then
        begin
          mp_1.Play;
          mp_1.EnabledButtons:=[btPause, btStop, btNext, btPrev, btStep, btBack];
        end
        else if mp_1.Mode=mpPlaying then
        begin
          mp_1.Pause;
          mp_1.EnabledButtons:=[btPlay, btPause, btStop, btNext, btPrev, btStep, btBack];
        end;
      end;
    btStop  :
      begin
        mp_1.Stop;
        mp_1.EnabledButtons:=[btPlay, btNext, btPrev, btStep, btBack];
      end;
    btNext  :
      begin
        mp_1.Close;
        chklst_1.itemindex:=chklst_1.itemindex+1;
        mp_1.FileName:=chklst_1.Items[chklst_1.itemindex];
        mp_1.Open;
        mp_1.Play;
        mp_1.Notify:=True;
        mp_1.EnabledButtons:=[btPause, btStop, btNext, btPrev, btStep, btBack];
      end;
    btPrev  :
      begin
        mp_1.Close;
        chklst_1.itemindex:=chklst_1.itemindex-1;
        mp_1.FileName:=chklst_1.Items[chklst_1.itemindex];
        mp_1.Open;
        mp_1.Play;
        mp_1.Notify:=True;
        mp_1.EnabledButtons:=[btPlay, btNext, btPrev, btStep, btBack];      end;
    btStep  :
      begin
        mp_1.Step;
        mp_1.EnabledButtons:=[btPlay, btNext, btPrev, btStep, btBack];
      end;
    btBack  :
      begin
        mp_1.Back;
        mp_1.EnabledButtons:=[btPlay, btNext, btPrev, btStep, btBack];
      end;
  end;end;end.

解决方案 »

  1.   

    再next按钮响应事件里再调用一次paly
      

  2.   

        btNext  : 
          begin 
            mp_1.Close; 
            chklst_1.itemindex:=chklst_1.itemindex+1; 
            mp_1.FileName:=chklst_1.Items[chklst_1.itemindex]; 
            mp_1.Open; 
            mp_1.Play; 
            mp_1.Notify:=True; 
            mp_1.EnabledButtons:=[btPause, btStop, btNext, btPrev, btStep, btBack]; 
          end; 
    应该没有问题啊 ? 没看到
    你可以先象楼上说的一样.先调用一下
      

  3.   

    代码里不是有
    btNext  : 
          begin 
            mp_1.Close; 
            chklst_1.itemindex:=chklst_1.itemindex+1; 
            mp_1.FileName:=chklst_1.Items[chklst_1.itemindex]; 
            mp_1.Open; 
            mp_1.Play; 
            mp_1.Notify:=True; 
            mp_1.EnabledButtons:=[btPause, btStop, btNext, btPrev, btStep, btBack]; 
          end; 
    你跟跟看呢。要不直接用tbutton来试,不要用控件自带的功能
      

  4.   

    怎么再次调用?mp控件只有整体的响应事件,就是onclick,然后按照value去运行啊,就像
    btNext  : 
          begin 
            mp_1.Close; 
            chklst_1.itemindex:=chklst_1.itemindex+1; 
            mp_1.FileName:=chklst_1.Items[chklst_1.itemindex]; 
            mp_1.Open; 
            mp_1.Play; 
            mp_1.Notify:=True; 
            mp_1.EnabledButtons:=[btPause, btStop, btNext, btPrev, btStep, btBack]; 
          end; 
    里面的mp_1.Play好像根本没有执行
      

  5.   

    我跟了一下,整个代码到
    procedure TForm1.mp_1Click(Sender: TObject; Button: TMPBtnType; 
      var DoDefault: Boolean); 
    begin 
      case Button of 
        btPlay  : 
          begin 
            mp_1.Play; 
            mp_1.EnabledButtons:=[btPause, btStop, btNext, btPrev, btStep, btBack]; 
          end; 
        btPause : 
          begin 
            if mp_1.Mode=mpPaused then 
            begin 
              mp_1.Play; 
              mp_1.EnabledButtons:=[btPause, btStop, btNext, btPrev, btStep, btBack]; 
            end 
            else if mp_1.Mode=mpPlaying then 
            begin 
              mp_1.Pause; 
              mp_1.EnabledButtons:=[btPlay, btPause, btStop, btNext, btPrev, btStep, btBack]; 
            end; 
          end; 
        btStop  : 
          begin 
            mp_1.Stop; 
            mp_1.EnabledButtons:=[btPlay, btNext, btPrev, btStep, btBack]; 
          end; 
        btNext  : 
          begin 
            mp_1.Close; 
            chklst_1.itemindex:=chklst_1.itemindex+1; 
            mp_1.FileName:=chklst_1.Items[chklst_1.itemindex]; 
            mp_1.Open; 
            mp_1.Play; 
            mp_1.Notify:=True; 
            mp_1.EnabledButtons:=[btPause, btStop, btNext, btPrev, btStep, btBack]; 
          end; 

        btPrev  : 
          begin 
            mp_1.Close; 
            chklst_1.itemindex:=chklst_1.itemindex-1; 
            mp_1.FileName:=chklst_1.Items[chklst_1.itemindex]; 
            mp_1.Open; 
            mp_1.Play; 
            mp_1.Notify:=True; 
            mp_1.EnabledButtons:=[btPlay, btNext, btPrev, btStep, btBack];       end; 
        btStep  : 
          begin 
            mp_1.Step; 
            mp_1.EnabledButtons:=[btPlay, btNext, btPrev, btStep, btBack]; 
          end; 
        btBack  : 
          begin 
            mp_1.Back; 
            mp_1.EnabledButtons:=[btPlay, btNext, btPrev, btStep, btBack]; 
          end; 
      end; end;
    在红色代码这里运行还是正常的,在单步跳到绿色代码的地方时,出现了下一首歌的声音,是重复的一秒钟左右的声音,这说明应该歌已经开始正常播放了。可是再跳一步结束时,歌就没有再放了,很奇怪 
      

  6.   

    不知道具体冲突在哪里,上一步是好的,跳下一步end就没有了,都不知道错在哪里
      

  7.   

    编译好后运行还是一样的结果,按NEXT没有反应