Some refactoring for media player