Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def on_mode_changed(self, mode):
LOG.info('current play mode is %d.'
' 1 for single in loop, 3 for loop, 4 for random' % mode)
self._update_mode_icon()
def Next(self):
LOG.info('dbus: call play_next')
ControllerApi.player.play_next()
def keyboard_tap_callback(proxy, type_, event, refcon):
from AppKit import NSKeyUp, NSEvent, NSBundle
NSBundle.mainBundle().infoDictionary()['NSAppTransportSecurity'] =\
dict(NSAllowsArbitraryLoads=True)
if type_ < 0 or type_ > 0x7fffffff:
LOG.error('Unkown mac event')
run_event_loop()
LOG.error('restart mac key board event loop')
return event
try:
key_event = NSEvent.eventWithCGEvent_(event)
except:
LOG.info("mac event cast error")
return event
if key_event.subtype() == 8:
key_code = (key_event.data1() & 0xFFFF0000) >> 16
key_state = (key_event.data1() & 0xFF00) >> 8
if key_code in (16, 19, 20):
# 16 for play-pause, 19 for next, 20 for previous
if key_state == NSKeyUp:
if key_code is 19:
ControllerApi.player.play_next()
elif key_code is 20:
ControllerApi.player.play_last()
elif key_code is 16:
ControllerApi.player.play_or_pause()
return None
return event
def on_set_favorite_btn_clicked(cls, checked=True):
if not cls.controller.state["current_mid"]:
return False
data = cls.controller.api.set_music_to_favorite(cls.controller.state['current_mid'], checked)
cls.controller.desktop_mini.content.is_song_like = checked
if not cls.controller.api.is_response_ok(data):
ViewOp.ui.LOVE_SONG_BTN.setChecked(not checked)
cls.controller.desktop_mini.content.is_song_like = not checked
return False
playlist_detail = cls.controller.api.get_playlist_detail(cls.controller.api.favorite_pid, cache=False)
if not cls.controller.api.is_response_ok(playlist_detail):
ViewOp.ui.STATUS_BAR.showMessage("刷新 -喜欢列表- 失败")
return False
if cls.controller.state['current_pid'] == cls.controller.api.favorite_pid:
LOG.info("喜欢列表的歌曲发生变化")
ViewOp.ui.WEBVIEW.load_playlist(playlist_detail)
return True
def OpenUri(self, Uri):
LOG.info('dbus: call play open uri')