0

I try to use some methods of http://doc.aldebaran.com/2-5/naoqi/audio/alaudioplayer-api.html

But the terminal tells me that most of them don't work.

# -*- encoding: UTF-8 -*-

import sys
import time
from naoqi import *

IP = "127.0.0.1"
PORT = 9559

try:
    aup = ALProxy("ALAudioPlayer", IP, PORT)
except Exception,e:
    print "Could not create proxy to ALAudioPlayer"
    print "Error was: ",e
    sys.exit(1)

#this line works. I can hear the music
fileId = aup.post.playFile("C:\VALIDPATH.wav")

#does not show most of the methods
print(aup.getMethodList())

time.sleep(1)

#this line does not work
currentPos = aup.getCurrentPosition(fileId)

The output :

['isStatsEnabled', 'enableStats', 'stats', 'clearStats', 'isTraceEnabled', 'enableTrace', 'exit', '__pCall', 'pCall', 'version', 'ping', getMethodList', 'getMethodHelp', 'getModuleHelp', 'wait', 'isRunning', 'stop', 'getBrokerName', 'getUsage', 'playFile', 'playFileInLoop', 'playFileFromPosition', 'pause']

Traceback (most recent call last): File "fggfgf.py", line 27, in currentPos = aup.getCurrentPosition(fileId) File "C:\Python27\lib\site-packages\naoqi.py", line 301, in call return self.wrapped.method_missing(self.method, *args, **kwargs) File "C:\Python27\lib\site-packages\naoqi.py", line 371, in method_missing raise e RuntimeError: ALAudioPlayer::getCurrentPosition Can't find method: getCurrentPosition (resolved to '(i)')

Abcdef GHI
  • 115
  • 2
  • 8

2 Answers2

1

The documentation you linked is a documentation for Naoqi 2.5, are you using a Naoqi 2.5 ?

If so I will say that ALProxy is deprecated and your code should more looks like this:

import qi

session = qi.Session()
try:
  session.connect(IP, PORT)
expect Exception e:
  print "Could not connect: %s" % e

try:
  audioplayer = session.service("ALAudioPlayer")
expect Exception e:
  print "Could not get service: %s" % e
  return

audioplayer.playFile(PATH) // synchrone
audioplayer.playFile(PATH, _async=True) // asynchrone

dir(audioplayer)
G. Vallat
  • 56
  • 3
0

You need to specify a file path that is on the robot. E.g. /data/home/nao/.local/share/PackageManager/apps/soundsetaldebaran/sfx_scanner.ogg"

Anders_K
  • 982
  • 9
  • 28