Volume viscosity is one of the most important and fundamental parameters in hydrodynamics. It measures the momentum loss caused by a volume deformation but without shape deformation. So it has close association with numerous phenomena in fluid dynamics. Nevertheless, most of the existing relevant investigations focus on the bulk fluids, while deep understanding about the volume viscosity of inhomogeneous fluids is still demanding. In this work, a novel theoretical method is proposed for the inhomogeneous volume viscosity within the framework of Maxwell viscoelastic theory. In this proposal, the local relaxation time is first proposed and calculated with the aid of the viscous and elastic properties of the bulk fluids. Accordingly, the inhomogeneous volume viscosity can be obtained by combining the calculations of the local relaxation time and the local relaxation modulus. On the theoretical aspect, it is advantageous over the conventional LADM, since it takes into account the underlying correlation much better. On one hand, the local infinite-frequency modulus is more accurate. On the other hand, the correlation effect can be better considered by weight calculations with a proper weight function. As an application, the volume viscosity of the confined Lennard-Jones fluids in slit pores is investigated, and the influences of bulk density, temperature, pore width and adsorption strength are calculated and analyzed. The results suggest that these factors can significantly modulate the volume viscosity of the confined fluids. Specifically, the positive correlation between the volume viscosity and the local density leads to the oscillation of viscosity profile in the pore. Besides, the occurrence of capillary condensation in the cases of lower density and lower temperature makes the inhomogeneous viscosity rather different from that of bulk gaseous phase. Further, the study suggests that the inhomogeneous volume viscosity usually increases with the decrement of temperature, or with the increment of the adsorption strength. This is again the result of its dependence on the fluid structure in the pore. Furthermore, the influence of pore width on the inhomogeneous volume viscosity suggests that the excluded volume plays a decisive role. This can be attributed to the fact that it exerts a direct impact on the deformation of the fluids. Moreover, comparison between the volume and shear viscosities is also conducted and analyzed. In general, this study can be beneficial for deepening the understanding of volume viscosity in the confined fluids, and can provide reliable theoretical support for studying related issues in hydrodynamics.