【问题标题】:Windows Phone Dev: Play internal mp3 files with winmm.dllWindows Phone 开发:使用 winmm.dll 播放内部 mp3 文件
【发布时间】:2014-04-24 10:12:21
【问题描述】:

我需要有关执行 mp3 播放器文件的帮助。我在互联网上搜索,发现只有在需要从外部目录获取 mp3 文件时如何使用 winmm.dll 库。我需要为我的应用程序的内部目录修改它。

让我们展示一下代码:

我这样创建 Mp3Player 类:

class Mp3Player : IDisposable 
{
    [DllImport("winmm.dll")]
    private static extern long mciSendString(string lpstrCommand, StringBuilder lpstrReturnString, int uReturnLength, int hwndCallback);

    public void open(string file)
    {
        const string FORMAT = @"open ""{0}"" type MPEGVideo alias MyMp3";
        string command = String.Format(FORMAT, file);
        mciSendString(command, null, 0, 0);
    }

    public void play()
    {
        string command = "play MyMp3";
        mciSendString(command, null, 0, 0);
    }

    public void stop()
    {
        string command = "stop MyMp3";
        mciSendString(command, null, 0, 0);
    }

    public void Dispose()
    {
        string command = "close MyMp3";
        mciSendString(command, null, 0, 0);
    }

    public double Duration()
    {
        string command = "status MyMp3 length";
        double bho = mciSendString(command, null, 0, 0);
        return bho;
    }

并要求在此处打开内部文件:

var soundfile = "Assets/audio/myaudio.mp3";
private Mp3Player _mp3player = new Mp3Player();
_mp3player.open(soundfile);
_mp3player.play();

这在打开文件时给我一个错误,所以我确定问题出在我发送给班级的目录路径中。我尝试了一些版本,但没有人工作,在互联网上找不到任何帮助我的东西。你们中的一些人可以告诉我使工作发挥作用的正确途径吗?

非常感谢大家。

对不起,我的英语真的很糟糕。

【问题讨论】:

    标签: c# windows-phone-8 mp3 winmm


    【解决方案1】:

    根据Windows Mobile上的this forum,所有波形音频功能都在'coredll.dll'中实现。使用此 DLL 而不是“winmm.dll”。

    【讨论】:

    • 我尝试改变它,但我仍然认为问题出在我写的路径上:“Assets/audio/myaudio.mp3”,你知道正确的使用路径吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多