refactor of MediaPlayer.js