For anyone contemplating writing a multi-touch application, PyMT can be a fun and easy way to see instant results. Its API offers several useful widgets that allows for fast prototyping. With that said, PyMT should not be used for a commercial or high performance applications, as it has some major limitations with its inheritance architecture and screen paint logic (plus it comes with a GPL license). Some of these issues have been addressed in the teams rewrite of PyMT called Kivy. Although Kivy appears promising, it is still in its infancy and will need a few more release iterations before being adopted by the masses.
The weakest PyMT widget is by far the video player. Its integration with gstreamer is not nearly as complete as PyQt and it doesn’t have full multi-touch support. To address the multi-touch issue I wrote the following code snippet for one of Immersive’s first early stage in store product browser. It adds a default picture when the video is at position 0 and superimposes a “play” button when paused. In addition it uses the MTScatter widget as its base class which allows the user to manipulate the video using full multi-touch gestures when playing.
class scatVid(MTScatter):
def __init__(self, filename, image, **kwargs):
# image is a pre-constructed Image( ) object to be used at start of video
super(scatVid, self).__init__(**kwargs)
self.image = MTImage(image)
self.play = MTImage(Image('./play_button.png'))
self._posXY = None
self.video = MTVideo(filename=filename, eos='loop')
self.video.hide_controls()
self.video.player.position = 10
self.size=self.video.size
connect(self.video, 'on_resize', self, 'size')
connect(self.video, 'on_resize', self.image, 'size')
connect(self.video, 'on_resize', self.play, 'size')
self.add_widget(self.video)
self.add_widget(self.image)
self.add_widget(self.play)
self._state = ""
def stop(self):
self.video.player.stop()
def play(self):
self.video.player.play()
def hide(self):
self.video.player.stop()
super(scatVid, self).hide()
def show(self):
self.video.player.load()
super(scatVid, self).show()
def _get_state(self):
return self.video.player.state
def _get_posXY(self):
return self._posXY
def _set_posXY(self, x, y):
print "setting posXY: %dx%d" %(x,y)
self._posXY=(x,y)
self.pos=(x,y)
def draw(self):
super(scatVid, self).draw()
if self.state != "playing":
if self.video.player.position < 2:
self.image.show()
else:
self.play.show()
else:
self.image.hide()
self.play.hide()
state = property(lambda self: self._get_state(),
doc='Get the video playing status')
To see the above code in action look here. You can use any play button piece of artwork, but for your convince here is the one I used.
