简体   繁体   English

如何知道音频在C#中播放是否完成?

[英]How to know if audio is done playing c#?

Is there any function to know if the audio is done playing? 有什么功能可以知道音频是否播放完毕? I want to do a function after the audio played, I have 2 ideas. 我想在音频播放后做一个功能,我有2个想法。 First if there is a function when audio is done, second is I will get the length of the audio and put it on the timer and set it on. 首先,如果完成音频后有功能,第二是获取音频的长度并将其放在计时器上并设置为打开。 Please help me to get either audio is done or audio"s time length thanks. 请帮助我完成音频或音频的时间长度。

You have to use AxWindowsMediaPlayer.playState property to know the status of the player. 您必须使用AxWindowsMediaPlayer.playState属性来了解播放器的状态。 Look at this: 看这个:

if (player.playState == WMPLib.WMPPlayState.wmppsPlaying)
{
    Console.WriteLine("Is playing!");
}
else
{
    Console.WriteLine("Is NOT playing!");
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM