MediaSwitcher:refactor the code