viewgit/index.php:465 Only variables should be passed by reference [2048]
viewgit/index.php:466 Non-static method GeSHi::get_language_name_from_extension() should not be called statically [2048]
# # -*- coding: utf-8 -*- # # Implementazione del Widget per gestire il video # import pygtk, gtk, gst, cairo, threading, time class GstPlayer(threading.Thread): def __init__(self, xid, video): threading.Thread.__init__(self) self.xid = xid self.video = video self.exit_required = False self.loading = False self.daemon = True def set_sink(self, sink): assert self.xid self.imagesink = sink self.imagesink.set_xwindow_id(self.xid) def on_sync_message(self, bus, message): if message.structure is None: return if message.structure.get_name() == 'prepare-xwindow-id': gtk.gdk.threads_enter() self.set_sink(message.src) message.src.set_property("force-aspect-ratio", True) gtk.gdk.threads_leave() def on_message(self, bus, message): if message.type == gst.MESSAGE_ERROR: err, debug = message.parse_error() print err, debug elif message.type == gst.MESSAGE_LATENCY: print message.parse_latency() elif message.type == gst.MESSAGE_BUFFERING: if message.parse_buffering() is 100: self.play() self.loading = False def is_loading(self): return self.loading def run(self): self.player = gst.element_factory_make("playbin", "player") self.player.set_property bus = self.player.get_bus() bus.enable_sync_message_emission() bus.add_signal_watch() bus.connect("sync-message::element", self.on_sync_message) bus.connect("message", self.on_message) self.loading = True self.player.set_property("uri", self.video) self.pause() while not self.exit_required: pass self.player.set_state(gst.STATE_NULL) def exit(self): self.player.set_state(gst.STATE_NULL) self.exit_required = True def pause(self): self.player.set_state(gst.STATE_PAUSED) def play(self): self.player.set_state(gst.STATE_PLAYING) self.loading = False class VideoWidget(gtk.DrawingArea): def __init__(self): ## Creo la drawing area e la coloro ## di nero gtk.DrawingArea.__init__(self) self.set_size_request(240,240) self.unset_flags(gtk.DOUBLE_BUFFERED) ## Connetto l'expose-event self.connect("expose-event", self.colorize) self.playing = False self.player = None def colorize(self, widget, event): """Quando la finestra viene creata la coloriamo di nero. Poi sarà tutto lavoro per gstreamer""" ## Ci permettiamo di disegnare sopra il filmato ## se e solo se non c'è un filmato che sta andando! :) print self.playing if not self.playing: cr = self.window.cairo_create() ## Non facciamo lavoro extra e coloriamo solo ciò ## che è stato scoperto cr.rectangle(event.area.x, event.area.y, event.area.width, event.area.height) cr.clip() width, height = self.window.get_size() cr.set_source_rgb(0,0,0) cr.rectangle(0,0,width,height) cr.fill() pixbuf = gtk.gdk.pixbuf_new_from_file("ui/rai_logo.png") x = pixbuf.get_width() y = pixbuf.get_height() cr.set_source_pixbuf(pixbuf,max((width-x)/2,0),max((height-y)/2,0)) cr.rectangle(max((width - x)/2,0),max((height-y)/2,0),x,y) cr.fill() return cr.set_source_rgb(0.5,0,0) st = "RaiTV :)" cr.set_font_size(height/20) cr.select_font_face("Comic Sans MS") xbearing , ybearing, twidth, theight, xadvance, yadvance = cr.text_extents(st) cr.move_to(width/2 - twidth/2, 1.6*height/3 - theight/5) cr.show_text(st) cr.set_line_width(3) cr.move_to(width/2 - twidth/2 - 5 , 1.6* height/3) cr.rel_line_to(twidth + 10,0) cr.stroke() def load_video(self, uri): """Start video playing with the specified URI""" ## Stoppiamo ogni video if self.playing: self.stop() print " => Buono, video stoppati" self.player = GstPlayer(self.window.xid, uri) print " => Player creato" self.player.start() self.player.pause() print " => Player avviato" self.playing = True ## Aspettiamo 5 secondi def pause(self): self.player.pause() def stop(self): self.playing = False if self.player is not None: self.player.exit() self.player.join(2) if self.player.isAlive(): print " => Ops, l'ho ucciso brutalmente" del self.player self.repaint() def repaint(self): width, height = self.window.get_size() self.queue_draw_area(0,0,width,height) def play(self): if self.player is not None: self.playing = True self.player.play() def reset(self): pass