def play_media(hass, media_type, media_id, entity_id=None):
    data = {ATTR_MEDIA_CONTENT_TYPE: media_type,
            ATTR_MEDIA_CONTENT_ID: media_id}

    if entity_id:
        data[ATTR_ENTITY_ID] = entity_id

    hass.services.call(DOMAIN, SERVICE_PLAY_MEDIA, data)
Send the media player the command for playing media.
dataset/ETHPy150Open home-assistant/home-assistant/homeassistant/components/media_player/__init__.py/play_media