A function $y = f ( x )$ satisfies $f ( x ) \sin 2 x + \sin x - \left( 1 + \cos ^ { 2 } x \right) f ^ { \prime } ( x ) = 0$ with condition $f ( 0 ) = 0$. Then $f \left( \frac { \pi } { 2 } \right)$ is equal to\\ (1) 1\\ (2) 0\\ (3) - 1\\ (4) 2