We investigate a continuous Heisenberg spin chain equation which models the local magnetization in ferromagnet with time- and site-dependent inhomogeneous bilinear interaction and time-dependent spin-transfer torque. By establishing the gauge equivalence between the spin chain equation and an integrable generalized nonlinear Schrödinger equation, we present explicitly a novel nonautonomous magnetic soliton solution for the spin chain equation. The results display how the dynamics of the magnetic soliton can be controlled by the bilinear interaction and spin-polarized current. Especially, we find that the site-dependent bilinear interaction may break some conserved quantity, and give rise to damping-like effect in the spin evolution.