def play(self, times=1, interval=0, callback=None):
        def play_cb(previous, current, err):
            #This is called first with EPlaying meaning that the playing started
            #and with EOpen meaning that the playing stopped.
            callback_error[0] = err
            if callback != None:
                if (current == EPlaying or current == EOpen):
                    lock.signal()
                callback(previous, current, err)
            elif (current == EPlaying
                  or current == EOpen) and callback == None:
                lock.signal()

        if self.state() != EOpen:
            raise RuntimeError, ("Sound not in correct state, state: %d" %
                                 (self.state()))
        lock = e32.Ao_lock()
        callback_error = [0]
        self._player.bind(play_cb)
        if not times == KMdaRepeatForever:
            times = times - 1
        self._player.play(times, interval)
        lock.wait()
        if callback_error[0]:
            raise SymbianError, (callback_error[0], "Error playing file: " +
                                 e32.strerror(callback_error[0]))
 def save(self,
          filename,
          callback=None,
          format=None,
          quality=75,
          bpp=24,
          compression='default'):
     if format is None:
         if filename.lower().endswith(
                 '.jpg') or filename.lower().endswith('.jpeg'):
             format = 'JPEG'
         elif filename.lower().endswith('.png'):
             format = 'PNG'
         else:
             raise ValueError(
                 'unrecognized suffix and format not specified')
     self._wait()
     lock = e32.Ao_lock()
     self._image.save(unicode(filename), self._callback, format,
                      quality, compression, bpp)
     # If the code above didn't raise an exception, this method
     # will succeed, so now it's safe to modify object state.
     self._usercallback = callback
     self._lock = lock
     if callback is None:
         self._wait()
         if self._errcode != 0:
             err = self._errcode
             self._errcode = 0
             raise SymbianError, (err, "Error saving image:" +
                                  e32.strerror(err))
Пример #3
0
 def open(filename):
     def finish_load(errcode):
         img._errcode=errcode
         lock.signal()
     lock=e32.Ao_lock()
     img=Image(_graphics.ImageOpen(unicode(filename),finish_load))
     lock.wait()        
     if img._errcode != 0:
         raise SymbianError,(img._errcode,
                             "Error loading image:"+e32.strerror(img._errcode))
     return img
Пример #4
0
 def open(filename):
     def finish_load(errcode):
         img._errcode=errcode
         lock.signal()
     lock=e32.Ao_lock()
     img=Image(_graphics.ImageOpen(unicode(filename),finish_load))
     lock.wait()        
     if img._errcode != 0:
         raise SymbianError,(img._errcode,
                             "Error loading image:"+e32.strerror(img._errcode))
     return img
Пример #5
0
 def load(self,filename,callback=None):
     self._wait()
     self._filename=unicode(filename)
     self._usercallback=callback
     self._lock=e32.Ao_lock()
     self._image.load(self._filename,self._callback)
     if callback is None:
         self._wait()
         if self._errcode != 0:
             err=self._errcode
             self._errcode=0
             raise SymbianError,(err, "Error loading image:"+e32.strerror(err))
    def from_buffer(buffer, mime="image/jpeg", ignore_errors=True):
        def finish_load(errcode):
            img._errcode = errcode
            lock.signal()

        lock = e32.Ao_lock()
        img = Image(_graphics.ImageFromBuffer(buffer, mime, finish_load))
        lock.wait()
        if not ignore_errors and img._errcode != 0:
            raise SymbianError, (img._errcode, "Error loading image:" +
                                 e32.strerror(img._errcode))
        return img
Пример #7
0
 def load(self,filename,callback=None):
     self._wait()
     self._filename=unicode(filename)
     self._usercallback=callback
     self._lock=e32.Ao_lock()
     self._image.load(self._filename,self._callback)
     if callback is None:
         self._wait()
         if self._errcode != 0:
             err=self._errcode
             self._errcode=0
             raise SymbianError,(err, "Error loading image:"+e32.strerror(err))
Пример #8
0
Файл: audio.py Проект: pymo/pymo
 def _say(text):
     def say_cb(previous, current, err):
         callback_error[0]=err
         lock.signal()
     player=Sound()
     lock=e32.Ao_lock()
     callback_error=[0]
     player._player.bind(say_cb)
     player._player.say(text)
     lock.wait()
     if callback_error[0]:
         raise SymbianError,(callback_error[0],
                             "Error: "+e32.strerror(callback_error[0]))
Пример #9
0
 def record(self):
     def rec_cb(previous, current, err):
         callback_error[0]=err
         lock.signal()
     if self.state()!=EOpen:
         raise RuntimeError,("Sound not in correct state, state: %d" % (self.state()))
     lock=e32.Ao_lock()
     callback_error=[0]
     self._player.bind(rec_cb)
     self._player.record()
     lock.wait()
     if callback_error[0]:
         raise SymbianError,(callback_error[0],
                             "Error while recording: "+e32.strerror(callback_error[0]))
Пример #10
0
Файл: audio.py Проект: pymo/pymo
 def record(self):
     def rec_cb(previous, current, err):
         callback_error[0]=err
         lock.signal()
     if self.state()!=EOpen:
         raise RuntimeError,("Sound not in correct state, state: %d" % (self.state()))
     lock=e32.Ao_lock()
     callback_error=[0]
     self._player.bind(rec_cb)
     self._player.record()
     lock.wait()
     if callback_error[0]:
         raise SymbianError,(callback_error[0],
                             "Error while recording: "+e32.strerror(callback_error[0]))
Пример #11
0
Файл: audio.py Проект: pymo/pymo
 def open(filename):
     def open_cb(previous, current, err):
         callback_error[0]=err
         lock.signal()
     player=Sound()
     lock=e32.Ao_lock()
     callback_error=[0]
     player._player.bind(open_cb)
     player._player.open_file(unicode(filename))
     lock.wait()
     if callback_error[0]:
         raise SymbianError,(callback_error[0],
                             "Error opening file: "+e32.strerror(callback_error[0]))
     return player
Пример #12
0
 def open(filename):
     def open_cb(previous, current, err):
         callback_error[0]=err
         lock.signal()
     player=Sound()
     lock=e32.Ao_lock()
     callback_error=[0]
     player._player.bind(open_cb)
     player._player.open_file(unicode(filename))
     lock.wait()
     if callback_error[0]:
         raise SymbianError,(callback_error[0],
                             "Error opening file: "+e32.strerror(callback_error[0]))
     return player
    def _say(text):
        def say_cb(previous, current, err):
            callback_error[0] = err
            lock.signal()

        player = Sound()
        lock = e32.Ao_lock()
        callback_error = [0]
        player._player.bind(say_cb)
        player._player.say(text)
        lock.wait()
        if callback_error[0]:
            raise SymbianError, (callback_error[0],
                                 "Error: " + e32.strerror(callback_error[0]))
Пример #14
0
 def resize(self,size,callback=None,keepaspect=0):
     self._wait()
     newimage=Image.new(size,self.mode) 
     lock=e32.Ao_lock()
     self._image.resize(newimage,keepaspect,self._callback)
     # If the code above didn't raise an exception, this method
     # will succeed, so now it's safe to modify object state.
     self._lock=lock
     self._usercallback=callback
     self._resized_image=newimage
     if callback is None:
         self._wait()
         if self._errcode != 0:
             err=self._errcode
             self._errcode=0
             raise SymbianError,(err, "Error resizing image:"+e32.strerror(err))
         t=self._resized_image
         self._resized_image=None
         return t
Пример #15
0
 def resize(self,size,callback=None,keepaspect=0):
     self._wait()
     newimage=Image.new(size,self.mode) 
     lock=e32.Ao_lock()
     self._image.resize(newimage,keepaspect,self._callback)
     # If the code above didn't raise an exception, this method
     # will succeed, so now it's safe to modify object state.
     self._lock=lock
     self._usercallback=callback
     self._resized_image=newimage
     if callback is None:
         self._wait()
         if self._errcode != 0:
             err=self._errcode
             self._errcode=0
             raise SymbianError,(err, "Error resizing image:"+e32.strerror(err))
         t=self._resized_image
         self._resized_image=None
         return t
Пример #16
0
 def save(self,filename,callback=None,format=None,quality=75,bpp=24,compression='default'):
     if format is None:
         if filename.lower().endswith('.jpg') or filename.lower().endswith('.jpeg'):
             format='JPEG'
         elif filename.lower().endswith('.png'):
             format='PNG'
         else:
             raise ValueError('unrecognized suffix and format not specified')
     self._wait()
     lock=e32.Ao_lock()
     self._image.save(unicode(filename),self._callback,format,quality,compression,bpp)
     # If the code above didn't raise an exception, this method
     # will succeed, so now it's safe to modify object state.
     self._usercallback=callback
     self._lock=lock
     if callback is None:
         self._wait()
         if self._errcode != 0:
             err=self._errcode
             self._errcode=0
             raise SymbianError,(err, "Error loading image:"+e32.strerror(err))
Пример #17
0
Файл: audio.py Проект: pymo/pymo
 def play(self, times=1, interval=0, callback=None):
     def play_cb(previous, current, err):
         #This is called first with EPlaying meaning that the playing started
         #and with EOpen meaning that the playing stopped.
         callback_error[0]=err
         if callback!=None:
             if (current==EPlaying or current==EOpen):
                 lock.signal()
             callback(previous, current, err)
         elif (current==EPlaying or current==EOpen) and callback==None:
             lock.signal()
     if self.state()!=EOpen:
         raise RuntimeError,("Sound not in correct state, state: %d" % (self.state()))
     lock=e32.Ao_lock()
     callback_error=[0]
     self._player.bind(play_cb)
     if not times==KMdaRepeatForever:
         times=times-1
     self._player.play(times, interval)
     lock.wait()
     if callback_error[0]:
         raise SymbianError,(callback_error[0],
                             "Error playing file: "+e32.strerror(callback_error[0]))