volume_manager.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:audio_file_player 作者: uts-magic-lab 项目源码 文件源码
def get_current_volume(self):
        cmd = ShellCmd(self.base_get_cmd)
        while not cmd.is_done() and not rospy.is_shutdown():
            rospy.sleep(0.1)
        output = cmd.get_stdout()
        rospy.logdebug("self.base_get_cmd output: " + str(output))
        # Output looks like:
        # Simple mixer control 'Master',0
        # Capabilities: pvolume pvolume-joined pswitch pswitch-joined
        # Playback channels: Mono
        # Limits: Playback 0 - 87
        # Mono: Playback 44 [51%] [-32.25dB] [on]

        pct_idx = output.index('%')
        # At most 3 characters of 100%
        pct_text = output[pct_idx - 3:pct_idx]
        # Remove [ if it was less than 3 chars
        pct_text = pct_text.replace('[', '')
        # Remove spaces if it was less than 2 char
        pct_text = pct_text.strip()
        curr_vol = int(pct_text)
        return curr_vol
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号