在Android上我收到此错误public async Task<string> GetTrackDuration(string pathToFile)
{
MediaMetadataRetriever reader = new MediaMetadataRetriever();
await reader.SetDataSourceAsync (global::Android.App.Application.Context, Android.Net.Uri.Parse (pathToFile));
return reader.ExtractMetadata(MetadataKey.Duration).ToString();
}
:
at /Users/builder/data/lanes/2058/58099c53/source/mono/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo中的System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()[0x0000b]。 CS:61 在/Users/builder/data/lanes/2058/58099c53/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs中的System.Runtime.CompilerServices.AsyncMethodBuilderCore.m__0(object)[0x00000]: 1006 在Android.App.SyncContext / c__AnonStorey0。&lt;&gt; m__0()[0x00000] /Users/builder/data/lanes/2058/58099c53/source/monodroid/src/Mono.Android/src/Android.App/SyncContext的.cs:18 at Java.Lang.Thread / RunnableImplementor.Run()[0x0000b] in /Users/builder/data/lanes/2058/58099c53/source/monodroid/src/Mono.Android/src/Java.Lang/Thread.cs:36 at Java.Lang.IRunnableInvoker.n_Run(intptr,intptr)[0x00009] in /Users/builder/data/lanes/2058/58099c53/source/monodroid/src/Mono.Android/platforms/android-21/src/generated/ Java.Lang.IRunnable.cs:71 at(wrapper dynamic-method)object.7dac782f-30e4-45cb-a248-e0c4c79fbcad(intptr,intptr)
---托管异常堆栈跟踪结束--- java.lang.IllegalArgumentException at dalvik.system.NativeStart.run(原生方法)中的android.media.MediaMetadataRetriever.setDataSource(MediaMetadataRetriever.java:169)
使用此代码来检索* .mp3文件的持续时间:
0.2
.1243
1.
-0.34
+033.98274E-10
-.1e+004
问题在哪里?我已经尝试了所有可能的构造函数