读取音频文件时出错? [英] Error when reading audio file?

查看:340
本文介绍了读取音频文件时出错?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我试图用它来确定一个MP3文件的长度以下功能:

I have the following function that I am attempting to use to determine the length of an MP3 file:

public static string GetMP3DurationBackup(string Filename)
{
    string Duration = null;
    WMPLib.WindowsMediaPlayer w = new WMPLib.WindowsMediaPlayer();
    WMPLib.IWMPMedia m = w.newMedia(Filename);
    if (m != null)
    {
        Duration = m.durationString;
    }
    w.close();
    return Duration;
}

我遇到了在那里我得到以下错误的问题:

I have run into an issue where I get the following error:

检索COM类工厂组件具有CLSID   {6BF52A52-394A-11D3-B153-00C04F79FAA6}失败由于以下   错误:80040154。

Retrieving the COM class factory for component with CLSID {6BF52A52-394A-11D3-B153-00C04F79FAA6} failed due to the following error: 80040154..

当我打电话从我的web应用程序的上述功能(拨打以下):

when I call the above function from my web application (call below):

string test = MediaUtil.GetMP3DurationBackup(@"C:\Temp\Audio\bad.mp3");

但是,当我从一个控制台应用程序测试工具,我创建(如上面完全相同的调用)调用它,它工作正常。我已经设置了包含函数为目标的x86在Build性质的项目,但是这并没有解决问题。

But when I call it from a console application test harness I created (exact same call as above) it works fine. I have set the project that contains the function to target x86 in the Build properties, but that did not fix the issue.

没有人知道为什么会发生这种情况?就从哪里开始调试此建议?

Does anyone know why this would happen? Suggestions on where to start to debug this?

更新的恩赐:

好吧,我已经尝试了一些东西,但我仍然收到此错误。在其他的事情我已经试过下面,我认为是最有前途的步骤,但没有骰子:

Ok, I've tried a number of things but I am still getting this error. Among other things I have tried the steps below which I felt were the most promising, but no dice:

  1. 走进我的注册表,并证实在该值: <$c$c>HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{6BF52A52-394A-11d3-B153-00C04F79FAA6}\InprocServer32 是指的 C:\ WINDOWS \ Syswow64资料\ wmp.dll文件
  2. 打开命令提示符, 导航到C:\ WINDOWS \ SysWow64文件,运行: regsvr32.exe的wmp.dll文件
  1. Went into my registry and confirmed that the value at: HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{6BF52A52-394A-11d3-B153-00C04F79FAA6}\InprocServer32 is refering to C:\WINDOWS\SysWOW64\wmp.dll
  2. Opened command prompt, navigated to C:\WINDOWS\SysWow64, ran: regsvr32.exe wmp.dll

我创建了一个控制台应用程序的测试工具,我能够当我运行在64位的测试项目,以重现错误。如果我切换到x86的正常工作。

I have created a console app test harness and I am able to reproduce the error if I run the test project in x64. If I switch it to x86 it works fine.

有没有人有,为什么上面会不会解决这个问题的任何想法?建议在哪里寻找下一个?

Does anyone have any idea of why the above would not resolve the issue? Suggestions on where to look next?

推荐答案

您说不能在64位工作,但你尝试注册了32位版本的Wmp.dll的( C: \的Windows \ SysWow64文件包含32位的程序集)。

You say it doesn't work in x64, but you try to register the 32-bit version of wmp.dll (C:\Windows\SysWow64 contains 32-bit assemblies).

尝试注册x64版本的Wmp.dll的,它位于 C:\ Windows \ System32下在64位平台

Try to register the x64 version of wmp.dll, which is located in C:\Windows\System32 on a 64-bit platform.

如果你没有这个文件,那么就可能没有64位的Windows Media Player可用于您的平台。但是有一个解决方法:

If you don't have this file then there probably is no 64bit Windows Media Player available for your platform. But there is a workaround:

创建一个32位控制台应用程序,采用的MP3文件名作为命令行参数和输出时间使用到stdout Console.WriteLine ,然后在Web应用程序,调用控制台应用程序,并捕获像<一个输出href="http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.redirectstandardoutput.aspx"相对=nofollow>这个例子在MSDN

Create a 32-bit console application that takes the mp3 filename as command line argument and outputs the duration to stdout using Console.WriteLine, then in the webapp, you call the console application and capture the output like in this example on MSDN

这篇关于读取音频文件时出错?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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