It is an easy question about integral,but I need your help. How to compute this integral?

$$ \int^{\pi}_{0} \frac{\sin(nx)\cos\left ( \frac{x}{2} \right )}{\sin \left ( \frac{x}{2} \right ) } \, dx$$

I need your help.
 A: There are many ways to do this. Here is one way out. Let $$I(n) = \int_0^{\pi} \dfrac{\sin(nx) \cos(x/2)}{\sin(x/2)}dx$$
We then have
\begin{align}
I(n+1) - I(n) & = \int_0^{\pi}\dfrac{(\sin((n+1)x) - \sin(nx))\cos(x/2)}{\sin(x/2)}dx\\
& = 2\int_0^{\pi} \dfrac{\sin(x/2) \cos((n+1/2)x) \cos(x/2)}{\sin(x/2)}dx\\
& = \int_0^{\pi} 2 \cos((n+1/2)x) \cos(x/2) dx\\
& = \int_0^{\pi} \left(\cos((n+1)x) + \cos(nx)\right)dx \tag{$\star$}
\end{align}
$(\star)$ gives us
$$I(n+1)-I(n) = \begin{cases} 0 & \text{if } n \in \mathbb{Z}^+\\ \int_0^{\pi}\left( \cos(x) + 1\right)dx = \pi & \text{if }n = 0\end{cases} \tag{$\dagger$}$$
Further, we have $I(0) = 0$. Hence, $(\dagger)$ gives us $I(1) - I(0) = \pi \implies I(1) = \pi$ and thereby
$$I(n) = \pi, \,\,\, \forall n \in \mathbb{Z}^+$$
A: Hint:
$\int_0^{\pi}\dfrac{\sin nx . \cos \dfrac{x}{2}}{\sin \dfrac{x}{2}}=\int_0^{\pi}\dfrac{\sin n(\pi -x) . \sin \dfrac{x}{2}}{\cos\dfrac{x}{2}}=1$
$\sin (n \pi-nx)=\sin n{\pi} \cos nx-\cos{n \pi}\sin{nx}= (-1)^{n+1}\sin nx$,
$2I=\int_0^{\pi}\dfrac{\sin nx}{\cos \dfrac{x}{2} \cdot \sin \dfrac{x}{2}}$, when $n \in$ Even
$2I= \int_0^ \pi \dfrac{\sin nx \cdot \cos x}{\cos \dfrac{x}{2} \cdot \sin \dfrac{x}{2}}$, when $n \in$ Odd.   Since we know $\cos^2\dfrac{x}{2}-\sin^2\dfrac{x}{2}=\cos x$
