How to detect when a mp3 file has finished playing

前端 未结 4 841
旧时难觅i
旧时难觅i 2020-12-10 13:34

My c# windows form is enable to play an mp3 file.I did this using this code

    WMPLib.WindowsMediaPlayer wplayer;
    wplayer = new WMPLib.WindowsMediaPlaye         


        
4条回答
  •  萌比男神i
    2020-12-10 13:59

    You can check it constantly with a Thread however, there is little documentation...

        //player .playState
        //Possible Values
        //
        //This property is a read-only Number (long). The C-style enumeration constant can be derived by prefixing 
        //the state value with "wmpps". For example, the constant for the Playing state is wmppsPlaying.
        //Value State Description
        //0     Undefined       Windows Media Player is in an undefined state.
        //1     Stopped         Playback of the current media item is stopped.
        //2     Paused          Playback of the current media item is paused. When a media item is paused, resuming playback begins from the same location.
        //3     Playing         The current media item is playing.
        //4     ScanForward     The current media item is fast forwarding.
        //5     ScanReverse     The current media item is fast rewinding.
        //6     Buffering       The current media item is getting additional data from the server.
        //7     Waiting         Connection is established, but the server is not sending data. Waiting for session to begin.
        //8     MediaEnded      Media item has completed playback.
        //9     Transitioning   Preparing new media item.
        //10    Ready           Ready to begin playing.
        //11    Reconnecting    Reconnecting to stream.
    

提交回复
热议问题