from devices.device import Device
from devices.audio_logging import AudioLogger

from pydub.audio_segment import AudioSegment
import pydub.playback as playback


class Speakers(Device):

    _audio_logger = AudioLogger()

    def update(self, data):
        super().update(data)
        if data:
            self.play(data)

    def play(self, file_name):
        playback.play(AudioSegment.from_mp3(file_name))
