async def _send_command(self, command): resp = await self.protocol.send_and_receive(messages.command(command)) inner = resp.inner() if inner.errorCode != 0: raise exceptions.CommandError( "Command {0} failed: {1}, {2}".format( command, inner.errorCode, inner.handlerReturnStatus))
async def _send_command(self, command, **kwargs): resp = await self.protocol.send_and_receive(messages.command(command, **kwargs)) inner = resp.inner() if inner.sendError == protobuf.SendError.NoError: return raise exceptions.CommandError( f"{CommandInfo_pb2.Command.Name(command)} failed: " f"SendError={protobuf.SendError.Enum.Name(inner.sendError)}, " "HandlerReturnStatus=" f"{protobuf.HandlerReturnStatus.Enum.Name(inner.handlerReturnStatus)}" )
def previous(self): """Press key previous.""" return self.protocol.send( messages.command(CommandInfo_pb2.PreviousTrack))
def next(self): """Press key next.""" return self.protocol.send(messages.command(CommandInfo_pb2.NextTrack))
def stop(self): """Press key stop.""" return self.protocol.send(messages.command(CommandInfo_pb2.Stop))
def pause(self): """Press key play.""" return self.protocol.send(messages.command(CommandInfo_pb2.Pause))