Esempio n. 1
0
    def __init__(self):
        self.__termination = threading.Event()
        self.__rds_ctl = config.get_rds_ctl()

        if platform.machine() == "x86_64":
            self.__output = print
        else:
            self.__output = self.write_rds_to_pipe

        self.__interval = int(config.get_settings()["RDS"]["updateInterval"])
        self.__step = int(config.get_settings()["RDS"]["charsJump"])
Esempio n. 2
0
    def __init__(self):
        super().__init__()
        signal.signal(signal.SIGUSR1, self.handler)
        signal.signal(signal.SIGINT, self.termination_handler)
        self.remote_msg = dict()
        self.remotes_termination = threading.Event()
        self.remote_event = threading.Event(
        )  # Event for signaling control thread(s) events to main thread
        self.reply_event = threading.Event()
        self.control_pipe = ControlPipe(self.remote_event, self.remote_msg)
        self.bt_remote = BtRemote(self.remote_event, self.remote_msg)

        # TODO: maybe refractor into player_methods and always eval()?
        self.media_control_methods = [
            f for f in dir(MediaControl)
            if not f.startswith('_') and callable(getattr(MediaControl, f))
        ]
        self.media_info_methods = [
            f for f in dir(MediaInfo)
            if not f.startswith('_') and callable(getattr(MediaInfo, f))
        ]
        self.player = StoragePlayer()
        self.encoder = Encoder()

        if config.get_settings()["PIRATERADIO"]["output"] == "fm":
            self.output = FmOutput()
        else:
            self.output = AnalogOutput()
Esempio n. 3
0
    def __next__(self):
        if len(self.__queued) > 0:
            idx = len(self.__queued) - 1
            # pop a random song according to settings.
            # Unless another song must be resumed from previous boot
            if config.get_settings(
            )["PLAYLIST"]["shuffle"] == "true" and not self.__noshuffle:
                idx = randint(0, len(self.__queued) - 1)
            self.__noshuffle = False
            self.__current = self.__queued.pop(idx)
            self.__played.append(self.__current)
        else:
            self.__queued = self.__ms.scan()
            try:
                self.__current = self.__queued.pop(
                )  # TODO: handle the "no songs" scenario
            except IndexError:
                print("ERR: No songs to play")
                return None
            self.__played.append(self.__current)

        # print("\n\nplaylist:", [song["path"] for song in self.__queued], "\n")
        # print("played:", [song["path"] for song in self.__played], "\n\n")
        self.save_playlist()

        return self.__current
Esempio n. 4
0
    def __init__(self):
        signal.signal(signal.SIGUSR1, self.handler)
        signal.signal(signal.SIGINT, self.termination_handler)
        self.remote_msg = dict()
        self.check_remotes_termination = threading.Event()
        self.remote_event = threading.Event(
        )  # Event for signaling control thread(s) events to main thread
        self.control_pipe = ControlPipe(self.remote_event, self.remote_msg)
        # Bluetooth setup (only if a2dp is supported)
        # if which("bluealsa") is not None:
        #     self.bt_daemon = BluetoothDaemon()

        # TODO: maybe refractor into player_methods end always eval()?
        self.media_control_methods = [
            f for f in dir(MediaControl)
            if not f.startswith('_') and callable(getattr(MediaControl, f))
        ]
        self.media_info_methods = [
            f for f in dir(MediaInfo)
            if not f.startswith('_') and callable(getattr(MediaInfo, f))
        ]
        self.player = StoragePlayer()
        self.encoder = Encoder()

        if config.get_settings()["PIRATERADIO"]["output"] == "fm":
            self.output = FmOutput()
        else:
            self.output = AnalogOutput()
Esempio n. 5
0
 def __init__(self):
     super().__init__()
     self.__frequency = config.get_settings()["PIRATERADIO"]["frequency"]
     self.__rds_ctl = config.get_rds_ctl()
     try:
         os.mkfifo(self.__rds_ctl)
     except FileExistsError:
         pass
Esempio n. 6
0
 def __load_settings(self):
     self.__frequency = config.get_settings()["PIRATERADIO"]["frequency"]
     self.__rds_ctl = config.get_rds_ctl()
     try:
         os.remove(self.__rds_ctl)
     except FileNotFoundError:
         pass
     try:
         os.mkfifo(self.__rds_ctl)
     except FileExistsError:
         pass
Esempio n. 7
0
 def check_reload(self):
     if self.__frequency != config.get_settings()["PIRATERADIO"]["frequency"]:
         self.reload()
Esempio n. 8
0
 def __set_treble(self):
     treble = config.get_settings()["PIRATERADIO"]["treble"]
     if treble != "0":
         self.__sox_cmd.extend(["treble", treble])