Add code for media pattern and events.