MediaSwitcher:refactory the code