本文整理汇总了Python中jsonrpclib.Server._request方法的典型用法代码示例。如果您正苦于以下问题:Python Server._request方法的具体用法?Python Server._request怎么用?Python Server._request使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jsonrpclib.Server
的用法示例。
在下文中一共展示了Server._request方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: xbmcControlPlayer
# 需要导入模块: from jsonrpclib import Server [as 别名]
# 或者: from jsonrpclib.Server import _request [as 别名]
def xbmcControlPlayer(action):
server = Server(xbmcMakeUrl() + '/jsonrpc')
if action == 'SetMute':
method = 'Application.SetMute'
data = server._request(methodname=method, params=['toggle'])
elif action == 'MoveLeft':
method = 'Player.MoveLeft'
data = server._request(methodname=method, params={'playerid' : 1, 'value' : 'smallbackward'})
elif action == 'MoveRight':
method = 'Player.MoveRight'
data = server._request(methodname=method, params={'playerid' : 1, 'value' : 'smallforward'})
else:
method = 'Player.' + action
data = server._request(methodname=method, params={'playerid' : 1})
return dumps(data)
示例2: ControlPlayer
# 需要导入模块: from jsonrpclib import Server [as 别名]
# 或者: from jsonrpclib.Server import _request [as 别名]
def ControlPlayer(self, action='', percent=''):
xbmc = Server(self.url('/jsonrpc', True))
player = xbmc.Player.GetActivePlayers()
if action == 'SetMute':
return xbmc.Application.SetMute(mute='toggle')
elif action == 'Back':
return xbmc.Input.Back()
elif action == 'Down':
return xbmc.Input.Down()
elif action == 'Home':
return xbmc.Input.Home()
elif action == 'Left':
return xbmc.Input.Left()
elif action == 'Right':
return xbmc.Input.Right()
elif action == 'Select':
return xbmc.Input.Select()
elif action == 'Up':
return xbmc.Input.Up()
elif action == 'MoveLeft':
return xbmc.Input.Left()
elif action == 'MoveRight':
return xbmc.Input.Right()
elif action == 'Seek':
try:
percent = float(percent)
return xbmc.Player.Seek(playerid=player[0][u'playerid'], value=percent)
except:
return
elif action:
try:
method = 'Player.'+action
return xbmc._request(methodname=method, params={'playerid' : player[0][u'playerid']})
except:
return
示例3: ControlPlayer
# 需要导入模块: from jsonrpclib import Server [as 别名]
# 或者: from jsonrpclib.Server import _request [as 别名]
def ControlPlayer(self, action='', percent=''):
""" Various commands to control XBMC Player """
self.logger.debug("Sending control to XBMC: " + action)
xbmc = Server(self.url('/jsonrpc', True))
player = xbmc.Player.GetActivePlayers()
if action == 'SetMute':
return xbmc.Application.SetMute(mute='toggle')
elif action == 'Back':
return xbmc.Input.Back()
elif action == 'Down':
return xbmc.Input.Down()
elif action == 'Home':
return xbmc.Input.Home()
elif action == 'Left':
return xbmc.Input.Left()
elif action == 'Right':
return xbmc.Input.Right()
elif action == 'Select':
return xbmc.Input.Select()
elif action == 'Up':
return xbmc.Input.Up()
elif action == 'MoveLeft':
return xbmc.Input.Left()
elif action == 'MoveRight':
return xbmc.Input.Right()
elif action == 'PlayNext':
try:
return xbmc.Player.GoTo(playerid=player[0][u'playerid'], to='next')
except:
self.logger.error("Unable to control XBMC with action: " + action)
return
elif action == 'PlayPrev':
try:
return xbmc.Player.GoTo(playerid=player[0][u'playerid'], to='previous')
except:
self.logger.error("Unable to control XBMC with action: " + action)
return
elif action == 'JumpItem':
try:
return xbmc.Player.GoTo(playerid=player[0][u'playerid'], to=int(percent))
except:
self.logger.error("Unable to control XBMC with action: " + action)
return
elif action == 'Seek':
try:
percent = float(percent)
return xbmc.Player.Seek(playerid=player[0][u'playerid'], value=percent)
except:
self.logger.error("Unable to control XBMC with action: " + action)
return
elif action:
try:
method = 'Player.' + action
return xbmc._request(methodname=method, params={'playerid': player[0][u'playerid']})
except:
self.logger.error("Unable to control XBMC with action: " + action)
return