Esempio n. 1
0
    def start(self, file_path=None):
        self._want_document = False
        self.playpath = os.path.dirname(file_path)
        if not file_path:
            return False
        self.playlist.append('file://' + os.path.abspath(file_path))
        if not self.player:
            # Lazy init the player so that videowidget is realized
            # and has a valid widget allocation.
            self.player = GstPlayer(self.videowidget, self.running_sugar)
            self.player.connect('eos', self._player_eos_cb)
            self.player.connect('error', self._player_error_cb)
            self.player.connect('stream-info', self._player_stream_info_cb)

        try:
            if not self.currentplaying:
                debug_output('Playing: %s' % (self.playlist[0]),
                             self.running_sugar)
                self.player.set_uri(self.playlist[0])
                self.currentplaying = 0
                self.play_toggled()
        except Exception as e:
            error_output('Error playing %s: %s' % (self.playlist[0], e),
                         self.running_sugar)
        return False
    def start(self, file_path=None):
        self._want_document = False
        self.playpath = os.path.dirname(file_path)
        if not file_path:
            return False
        self.playlist.append('file://' + os.path.abspath(file_path))
        if not self.player:
            # Lazy init the player so that videowidget is realized
            # and has a valid widget allocation.
            self.player = GstPlayer(self.videowidget, self.running_sugar)
            self.player.connect('eos', self._player_eos_cb)
            self.player.connect('error', self._player_error_cb)
            self.player.connect('stream-info', self._player_stream_info_cb)

        try:
            if not self.currentplaying:
                debug_output('Playing: %s' % (self.playlist[0]),
                             self.running_sugar)
                self.player.set_uri(self.playlist[0])
                self.currentplaying = 0
                self.play_toggled()
        except Exception as e:
            error_output('Error playing %s: %s' % (self.playlist[0], e),
                         self.running_sugar)
        return False
    def __init__(self, turtle_window, n):
        '''This class handles the display of palette selectors (Only relevant
        to GNOME version and very old versions of Sugar).
        '''

        self.shapes = []
        self.spr = None
        self._turtle_window = turtle_window
        self._index = n

        if not n < len(palette_names):
            # Shouldn't happen, but hey...
            debug_output('palette index %d is out of range' % n,
                         self._turtle_window.running_sugar)
            self._name = 'extras'
        else:
            self._name = palette_names[n]

        icon_pathname = None
        for path in self._turtle_window.icon_paths:
            if os.path.exists(os.path.join(path, '%soff.svg' % (self._name))):
                icon_pathname = os.path.join(path, '%soff.svg' % (self._name))
                break

        if icon_pathname is not None:
            off_shape = svg_str_to_pixbuf(svg_from_file(icon_pathname))
        else:
            off_shape = svg_str_to_pixbuf(
                svg_from_file(
                    os.path.join(self._turtle_window.icon_paths[0],
                                 'extrasoff.svg')))
            error_output('Unable to open %soff.svg' % (self._name),
                         self._turtle_window.running_sugar)

        icon_pathname = None
        for path in self._turtle_window.icon_paths:
            if os.path.exists(os.path.join(path, '%son.svg' % (self._name))):
                icon_pathname = os.path.join(path, '%son.svg' % (self._name))
                break

        if icon_pathname is not None:
            on_shape = svg_str_to_pixbuf(svg_from_file(icon_pathname))
        else:
            on_shape = svg_str_to_pixbuf(
                svg_from_file(
                    os.path.join(self._turtle_window.icon_paths[0],
                                 'extrason.svg')))
            error_output('Unable to open %son.svg' % (self._name),
                         self._turtle_window.running_sugar)

        self.shapes.append(off_shape)
        self.shapes.append(on_shape)

        x = int(ICON_SIZE * self._index)
        self.spr = Sprite(self._turtle_window.sprite_list, x, 0, off_shape)
        self.spr.type = 'selector'
        self.spr.name = self._name
        self.set_layer()
Esempio n. 4
0
    def __init__(self, turtle_window, n):
        '''This class handles the display of palette selectors (Only relevant
        to GNOME version and very old versions of Sugar).
        '''

        self.shapes = []
        self.spr = None
        self._turtle_window = turtle_window
        self._index = n

        if not n < len(palette_names):
            # Shouldn't happen, but hey...
            debug_output('palette index %d is out of range' % n,
                         self._turtle_window.running_sugar)
            self._name = 'extras'
        else:
            self._name = palette_names[n]

        icon_pathname = None
        for path in self._turtle_window.icon_paths:
            if os.path.exists(os.path.join(path, '%soff.svg' % (self._name))):
                icon_pathname = os.path.join(path, '%soff.svg' % (self._name))
                break

        if icon_pathname is not None:
            off_shape = svg_str_to_pixbuf(svg_from_file(icon_pathname))
        else:
            off_shape = svg_str_to_pixbuf(svg_from_file(os.path.join(
                self._turtle_window.icon_paths[0], 'extrasoff.svg')))
            error_output('Unable to open %soff.svg' % (self._name),
                         self._turtle_window.running_sugar)

        icon_pathname = None
        for path in self._turtle_window.icon_paths:
            if os.path.exists(os.path.join(path, '%son.svg' % (self._name))):
                icon_pathname = os.path.join(path, '%son.svg' % (self._name))
                break

        if icon_pathname is not None:
            on_shape = svg_str_to_pixbuf(svg_from_file(icon_pathname))
        else:
            on_shape = svg_str_to_pixbuf(svg_from_file(os.path.join(
                self._turtle_window.icon_paths[0], 'extrason.svg')))
            error_output('Unable to open %son.svg' % (self._name),
                         self._turtle_window.running_sugar)

        self.shapes.append(off_shape)
        self.shapes.append(on_shape)

        x = int(ICON_SIZE * self._index)
        self.spr = Sprite(self._turtle_window.sprite_list, x, 0, off_shape)
        self.spr.type = 'selector'
        self.spr.name = self._name
        self.set_layer()
Esempio n. 5
0
 def _make_block(self, svg):
     self._left = 0
     self._top = 0
     self._right = 0
     self._bottom = 0
     self.svg.set_stroke_width(STANDARD_STROKE_WIDTH)
     self.svg.clear_docks()
     for k in block_styles.keys():
         if self.name in block_styles[k]:
             if type(self.block_methods[k]) == type([]):
                 self.block_methods[k][0](svg, self.block_methods[k][1],
                                          self.block_methods[k][2])
             else:
                 self.block_methods[k](svg)
             return
     error_output('block type not found %s' % (self.name))
     self.block_methods['basic-style'](svg)
Esempio n. 6
0
 def on_message(self, bus, message):
     t = message.type
     if t == Gst.MessageType.ERROR:
         err, debug = message.parse_error()
         error_output('Error: %s - %s' % (err, debug), self.running_sugar)
         self.error = True
         self.emit('eos')
         self.playing = False
         self.emit('error', str(err), str(debug))
     elif t == Gst.MessageType.EOS:
         self.emit('eos')
         self.playing = False
     elif t == Gst.MessageType.STATE_CHANGED:
         old, new, pen = message.parse_state_changed()
         if old == Gst.State.READY and new == Gst.State.PAUSED and \
            hasattr(self.player.props, 'stream_info_value_array'):
             self.emit('stream-info',
                       self.player.props.stream_info_value_array)
 def on_message(self, bus, message):
     t = message.type
     if t == Gst.MessageType.ERROR:
         err, debug = message.parse_error()
         error_output('Error: %s - %s' % (err, debug),
                      self.running_sugar)
         self.error = True
         self.emit('eos')
         self.playing = False
         self.emit('error', str(err), str(debug))
     elif t == Gst.MessageType.EOS:
         self.emit('eos')
         self.playing = False
     elif t == Gst.MessageType.STATE_CHANGED:
         old, new, pen = message.parse_state_changed()
         if old == Gst.State.READY and new == Gst.State.PAUSED and \
            hasattr(self.player.props, 'stream_info_value_array'):
             self.emit('stream-info',
                       self.player.props.stream_info_value_array)
Esempio n. 8
0
 def _make_block(self, svg):
     self._left = 0
     self._top = 0
     self._right = 0
     self._bottom = 0
     self.svg.set_stroke_width(STANDARD_STROKE_WIDTH)
     self.svg.clear_docks()
     if isinstance(self.name, unicode):
         self.name = self.name.encode('utf-8')
     for k in block_styles.keys():
         if self.name in block_styles[k]:
             if isinstance(self.block_methods[k], list):
                 self.block_methods[k][0](svg, self.block_methods[k][1],
                                          self.block_methods[k][2])
             else:
                 self.block_methods[k](svg)
             return
     error_output('ERROR: block type not found %s' % (self.name))
     self.block_methods['blank-style'](svg)
     self.unknown = True
 def _player_error_cb(self, widget, message, detail):
     self.player.stop()
     self.player.set_uri(None)
     error_output('Error: %s - %s' % (message, detail),
                  self.running_sugar)
Esempio n. 10
0
 def _player_error_cb(self, widget, message, detail):
     self.player.stop()
     self.player.set_uri(None)
     error_output('Error: %s - %s' % (message, detail),
                  self.running_sugar)