Volume viscosity is one of the most important and fundamental parameters in hydrodynamics. It measures the momentum loss caused by a volume deformation rather than shape deformation. So it is closely related to numerous phenomena in fluid dynamics. However, most of the existing related researches focus on the bulk fluids, but there is still a lack of in-depth understanding of the bulk viscosity of inhomogeneous fluids. In this work, a novel theoretical method is proposed for the inhomogeneous volume viscosity in the framework of Maxwell viscoelastic theory. In this proposal, the local relaxation time is calculated by using 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. It is advantageous in the theoretical sense over the conventional LADM, because it takes into account the underlying correlation much better. On the one hand, the local infinite-frequency modulus is more accurate. On the other hand, by using an appropriate weight function to calculate the weight, the correlation effect can be better considered . As an application, the volume viscosity of the confined Lennard-Jones fluid in slit pore is investigated, and the influences of bulk density, temperature, pore width and adsorption strength are calculated and analyzed. The results indicate that these factors can significantly modulate the volume viscosity of the confined fluid. 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, this study shows that the inhomogeneous volume viscosity usually increases with temperature decreasing, or with adsorption strength increasing. 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 indicates that the excluded volume plays a decisive role. This can be attributed to the fact that it exerts a direct influence on the deformation of the fluid. Moreover, comparison between the volume and shear viscosity is also conducted and analyzed. In general, this study can be beneficial to deepening the understanding of volume viscosity in the confined fluids, and can provide reliable theoretical support for studying related issues in hydrodynamics.