我添加了一个线程用playsound播放一个res文件,但每次打开程序时,音乐都不能完整播放,总是到一定时候停了,这是怎么回事啊.各路老大帮帮忙.

解决方案 »

  1.   

    跟你播放参数设置有关系,估计你是采用异步方式播放声音文件。采用同步播放即可。
    SND_SYNC
      Synchronous playback of a sound event. PlaySound returns after the sound event completes.SND_ASYNC
      The sound is played asynchronously and PlaySound returns immediately after beginning the sound. To terminate an asynchronously played waveform sound, call PlaySound with pszSound set to NULL.
      

  2.   

    不行啊,playsound播放外部文件也是放到一部分就重放了,怎么回事啊,急死我了
      

  3.   

    封装个函数给你用用procedure PlayMusic(FileName: String; Loop: Boolean=TRUE);
    var
      tmp: PChar;
    begin
      if not FileExists(FileName) then Exit;
      tmp := PChar(FileName);
      try
        if not Loop then tmp := nil;
        PlaySound(tmp,0,SND_LOOP);
      except
      end;  
    end;如果想停掉播放,传参时,Loop设置成false即可。