private static int GetAudioDuration(IntPtr L) { int result; try { ToLua.CheckArgsCount(L, 3); PlatformUtil platformUtil = (PlatformUtil)ToLua.CheckObject(L, 1, typeof(PlatformUtil)); string audioFile = ToLua.CheckString(L, 2); LuaTypes luaTypes = LuaDLL.lua_type(L, 3); Action <int> completeCallback; if (luaTypes != LuaTypes.LUA_TFUNCTION) { completeCallback = (Action <int>)ToLua.CheckObject(L, 3, typeof(Action <int>)); } else { LuaFunction func = ToLua.ToLuaFunction(L, 3); completeCallback = (DelegateFactory.CreateDelegate(typeof(Action <int>), func) as Action <int>); } platformUtil.GetAudioDuration(audioFile, completeCallback); result = 0; } catch (Exception e) { result = LuaDLL.toluaL_exception(L, e, null); } return(result); }