我怎样可以暂停使用C#的MP3文件? [英] How can I pause an MP3 file using C#?

查看:178
本文介绍了我怎样可以暂停使用C#的MP3文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个类我在一个网站上找到:

I have this class I found in a website:

class MP3Handler
{
    private string _command;
    private bool isOpen;
    [DllImport("winmm.dll")]

    private static extern long mciSendString(string strCommand, StringBuilder strReturn, int iReturnLength, IntPtr hwndCallback);

    public void Close()
    {
        _command = "close MediaFile";
        mciSendString(_command, null, 0, IntPtr.Zero);
        isOpen = false;
    }

    public void Open(string sFileName)
    {
        _command = "open \"" + sFileName + "\" type mpegvideo alias MediaFile";
        mciSendString(_command, null, 0, IntPtr.Zero);
        isOpen = true;
    }

    public void Play(bool loop)
    {
        if (isOpen)
        {
            _command = "play MediaFile";
            if (loop)
                _command += " REPEAT";
            mciSendString(_command, null, 0, IntPtr.Zero);
        }
    }
}

时有停止和播放的方法。我想知道如果任何人都熟悉WINMM.DLL库。我怎样可以暂停歌曲,因为它的演奏,然后从它暂停的地方继续?

Is has the methods for STOP and PLAY. I was wondering if anyone is familiar with the winmm.dll library. How can I pause the song as it's playing and then continue from where it was paused?

推荐答案

$ C $的CProject文章包含它处理的WINMM.DLL库的功能,​​包括暂停5月,并可能是这一点,并在未来有帮助的一类。

This CodeProject article contains a class which handles may of the functions of the winmm.dll library, including pause, and may be helpful for this and in the future.

基本code,却是:

    _command = "pause MediaFile";
    mciSendString(_command, null, 0, IntPtr.Zero);

这篇关于我怎样可以暂停使用C#的MP3文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆