| 127 | self.imagesink.set_xwindow_id(self.window.xid) |
| 128 | |
| 129 | class PlayerWindow(gtk.Window): |
| 130 | UPDATE_INTERVAL = 500 |
| 131 | def __init__(self): |
| 132 | gtk.Window.__init__(self) |
| 133 | self.set_default_size(410, 325) |
| 134 | |
| 135 | self.create_ui() |
| 136 | |
| 137 | self.player = GstPlayer(self.videowidget) |
| 138 | |
| 139 | def on_eos(): |
| 140 | self.player.seek(0L) |
| 141 | self.play_toggled() |
| 142 | self.player.on_eos = lambda *x: on_eos() |
| 143 | |
| 144 | self.update_id = -1 |
| 145 | self.changed_id = -1 |
| 146 | self.seek_timeout_id = -1 |
| 147 | |
| 148 | self.p_position = gst.CLOCK_TIME_NONE |
| 149 | self.p_duration = gst.CLOCK_TIME_NONE |
| 150 | |
| 151 | def on_delete_event(): |
| 152 | self.player.stop() |
| 153 | gtk.main_quit() |
| 154 | self.connect('delete-event', lambda *x: on_delete_event()) |
| 155 | |
| 156 | def load_file(self, location): |
| 157 | self.player.set_location(location) |
| 158 | |
| 159 | def create_ui(self): |
| 160 | vbox = gtk.VBox() |
| 161 | self.add(vbox) |
| 162 | |
| 163 | self.videowidget = VideoWidget() |
| 164 | vbox.pack_start(self.videowidget) |
| 165 | |
| 166 | hbox = gtk.HBox() |
| 167 | vbox.pack_start(hbox, fill=False, expand=False) |
| 168 | |
| 169 | self.pause_image = gtk.image_new_from_stock(gtk.STOCK_MEDIA_PAUSE, |
| 170 | gtk.ICON_SIZE_BUTTON) |
| 171 | self.pause_image.show() |
| 172 | self.play_image = gtk.image_new_from_stock(gtk.STOCK_MEDIA_PLAY, |
| 173 | gtk.ICON_SIZE_BUTTON) |
| 174 | self.play_image.show() |
| 175 | self.button = button = gtk.Button() |
| 176 | button.add(self.play_image) |
| 177 | button.set_property('can-default', True) |
| 178 | button.set_focus_on_click(False) |
| 179 | button.show() |
| 180 | hbox.pack_start(button, False) |
| 181 | button.set_property('has-default', True) |
| 182 | button.connect('clicked', lambda *args: self.play_toggled()) |
| 183 | |
| 184 | self.adjustment = gtk.Adjustment(0.0, 0.00, 100.0, 0.1, 1.0, 1.0) |
| 185 | hscale = gtk.HScale(self.adjustment) |
| 186 | hscale.set_digits(2) |