reduce JS duplication in media player