当前位置: 首页>>代码示例>>Python>>正文


Python MPDClient.replay_gain_mode方法代码示例

本文整理汇总了Python中mpd.MPDClient.replay_gain_mode方法的典型用法代码示例。如果您正苦于以下问题:Python MPDClient.replay_gain_mode方法的具体用法?Python MPDClient.replay_gain_mode怎么用?Python MPDClient.replay_gain_mode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mpd.MPDClient的用法示例。


在下文中一共展示了MPDClient.replay_gain_mode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: myMPD

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import replay_gain_mode [as 别名]

#.........这里部分代码省略.........
                #                  "password commmand failed: %s" %
                #                  (self._host, e))
                #db.write_log_to_db_a(ac, "MPD-PW-Error: %s" % str(e), "x",
                #                             "write_also_to_console")
                return None

            # Catch all other possible errors
            except (MPDError, IOError) as e:
                #raise RunError("Could not connect to '%s': "
                #                  "error with password command: %s" %
                #                  (self._host, e))
                db.write_log_to_db_a(ac, "MPD-Error-2: %s" % str(e), "x",
                                             "write_also_to_console")
            return None

    def disconnect(self):
        # Try to tell MPD we're closing the connection first
        try:
            self._client.close()

        # If that fails, don't worry, just ignore it and disconnect
        except (MPDError, IOError):
            pass

        try:
            self._client.disconnect()

        # Disconnecting failed, so use a new client object instead
        # This should never happen.  If it does, something is seriously broken,
        # and the client object shouldn't be trusted to be re-used.
        except (MPDError, IOError):
            self._client = MPDClient()

    def exec_command(self, db, ac, command, value):
        """spread out exec commands"""
        result = None
        try:
            if command == "access":
                result = self.mpd_access(db, ac)
            if command == "play":
                result = self._client.play()
            if command == "update":
                result = self._client.update()
            if command == "song":
                result = self._client.currentsong()
            if command == "status":
                result = self._client.status()
            if command == "add":
                result = self._client.add(value)
            if command == "consume":
                result = self._client.consume(value)
            if command == "crossfade":
                result = self._client.crossfade(value)
            if command == "seek":
                result = self._client.seek(value)
            if command == "repeat":
                result = self._client.repeat(value)
            if command == "random":
                result = self._client.random(value)
            if command == "single":
                result = self._client.single(value)
            if command == "replay_gain_mode":
                result = self._client.replay_gain_mode(value)
            if command == "next":
                result = self._client.next()
            if command == "setvol":
                result = self._client.setvol(value)
            # via mpc-client
            if command == "crop":
                result = mpc_client(db, ac, "crop", value)
            if command == "vol":
                result = mpc_client(db, ac, "volume", value)
            # via os
            if command == "reload-1":
                result = run_cmd(db, ac, "killall", value)
            if command == "reload-2":
                result = run_cmd(db, ac, "mpd", value)
            return result

        # Couldn't get the current cmd, so try reconnecting and retrying
        except (MPDError, IOError) as e:
            # No error handling required here
            # Our disconnect function catches all exceptions, and therefore
            # should never raise any.
            error_msg = "MPD-Error-3: %s" % str(e)

            if value is not None:
                error_msg = error_msg + ", cmd: " + value
                #db.write_log_to_db_a(ac, "MPD-E-3 cmd-value: " + value, "x",
                #                             "write_also_to_console")
            if str(e) == "Not connected":
                error_msg = error_msg + ", try recon.:"
                db.write_log_to_db_a(ac, error_msg, "x",
                                                "write_also_to_console")
                self.connect(db, ac)
                self.exec_command(db, ac, command, value)
            else:
                db.write_log_to_db_a(ac, error_msg, "x",
                                                "write_also_to_console")
            return None
开发者ID:srb-fm,项目名称:admin-srb,代码行数:104,代码来源:lib_mpd.py


注:本文中的mpd.MPDClient.replay_gain_mode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。