本文整理汇总了Python中music.Music.clone方法的典型用法代码示例。如果您正苦于以下问题:Python Music.clone方法的具体用法?Python Music.clone怎么用?Python Music.clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类music.Music
的用法示例。
在下文中一共展示了Music.clone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from music import Music [as 别名]
# 或者: from music.Music import clone [as 别名]
class EventLoop:
def __init__(self):
self.window_manager = WindowManager()
self.events = Queue()
self.panel = Panel()
self.clock = Clock()
self.notification_monitor = NotificationMonitor()
try:
with open(os.path.expanduser('~/.config/mpd/credentials.conf'), 'r') as f:
mpd_settings = json.load(f)
except FileNotFoundError:
self.music = Music()
else:
self.music = Music(**mpd_settings)
self.music_controller = self.music.clone()
self.system_info = SystemInfo()
def start_thread(self, loop):
thread = threading.Thread(
target=loop,
kwargs={'events': self.events}
)
thread.daemon = True
thread.start()
return thread
def process_event(self, event):
if isinstance(event, PanelStrip):
self.panel.update(event)
elif isinstance(event, UserCommand):
try:
command = event.command.split()
if command[0] == 'music_pause':
self.music_controller.pause()
elif command[0] == 'music_stop':
self.music_controller.stop()
elif command[0] == 'music_home':
self.music_controller.seek(0)
elif command[0] == 'music_next':
self.music_controller.next()
elif command[0] == 'music_previous':
self.music_controller.previous()
elif command[0] == 'music_volume':
if command[1].startswith('+') or command[1].startswith('-'):
is_relative = True
else:
is_relative = False
self.music_controller.volume(int(command[1]), is_relative)
elif command[0] == 'notification_next':
self.notification_monitor.history_next(self.events)
except:
sys.stderr.write(
"failed executing command. details: \n" +
traceback.format_exc()
)
def loop(self):
self.window_manager_thread = self.start_thread(
self.window_manager.loop
)
self.clock_thread = self.start_thread(
self.clock.loop
)
self.system_info_thread = self.start_thread(
self.system_info.loop
)
self.music_thread = self.start_thread(
self.music.loop
)
self.notification_monitor_thread = self.start_thread(
self.notification_monitor.loop
)
self.panel.start()
while True:
self.process_event(self.events.get())