Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用WndProc和mciSendString确定音频文件是否已到达其结尾_C# - Fatal编程技术网

C# 使用WndProc和mciSendString确定音频文件是否已到达其结尾

C# 使用WndProc和mciSendString确定音频文件是否已到达其结尾,c#,C#,我正在尝试创建一个简单的媒体播放器,现在我可以播放一首歌曲并加载多首歌曲来创建播放列表,问题是当一首歌曲结束时,程序将无法继续播放下一首歌曲 public void Play(int songNumber, Form f) { Load(Songs[songNumber]); string Command = "play MediaFile notify"; mciSendString(Command, nu

我正在尝试创建一个简单的媒体播放器,现在我可以播放一首歌曲并加载多首歌曲来创建播放列表,问题是当一首歌曲结束时,程序将无法继续播放下一首歌曲

    public void Play(int songNumber, Form f)
    {
            Load(Songs[songNumber]);
            string Command = "play MediaFile notify";
            mciSendString(Command, null, 0, f.Handle);
    }

    private void PlayBtn_Click(object sender, EventArgs e)
    {
        int length = AudioPlayer.PlaylistLength;
        for (int PlayLoopcnt = 0; PlayLoopcnt < length;)
        {
            Player.Play(PlayLoopcnt, this);
        }
    }

    protected override void WndProc(ref Message m)
    {
        if(m.Msg == MM_MCINOTIFY)
        {
            PlayLoopcnt++;
        }
        base.WndProc(ref m); 
   }
public void Play(int songNumber,Form f)
{
加载(歌曲[歌曲编号]);
string命令=“播放媒体文件通知”;
mciSendString(命令,null,0,f.Handle);
}
私有void PlayBtn_单击(对象发送方,事件参数e)
{
int length=AudioPlayer.playlinglength;
对于(int PlayLoopcnt=0;PlayLoopcnt
我有一个AudioPlayer类,它处理amedia播放器的所有方法,如play、stop等


WndProc位于表单代码中,如果有人能指出我做错了什么,如果这是正确的方法,我会很高兴。

单击事件处理程序是错误的,它不能使用for循环。相反,它需要将PlayLoopcnt设置为0,并且只启动第一首歌曲。然后WndProc需要像它一样递增,并调用Play(),以便激活下一首歌曲。这很有效,谢谢!