コード例 #1
0
ファイル: rds.py プロジェクト: morrolinux/mpradio-py
    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"])
コード例 #2
0
ファイル: mpradio.py プロジェクト: ikoydg/mpradio-py
    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()
コード例 #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
コード例 #4
0
ファイル: mpradio.py プロジェクト: Hurricos/mpradio-py
    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()
コード例 #5
0
ファイル: fm_output.py プロジェクト: Hurricos/mpradio-py
 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
コード例 #6
0
ファイル: fm_output.py プロジェクト: morrolinux/mpradio-py
 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
コード例 #7
0
ファイル: fm_output.py プロジェクト: morrolinux/mpradio-py
 def check_reload(self):
     if self.__frequency != config.get_settings()["PIRATERADIO"]["frequency"]:
         self.reload()
コード例 #8
0
 def __set_treble(self):
     treble = config.get_settings()["PIRATERADIO"]["treble"]
     if treble != "0":
         self.__sox_cmd.extend(["treble", treble])