moved mplayer initialization to function