<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def on_taskend(self, task):
 """ Play sounds at task end. """

        key = 'timer' if task.elapsed else 'end'
        filename = self.files.get(key)

        if filename:
            self._play_sound(filename)