예제 #1
0
 def __init__(self):
     GObject.GObject.__init__(self)
     Gst.init_check(None)
     self.status = Status.STOPPED
     self.player = None
     self.speed = 1.0
     self.volume = 1.0
     self.amplification = 1.0
     self.removesilence = False
     self.equalizer = {
         'band0': 0,
         'band1': 0,
         'band2': 0,
         'band3': 0,
         'band4': 0,
         'band5': 0,
         'band6': 0,
         'band7': 0,
         'band8': 0,
         'band9': 0,
         'band10': 0,
         'band11': 0,
         'band12': 0,
         'band13': 0,
         'band14': 0,
         'band15': 0,
         'band16': 0,
         'band17': 0
     }
     self.lastpos = 0
예제 #2
0
def main():
    logging.basicConfig(level=logging.INFO)
    options = get_options().parse_args()
    Gst.init_check(None)
    command = [
        'udpsrc',
        'name=network',
        'address=224.1.1.2',
        'port=8000',
        'multicast-iface=lo',
        '!',
        'tsdemux',
        'name=demux',
        'emit-stats=true',
        '!',
        'fakesink',
    ]
    pipe = pipeline.Pipe('sample', command)
    pipe.run()
    pipe2 = pipeline.Pipe('generator', GENERATOR_PIPELINE)
    pipe2.run()

    def pad_added(bus, message):
        log.info('pad added: %s', message)

    pipe.components.demux.connect('pad-added', pad_added)

    log.info("Muxer: %s", pipe.components.muxer)
    pipeline.LOOP.run()
예제 #3
0
    def __init__(self, pipeline_string):
        import sys
        Gst.init_check(sys.argv)
        GObject.GObject.__init__(self)

        self.pipeline_string = pipeline_string

        self._setup_pipeline()
예제 #4
0
 def __init__(self):
     
     self.playing = False
 
     # A free example sound track
     #self.uri = "http://cdn02.cdn.gorillavsbear.net/wp-content/uploads/2012/10/GORILLA-VS-BEAR-OCTOBER-2012.mp3"
     
     self.uri = "http://docs.gstreamer.com/media/sintel_trailer-480p.webm"
     # GTK window and widgets
     self.window = Gtk.Window()
     self.window.set_size_request(300,50)
 
     vbox = Gtk.Box(Gtk.Orientation.HORIZONTAL, 0)
     vbox.set_margin_top(3)
     vbox.set_margin_bottom(3)
     self.window.add(vbox)
 
     self.playButtonImage = Gtk.Image()
     self.playButtonImage.set_from_stock("gtk-media-play", Gtk.IconSize.BUTTON)
     self.playButton = Gtk.Button.new()
     self.playButton.add(self.playButtonImage)
     self.playButton.connect("clicked", self.playToggled)
     Gtk.Box.pack_start(vbox, self.playButton, False, False, 0)
 
     self.slider = Gtk.HScale()
     self.slider.set_margin_left(6)
     self.slider.set_margin_right(6)
     self.slider.set_draw_value(False)
     self.slider.set_range(0, 100)
     self.slider.set_increments(1, 10)
 
     Gtk.Box.pack_start(vbox, self.slider, True, True, 0)
 
     self.label = Gtk.Label(label='0:00')
     self.label.set_margin_left(6)
     self.label.set_margin_right(6)
     Gtk.Box.pack_start(vbox, self.label, False, False, 0)
 
     self.window.show_all()
 
     # GStreamer Setup
     Gst.init_check(None)
     self.IS_GST010 = Gst.version()[0] == 0
     self.player = Gst.ElementFactory.make("playbin", "player")
     
     #fakesink = Gst.ElementFactory.make("fakesink", "fakesink")
     #self.player.set_property("video-sink", fakesink)
     filesink = Gst.ElementFactory.make("filesink", "filesink")
     filesink.location = "/home/smonni/test_video.yuv"
     self.player.set_property("video-sink", filesink)
     
     
     
     
     bus = self.player.get_bus()
     #bus.add_signal_watch_full()
     bus.connect("message", self.on_message)
     self.player.connect("about-to-finish",  self.on_finished)
    def setup_gstreamer(self):
                # Setup GStreamer 
        Gst.init(None)
        Gst.init_check(None)
        print Gst.version_string(), Gst.version()

        Gst.debug_set_active(True)
        Gst.debug_print_stack_trace() # If activated, debugging messages are sent to the debugging handlers.
        
        """ 
def main():

	if dbus.SessionBus().request_name('es.atareao.PomodoroIndicator') != dbus.bus.REQUEST_NAME_REPLY_PRIMARY_OWNER:
		print("application already running")
		exit(0)		
	GObject.threads_init()
	Gst.init(None)
	Gst.init_check(None)
	Notify.init('pomodoro-indicator')
	pomodoro_indicator=Pomodoro_Indicator()
	Gtk.main()
예제 #7
0
    def setup_gstreamer(self):
        # Setup GStreamer
        Gst.init(None)
        Gst.init_check(None)
        print
        Gst.version_string(), Gst.version()

        Gst.debug_set_active(True)
        Gst.debug_print_stack_trace(
        )  # If activated, debugging messages are sent to the debugging handlers.
        """ 
예제 #8
0
    def __init__(self, frequency=587.33, length=250):

        if not sound_available:
            return

        Gst.init_check()
        self.frequency = frequency
        self.length = length
        # play in a separate thread - do not block simulation
        thread = Thread(target=self.play)
        thread.start()
예제 #9
0
    def __init__(self, playlistt, fader):

        threading.Thread.__init__(self)
        self.filepath = ""
        self._filepath = ""
        self.ffilepath = ""
        self.nowplaying = False
        self.gui = None
        self.vol = fader

        Gst.init_check(None)
        self.ISGST010 = Gst.version()[0] == 0

        self.player = Gst.ElementFactory.make("playbin", "player")
        self.equalizer = Gst.ElementFactory.make("equalizer-10bands", "equalizer-10bands")

        fakesink = Gst.ElementFactory.make("fakesink", "fakesink")
        self.player.set_property("video-sink", fakesink)

        audioconvert = Gst.ElementFactory.make('audioconvert', "audioconvert")
        audiosink = Gst.ElementFactory.make('autoaudiosink', "audiosink")
        sinkbin = Gst.Bin()
        sinkbin.add(self.equalizer)
        sinkbin.add(audioconvert)
        sinkbin.add(audiosink)
        #Gst.element_link_many(self.equalizer, audioconvert, audiosink)

        self.equalizer.link(audioconvert)
        audioconvert.link(audiosink)

        sinkpad = self.equalizer.get_static_pad('sink')
        sinkbin.add_pad(Gst.GhostPad.new('sink', sinkpad))
        self.player.set_property('audio-sink', sinkbin)

        bus = self.player.get_bus()
        bus.add_signal_watch()
        bus.connect("message", self.on_message)

        self.player.connect("about-to-finish", self.about_to_finish)

        self.playlist_instance = playlistt

        self.time_format = Gst.Format(Gst.Format.TIME)
        self.duration = None
        self.new_file = False
        self.is_playing = False
        self.is_paused = False
        self.current_position = ""
        self.current_track_playlist_index = -2
        self.gapless_playback_flag = True
        self.track_queue = queue.Queue()

        self.music_items = self.playlist_instance.get_items_from_playlist(self.playlist_instance.playlist)
    def __init__(self):
        # Creating normal vars
        self.playing = False
        self.duration = Gst.CLOCK_TIME_NONE

        # Creating the GUI
        interface = Gtk.Builder()
        interface.add_from_file(os.path.realpath("glade_windows/player.glade"))

        interface.connect_signals(self)

        self.main_widget = interface.get_object("player")
        self.play_button = interface.get_object("play_button")
        self.play_button_label = interface.get_object("play_button_label")
        self.adjustment_volume = interface.get_object("adjustment_volume")
        self.adjustment_position = interface.get_object("adjustment_position")
        self.slider_position = interface.get_object("scale_position")
        self.time_label = interface.get_object("time_label")

        self.slider_seek_handler_id = self.slider_position.connect(
            "value-changed", self.on_slider_seek)

        # Creating the GStreamer pipeline and filling it.
        Gst.init_check()
        self._pipeline = Gst.Pipeline.new("pipeline")

        self._file_source = Gst.ElementFactory.make("filesrc", "file-source")
        self._pipeline.add(self._file_source)

        self._decoder = Gst.ElementFactory.make("decodebin", "decoder")
        self._pipeline.add(self._decoder)

        self._queue = Gst.ElementFactory.make("queue", "queue")
        self._pipeline.add(self._queue)

        self._converter = Gst.ElementFactory.make("audioconvert", "converter")
        self._pipeline.add(self._converter)

        self._volume = Gst.ElementFactory.make("volume", "volume")
        self._pipeline.add(self._volume)

        self._output = Gst.ElementFactory.make("autoaudiosink", "output")
        self._pipeline.add(self._output)

        self._file_source.link(self._decoder)
        self._decoder.connect("pad-added", self.on_decoder_add_pad)
        self._queue.link(self._converter)
        self._converter.link(self._volume)
        self._volume.link(self._output)

        bus = self._pipeline.get_bus()
        bus.add_signal_watch()
        bus.connect("message", self.on_pipeline_message)
예제 #11
0
파일: applet.py 프로젝트: ojuba-org/monajat
 def __init__(self, fn = "", change_play_status = None):
     """ SoundPlayer Using gst """
     self.fn = fn
     self.change_play_status = change_play_status
     Gst.init_check(None)
     self.gst_player = Gst.ElementFactory.make("playbin", "Ojuba-SoundPlayer")
     self.gst_player.set_property("uri", "file://" + fn)
     bus = self.gst_player.get_bus()
     bus.add_signal_watch()
     #bus.connect("message", self.on_message)
     bus.connect('message::eos', self.on_message)
     bus.connect('message::error', self.on_message)
예제 #12
0
파일: gsounder.py 프로젝트: kyahco/gsounder
    def __init__(self):

        self.uri = "file:///home/kyahco/Music/Random/Under-Pressure.wav"
        self.playing = False

        # GStreamer Setup
        Gst.init_check(None)
        self.player = Gst.ElementFactory.make("playbin", "audio-player")
        self.IS_GST010 = Gst.version()[0] == 0
        fakesink = Gst.ElementFactory.make("fakesink", "fakesink")
        self.player.set_property("video-sink", fakesink)
        bus = self.player.get_bus()
예제 #13
0
def main():
    if dbus.SessionBus().request_name(
        'es.atareao.PomodoroIndicator') !=\
            dbus.bus.REQUEST_NAME_REPLY_PRIMARY_OWNER:
        print("application already running")
        exit(0)
    GObject.threads_init()
    Gst.init(None)
    Gst.init_check(None)
    Notify.init('pomodoro-indicator')
    Pomodoro_Indicator()
    Gtk.main()
예제 #14
0
 def __init__(self, fn="", change_play_status=None):
     """ SoundPlayer Using gst """
     self.fn = fn
     self.change_play_status = change_play_status
     Gst.init_check(None)
     self.gst_player = Gst.ElementFactory.make("playbin",
                                               "Ojuba-SoundPlayer")
     self.gst_player.set_property("uri", "file://" + fn)
     bus = self.gst_player.get_bus()
     bus.add_signal_watch()
     #bus.connect("message", self.on_message)
     bus.connect('message::eos', self.on_message)
     bus.connect('message::error', self.on_message)
    def __init__(self):
        self.playing = False

        # A free example sound track
        self.uri = "file:///home/kemal/Videos/jason_statham.mp4"

        # GTK window and widgets
        self.window = Gtk.Window()
        self.window.set_size_request(300, 50)

        vbox = Gtk.Box(Gtk.Orientation.HORIZONTAL, 0)
        vbox.set_margin_top(3)
        vbox.set_margin_bottom(3)
        self.window.add(vbox)

        self.playButtonImage = Gtk.Image()
        self.playButtonImage.set_from_stock("gtk-media-play",
                                            Gtk.IconSize.BUTTON)
        self.playButton = Gtk.Button.new()
        self.playButton.add(self.playButtonImage)
        self.playButton.connect("clicked", self.playToggled)
        Gtk.Box.pack_start(vbox, self.playButton, False, False, 0)

        self.slider = Gtk.HScale()
        self.slider.set_margin_left(6)
        self.slider.set_margin_right(6)
        self.slider.set_draw_value(False)
        self.slider.set_range(0, 100)
        self.slider.set_increments(1, 10)

        Gtk.Box.pack_start(vbox, self.slider, True, True, 0)

        self.label = Gtk.Label(label='0:00')
        self.label.set_margin_left(6)
        self.label.set_margin_right(6)
        Gtk.Box.pack_start(vbox, self.label, False, False, 0)

        self.window.show_all()

        # GStreamer Setup
        Gst.init_check(None)
        self.IS_GST010 = Gst.version()[0] == 0
        self.player = Gst.ElementFactory.make("playbin",
                                              "player")  # playbin2 sıçıyor
        autovideosink = Gst.ElementFactory.make("autovideosink",
                                                "autovideosink")
        self.player.set_property("video-sink", autovideosink)
        bus = self.player.get_bus()
        # bus.add_signal_watch_full()
        bus.connect("message", self.on_message)
        self.player.connect("about-to-finish", self.on_finished)
    def __init__(self):
        self.playing = False

        # A free example sound track
        self.uri = "2012.mp3"

        # GTK window and widgets
        self.window = Gtk.Window()
        self.window.set_size_request(300,50)

        vbox = Gtk.Box(Gtk.Orientation.HORIZONTAL, 0)
        vbox.set_margin_top(3)
        vbox.set_margin_bottom(3)
        self.window.add(vbox)

        self.playButtonImage = Gtk.Image()
        self.playButtonImage.set_from_stock("gtk-media-play", Gtk.IconSize.BUTTON)
        self.playButton = Gtk.Button.new()
        self.playButton.add(self.playButtonImage)
        self.playButton.connect("clicked", self.playToggled)
        Gtk.Box.pack_start(vbox, self.playButton, False, False, 0)

        self.slider = Gtk.HScale()
        self.slider.set_margin_left(6)
        self.slider.set_margin_right(6)
        self.slider.set_draw_value(False)
        self.slider.set_range(0, 100)
        self.slider.set_increments(1, 10)

        Gtk.Box.pack_start(vbox, self.slider, True, True, 0)

        self.label = Gtk.Label(label='0:00')
        self.label.set_margin_left(6)
        self.label.set_margin_right(6)
        Gtk.Box.pack_start(vbox, self.label, False, False, 0)

        self.window.connect("destroy", Gtk.main_quit)
        self.window.show_all()

        # GStreamer Setup
        Gst.init_check(None)
        self.IS_GST010 = Gst.version()[0] == 0
        self.player = Gst.ElementFactory.make("playbin", "player")
        fakesink = Gst.ElementFactory.make("fakesink", "fakesink")
        self.player.set_property("video-sink", fakesink)
        bus = self.player.get_bus()
        #bus.add_signal_watch_full()
        bus.connect("message", self.on_message)
        self.player.connect("about-to-finish",  self.on_finished)
예제 #17
0
    def __init__(self):
        Gst.init_check(None)
        self.IS_GST010 = Gst.version()[0] == 0

        playbin = "playbin2" if self.IS_GST010 else "playbin"
        self.player = Gst.ElementFactory.make(playbin, "player")
        fakesink = Gst.ElementFactory.make("fakesink", "fakesink")
        self.player.set_property("video-sink", fakesink)
        bus = self.player.get_bus()
        bus.add_signal_watch()
        bus.connect("message::eos", self.on_eos)
        bus.connect("message::error", self.on_error)
        self.player.connect("about-to-finish",  self.on_finished)

        self.moving_slider = False
예제 #18
0
    def __init__(self):
        Gst.init_check(None)
        self.IS_GST010 = Gst.version() < (0, 11)

        playbin = "playbin2" if self.IS_GST010 else "playbin"
        self.player = Gst.ElementFactory.make(playbin, "player")
        if not self.IS_GST010:
            fakesink = Gst.ElementFactory.make("fakesink", "fakesink")
            self.player.set_property("video-sink", fakesink)
            bus = self.player.get_bus()
            bus.add_signal_watch()
            bus.connect("message::eos", self.on_eos)
            bus.connect("message::error", self.on_error)
        self.player.connect("about-to-finish",  self.on_finished)

        self.moving_slider = False
예제 #19
0
def _init_gst():
    """Call once before importing GStreamer"""

    assert "gi.repository.Gst" not in sys.modules

    import gi

    # We don't want python-gst, it changes API..
    assert "gi.overrides.Gst" not in sys.modules
    sys.modules["gi.overrides.Gst"] = None

    # blacklist some modules, simply loading can cause segfaults
    sys.modules["gst"] = None

    # We don't depend on Gst overrides, so make sure it's initialized.
    try:
        gi.require_version("Gst", "1.0")
        from gi.repository import Gst
    except (ValueError, ImportError):
        return

    if Gst.is_initialized():
        return

    from gi.repository import GLib

    try:
        ok, argv[:] = Gst.init_check(argv)
    except GLib.GError:
        print_e("Failed to initialize GStreamer")
        # Uninited Gst segfaults: make sure no one can use it
        sys.modules["gi.repository.Gst"] = None
    else:
        # monkey patching ahead
        _fix_gst_leaks()
예제 #20
0
파일: _init.py 프로젝트: Muges/quodlibet
def _init_gst():
    """Call once before importing GStreamer"""

    assert "gi.repository.Gst" not in sys.modules

    import gi

    # We don't want python-gst, it changes API..
    assert "gi.overrides.Gst" not in sys.modules
    sys.modules["gi.overrides.Gst"] = None

    # blacklist some modules, simply loading can cause segfaults
    sys.modules["gst"] = None

    # We don't depend on Gst overrides, so make sure it's initialized.
    try:
        gi.require_version("Gst", "1.0")
        from gi.repository import Gst
    except (ValueError, ImportError):
        return

    if Gst.is_initialized():
        return

    from gi.repository import GLib

    try:
        ok, argv[:] = Gst.init_check(argv)
    except GLib.GError:
        print_e("Failed to initialize GStreamer")
        # Uninited Gst segfaults: make sure no one can use it
        sys.modules["gi.repository.Gst"] = None
    else:
        # monkey patching ahead
        _fix_gst_leaks()
예제 #21
0
    def __init__(self):
    self.playing = False

    # A free example sound track
    self.uri = "http://cdn02.cdn.gorillavsbear.net/wp-content/uploads/2012/10/GORILLA-VS-BEAR-OCTOBER-2012.mp3"

    # GTK window and widgets
    self.window = Gtk.Window()
    self.window.set_size_request(300,50)

    vbox = Gtk.Box(Gtk.Orientation.HORIZONTAL, 0)
    vbox.set_margin_top(3)
    vbox.set_margin_bottom(3)
    self.window.add(vbox)

    self.playButtonImage = Gtk.Image()
    self.playButtonImage.set_from_stock("gtk-media-play", Gtk.IconSize.BUTTON)
    self.playButton = Gtk.Button.new()
    self.playButton.add(self.playButtonImage)
    self.playButton.connect("clicked", self.playToggled)
    Gtk.Box.pack_start(vbox, self.playButton, False, False, 0)

    self.slider = Gtk.HScale()
    self.slider.set_margin_left(6)
    self.slider.set_margin_right(6)
    self.slider.set_draw_value(False)
    self.slider.set_range(0, 100)
    self.slider.set_increments(1, 10)

    Gtk.Box.pack_start(vbox, self.slider, True, True, 0)

    self.label = Gtk.Label(label='0:00')
    self.label.set_margin_left(6)
    self.label.set_margin_right(6)
    Gtk.Box.pack_start(vbox, self.label, False, False, 0)

    self.window.show_all()

        # GStreamer Setup
        Gst.init_check(None)
        self.IS_GST010 = Gst.version()[0] == 0
예제 #22
0
    def __init__(self):
        Gtk.Box.__init__(self, spacing=6)
        #GObject.threads_init()
        Gst.init(None)
        Gst.init_check(None)

        self.playerDic = {}
        self.video_box = Gtk.Box(spacing=6)

        self.description_store = Gtk.ListStore(str, str)
        self.description_entries = self.build_description_entries()

        scrolled_window = Gtk.ScrolledWindow(expand=True)
        #scrolled_window.set_size_request(650, 50)
        scrolled_window.add(self.description_entries)

        grid = Gtk.Grid(margin=20, column_spacing=10, row_spacing=20)
        grid.set_column_homogeneous(True)
        grid.set_row_homogeneous(True)

        grid.attach(self.video_box, 0, 0, 8, 8)
        grid.attach(scrolled_window, 0, 9, 8, 2)

        self.back = Gtk.Button(label=_("Back to Exercises"), use_underline=True)
        Gtk.Widget.set_sensitive(self.back, True)
        grid.attach(self.back, 0, 8, 4, 1)

        self.play = Gtk.Button(label=_("Play"), use_underline=True)
        self.play.connect('clicked', self._on_play_stop)
        Gtk.Widget.set_sensitive(self.play, False)
        grid.attach(self.play, 4, 8, 4, 1)

        self.grid = grid
        self.pack_start(grid, True, True, 0)

        self.pipeline = Gst.ElementFactory.make("playbin", "player")
        self.sink = Gst.ElementFactory.make("gtksink")
        self.video_box.pack_start(self.sink.props.widget, True, True, 0)
        bus = self.pipeline.get_bus()
        bus.add_signal_watch()
        bus.connect("message", self._on_message)
예제 #23
0
파일: player.py 프로젝트: hrkfdn/gomusic
    def __init__(self, mc, devid):
        self.mc = mc
        self.devid = devid
        self.statusbar_func = None
        self.state = Gst.State.NULL
        self.messagelistener = []

        Gst.init_check(None)
        print("GStreamer version: " + Gst.version_string())

        self.pipeline = Gst.Pipeline()
        self.player = Gst.ElementFactory.make("playbin", None)
        self.pipeline.add(self.player)
        pulse = Gst.ElementFactory.make("pulsesink", "pulse")
        fakesink = Gst.ElementFactory.make("fakesink", "fakesink")

        self.bus = self.pipeline.get_bus()
        self.bus.add_signal_watch()
        self.bus.connect("message", self.on_message)

        self.player.set_property("audio-sink", pulse)
        self.player.set_property("video-sink", fakesink)
예제 #24
0
	def __init__(self, device, size, rotation, onFatalError, mainLoop, debugLevel):

		if not Gst.init_check(None):
			raise ImportError

		if debugLevel > 0:
			Gst.debug_set_active(True)
			Gst.debug_set_default_threshold(debugLevel)

		self._onFatalError = onFatalError
		self._mainLop = mainLoop

		self._toreDownAlready = False

		#pipeline control
		self._currentPipelineState = None
		self._pipelineStateCondition = Condition()
		## Make sure attach and detach operation wait for each other to complete ##
		self._photoBinAttachDetachLock = Lock()
		self._localVideoBinAttachDetachLock = Lock()
		###########################################################################

		self._pipeline = Gst.Pipeline()

		self._videoSrcBin = self._getVideoSrcBin(self._pipeline, device, size, rotation)
		self._videoEncBin = self._getVideoEncBin(size, rotation)
		self._photoCaptureBin = PhotoCaptureBin(self._onNoMorePhotos)
		self._localVideoBin = ImgVideoEncBin(size, rotation, self._onStopPhotoSeq)

		self._pipeline.add(self._videoEncBin.bin)
		self._pipeline.add(self._photoCaptureBin.bin)
		self._pipeline.add(self._localVideoBin.bin)

		self._bus = self._pipeline.get_bus()
		self._bus.set_flushing(True)

		self._busListener = BusListener(self._bus)
		self._busListener.addListener(Gst.MessageType.ERROR, self._onBusError)
		self._busListener.addListener(Gst.MessageType.EOS, self._onBusEos)
		self._busListener.addListener(Gst.MessageType.STATE_CHANGED, self._onBusStateChanged)
		self._busListener.addListener(Gst.MessageType.REQUEST_STATE, self._onRequestState)
		self._busListener.start()
예제 #25
0
def _gst_init():
    """Call once before importing GStreamer"""

    assert "gi.repository.Gst" not in sys.modules

    import gi

    # We don't want python-gst, it changes API..
    assert "gi.overrides.Gst" not in sys.modules
    sys.modules["gi.overrides.Gst"] = None

    # blacklist some modules, simply loading can cause segfaults
    sys.modules["gst"] = None

    # We don't depend on Gst overrides, so make sure it's initialized.
    try:
        gi.require_version("Gst", "1.0")
        from gi.repository import Gst
    except (ValueError, ImportError):
        return

    if Gst.is_initialized():
        return

    from gi.repository import GLib

    try:
        ok, argv = Gst.init_check(sys.argv)
    except GLib.GError:
        print_e("Failed to initialize GStreamer")
        # Uninited Gst segfaults: make sure no one can use it
        sys.modules["gi.repository.Gst"] = None
    else:
        sys.argv = argv

        # monkey patching ahead
        _fix_gst_leaks()

        # https://bugzilla.gnome.org/show_bug.cgi?id=710447
        import threading
        threading.Thread(target=lambda: None).start()
예제 #26
0
def _init_gst():
    """Call once before importing GStreamer"""

    arch_key = "64" if sys.maxsize > 2**32 else "32"
    registry_name = "gst-registry-%s-%s.bin" % (sys.platform, arch_key)
    environ["GST_REGISTRY"] = os.path.join(get_cache_dir(), registry_name)

    assert "gi.repository.Gst" not in sys.modules

    import gi

    # We don't want python-gst, it changes API..
    assert "gi.overrides.Gst" not in sys.modules
    sys.modules["gi.overrides.Gst"] = None

    # blacklist some modules, simply loading can cause segfaults
    sys.modules["gst"] = None

    # We don't depend on Gst overrides, so make sure it's initialized.
    try:
        gi.require_version("Gst", "1.0")
        from gi.repository import Gst
    except (ValueError, ImportError):
        return

    if Gst.is_initialized():
        return

    from gi.repository import GLib

    try:
        ok, argv[:] = Gst.init_check(argv)
    except GLib.GError:
        print_e("Failed to initialize GStreamer")
        # Uninited Gst segfaults: make sure no one can use it
        sys.modules["gi.repository.Gst"] = None
    else:
        # monkey patching ahead
        _fix_gst_leaks()
예제 #27
0
    def start(self, params = None, last_return = None):
        """
Starts the GStreamer process und underlying library if applicable.

:param params: Parameter specified
:param last_return: The return value from the last hook called.

:since: v0.2.00
        """

        with self._instance_lock:
            if (self._glib_mainloop is None): self._glib_mainloop = GLib.get_mainloop_instance()
        #

        with Gstreamer._lock:
            if (not Gst.is_initialized()):
                Gst.segtrap_set_enabled(False)
                Gst.Registry.fork_set_enabled(False)

                if (not Gst.init_check(sys.argv)): raise IOException("GStreamer initialization failed")

                gst_version = Gst.version_string()
                if (self.log_handler is not None): self.log_handler.debug("#echo(__FILEPATH__)# -{0!r}.__init__()- reporting: {1} ready", self, gst_version, context = "pas_gapi_gstreamer")
예제 #28
0
파일: base.py 프로젝트: AstroPrint/AstroBox
	def __init__(self, device, size, rotation, onFatalError, mainLoop, debugLevel):

		if not Gst.init_check(None):
			raise ImportError

		if debugLevel > 0:
			Gst.debug_set_active(True)
			Gst.debug_set_default_threshold(debugLevel)

		self._onFatalError = onFatalError
		self._mainLop = mainLoop

		self._toreDownAlready = False

		#pipeline control
		self._currentPipelineState = None
		self._pipelineStateCondition = Condition()
		self._photoBinAttachDetachLock = Lock() #Make sure attach and detach operation wait for each other to complete

		self._pipeline = Gst.Pipeline()

		self._videoSrcBin = self._getVideoSrcBin(self._pipeline, device, size, rotation)
		self._videoEncBin = self._getVideoEncBin(size, rotation)
		self._photoCaptureBin = PhotoCaptureBin(self._onNoMorePhotos)

		self._pipeline.add(self._videoEncBin.bin)
		self._pipeline.add(self._photoCaptureBin.bin)

		self._bus = self._pipeline.get_bus()
		self._bus.set_flushing(True)

		self._busListener = BusListener(self._bus)
		self._busListener.addListener(Gst.MessageType.ERROR, self._onBusError)
		self._busListener.addListener(Gst.MessageType.EOS, self._onBusEos)
		self._busListener.addListener(Gst.MessageType.STATE_CHANGED, self._onBusStateChanged)
		self._busListener.addListener(Gst.MessageType.REQUEST_STATE, self._onRequestState)
		self._busListener.start()
예제 #29
0
#!/bin/python
# -*- coding: utf-8 -*-

# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers.

from core import debug
import time, threading

_gstreamerAvailable = False
try:
    import gi
    from gi.repository import GLib
    gi.require_version('Gst', '1.0')
    from gi.repository import Gst
    _gstreamerAvailable, args = Gst.init_check(None)
except Exception as e:
    _gstreamerAvailable = False
    _availableError = str(e)


class driver:
    def __init__(self):
        self._source = None
        self._sink = None
        self.volume = 1
        self._initialized = False

    def initialize(self, environment):
        self.env = environment
        global _gstreamerAvailable
예제 #30
0
        def play(self, uri):
            try:
                winsound.PlaySound(None, 0)
                winsound.PlaySound(url2pathname(uri[5:]),
                                    winsound.SND_FILENAME|winsound.SND_ASYNC)
            except RuntimeError:
                log.error("ERROR: RuntimeError while playing %s." % url2pathname(uri[5:]))

    sound_player = WinsoundPlayer()
else:
    try:
        from gi.repository import Gst
    except ImportError as e:
        log.error("ERROR: Unable to import gstreamer. All sound will be mute.\n%s" % e)
    else:
        if not Gst.init_check(None):
            log.error("ERROR: Unable to initialize gstreamer. All sound will be mute.")
        else:
            class GstPlayer(Player):
                def __init__(self):
                    self.player = Gst.ElementFactory.make("playbin", "player")
                    if self.player is None:
                        log.error('ERROR: Gst.ElementFactory.make("playbin", "player") failed')
                    else:
                        self.ready = True
                        fakesink = Gst.ElementFactory.make("fakesink", "fakesink")
                        self.player.set_property("video-sink", fakesink)
                        bus = self.player.get_bus()
                        bus.connect("message", self.onMessage)
                
                def onMessage(self, bus, message):
예제 #31
0
    def __init__(self):
        self.playing = False
        self.ispaused = False

        # A free example sound track
        self.uri = "file:///home/tj/my/antkillerfarm_rubbish/python/2012.mp3"

        # GTK window and widgets
        self.window = Gtk.Window()
        self.window.set_size_request(300, 50)
        self.window.set_title("My Gstreamer Player V1.0")

        vbox = Gtk.Box(Gtk.Orientation.HORIZONTAL, 0)
        vbox.set_margin_top(3)
        vbox.set_margin_bottom(3)
        self.window.add(vbox)

        self.playButtonImage = Gtk.Image()
        self.playButtonImage.set_from_icon_name("media-playback-start",
                                                Gtk.IconSize.BUTTON)
        self.playButton = Gtk.Button()
        self.playButton.add(self.playButtonImage)
        self.playButton.connect("clicked", self.playToggled)
        Gtk.Box.pack_start(vbox, self.playButton, False, False, 0)

        self.playButtonImage2 = Gtk.Image()
        self.playButtonImage2.set_from_icon_name("media-playback-pause",
                                                 Gtk.IconSize.BUTTON)
        self.playButton2 = Gtk.Button()
        self.playButton2.add(self.playButtonImage2)
        self.playButton2.connect("clicked", self.pauseToggled)
        self.playButton2.set_sensitive(False)
        Gtk.Box.pack_start(vbox, self.playButton2, False, False, 0)

        self.playButtonImage3 = Gtk.Image()
        self.playButtonImage3.set_from_icon_name("media-seek-forward",
                                                 Gtk.IconSize.BUTTON)
        self.playButton3 = Gtk.Button()
        self.playButton3.add(self.playButtonImage3)
        self.playButton3.connect("clicked", self.pauseToggled)
        self.playButton3.set_sensitive(False)
        Gtk.Box.pack_start(vbox, self.playButton3, False, False, 0)

        self.slider = Gtk.HScale()
        self.slider.set_margin_left(6)
        self.slider.set_margin_right(6)
        self.slider.set_draw_value(False)
        self.slider.set_range(0, 100)
        self.slider.set_increments(1, 10)
        #self.slider.connect("value-changed", self.sliderValueChanged)
        self.slider.connect("change-value", self.sliderChangeValue)
        Gtk.Box.pack_start(vbox, self.slider, True, True, 0)

        self.label = Gtk.Label(label='0:00')
        self.label.set_margin_left(6)
        self.label.set_margin_right(6)
        Gtk.Box.pack_start(vbox, self.label, False, False, 0)

        self.window.connect("destroy", self.playerQuit)
        self.window.show_all()

        # GStreamer Setup
        Gst.init_check(None)
        self.IS_GST010 = Gst.version()[0] == 0
        self.player = Gst.ElementFactory.make("playbin", "player")
        fakesink = Gst.ElementFactory.make("fakesink", "fakesink")
        self.player.set_property("video-sink", fakesink)
        bus = self.player.get_bus()
        #bus.add_signal_watch_full()
        bus.connect("message", self.on_message)
        self.player.connect("about-to-finish", self.on_finished)
예제 #32
0
 def __init__(self):
     Gst.init_check(None)
     self.player = Gst.ElementFactory.make("playbin", "onDemandPlayer")
     if not self.player:
         raise Exception('Gstreamer Playbin plugin not installed')
     self.bus = self.player.get_bus()
예제 #33
0
#!/usr/bin/env python3

import os, sys
path = "/usr/local/lib/gstreamer-1.0"
os.environ["GST_PLUGIN_PATH"] = path

from gi.repository import Gst

Gst.init(None)
if Gst.init_check(None):
    print("Wersja:", Gst.version())

    def __init__(self):
        self.playing = False
        self.ispaused = False
        self.isforward = False

        # A free example sound track
        self.src = "/home/tj/my/crazy/python/2012.avi"
        self.uri = "file://" + self.src

        # GTK window and widgets
        self.window = Gtk.Window()
        self.window.set_size_request(300,50)
        self.window.set_title("My Gstreamer Player V1.0")

        vbox = Gtk.Box(Gtk.Orientation.HORIZONTAL, 0)
        vbox.set_margin_top(3)
        vbox.set_margin_bottom(3)
        self.window.add(vbox)

        self.playButtonImage = Gtk.Image()
        self.playButtonImage.set_from_icon_name("media-playback-start", Gtk.IconSize.BUTTON)
        self.playButton = Gtk.Button()
        self.playButton.add(self.playButtonImage)
        self.playButton.connect("clicked", self.playToggled)
        Gtk.Box.pack_start(vbox, self.playButton, False, False, 0)

        self.pauseButtonImage = Gtk.Image()
        self.pauseButtonImage.set_from_icon_name("media-playback-pause", Gtk.IconSize.BUTTON)
        self.pauseButton = Gtk.Button()
        self.pauseButton.add(self.pauseButtonImage)
        self.pauseButton.connect("clicked", self.pauseToggled)
        self.pauseButton.set_sensitive(False)
        Gtk.Box.pack_start(vbox, self.pauseButton, False, False, 0)

        self.forwardButtonImage = Gtk.Image()
        self.forwardButtonImage.set_from_icon_name("media-seek-forward", Gtk.IconSize.BUTTON)
        self.forwardButton = Gtk.Button()
        self.forwardButton.add(self.forwardButtonImage)
        self.forwardButton.connect("clicked", self.forwardToggled)
        self.forwardButton.set_sensitive(False)
        Gtk.Box.pack_start(vbox, self.forwardButton, False, False, 0)

        self.slider = Gtk.HScale()
        self.slider.set_margin_left(6)
        self.slider.set_margin_right(6)
        self.slider.set_draw_value(False)
        self.slider.set_range(0, 100)
        self.slider.set_increments(1, 10)
        #self.slider.connect("value-changed", self.sliderValueChanged)
        self.slider.connect("change-value", self.sliderChangeValue)
        Gtk.Box.pack_start(vbox, self.slider, True, True, 0)

        self.label = Gtk.Label(label='0:00')
        self.label.set_margin_left(6)
        self.label.set_margin_right(6)
        Gtk.Box.pack_start(vbox, self.label, False, False, 0)

        self.window.connect("destroy", self.playerQuit)
        self.window.show_all()

        # GStreamer Setup
        Gst.init_check(None)
        self.IS_GST010 = Gst.version()[0] == 0

##        self.player = Gst.ElementFactory.make("playbin", "player")
##        fakesink = Gst.ElementFactory.make("fakesink", "fakesink")
##        self.player.set_property("video-sink", fakesink)

##        self.player = Gst.parse_launch("filesrc location="+self.src+\
##                                       " ! decodebin name=dmux dmux. ! \
##                                       queue ! audioconvert ! autoaudiosink \
##                                       dmux. ! queue ! videoconvert ! \
##                                       ximagesink")

        self.player = Gst.Pipeline.new("my_pippeline")
        self.source = Gst.ElementFactory.make("filesrc", "source");
        decoder = Gst.ElementFactory.make("decodebin", "decoder");
        self.audio_queue = Gst.ElementFactory.make("queue", "audio_queue")
        audio_convert = Gst.ElementFactory.make("audioconvert", "audio_convert")
        audio_sink = Gst.ElementFactory.make("autoaudiosink", "audio_sink")
        self.video_queue = Gst.ElementFactory.make("queue", "video_queue")
        video_convert = Gst.ElementFactory.make("videoconvert", "video_convert")
        video_sink = Gst.ElementFactory.make("ximagesink", "video_sink")
        if (not self.player or not self.source or not decoder \
            or not self.audio_queue or not audio_convert or not audio_sink \
            or not self.video_queue or not video_convert or not video_sink):
            print "Not all elements could be created."
            exit(-1)

        self.player.add(self.source)
        self.player.add(decoder)
        self.player.add(self.audio_queue)
        self.player.add(audio_convert)
        self.player.add(audio_sink)
        self.player.add(self.video_queue)
        self.player.add(video_convert)
        self.player.add(video_sink)

        res0 = self.source.link(decoder)
        res1 = self.audio_queue.link(audio_convert)
        res2 = audio_convert.link(audio_sink)
        res3 = self.video_queue.link(video_convert)
        res4 = video_convert.link(video_sink)
        if (not res0 or not res1 or not res2 or not res3 or not res4):
            print "Elements could not be linked."
            exit(-1)

##        audio_pad = decoder.get_request_pad("src_%u")
##        queue_audio_pad = audio_queue.get_static_pad("sink")
##        video_pad = decoder.get_request_pad("src_%u")
##        queue_video_pad = video_queue.get_static_pad("sink")
##        if (audio_pad.link(queue_audio_pad) != Gst.PadLinkReturn.OK or
##            video_pad.link(queue_video_pad) != Gst.PadLinkReturn.OK):
##            print "Decoder could not be linked."
##            exit(-1)
        decoder.connect("pad-added", self.pad_added_handler, 0)
        
        bus = self.player.get_bus()
        #bus.add_signal_watch_full()
        bus.connect("message", self.on_message)
예제 #35
0
def _gtk_init(icon=None):
    import gi

    try:
        # not sure if this is available under Windows
        gi.require_version("GdkX11", "3.0")
        from gi.repository import GdkX11
    except (ValueError, ImportError):
        pass

    gi.require_version("GLib", "2.0")
    gi.require_version("Gtk", "3.0")
    gi.require_version("Gdk", "3.0")
    gi.require_version("GObject", "2.0")
    gi.require_version("Pango", "1.0")
    gi.require_version("GdkPixbuf", "2.0")
    gi.require_version("Gio", "2.0")

    from gi.repository import Gtk, GObject, GLib, Gdk

    # add Gtk.TreePath.__getitem__/__len__ for PyGObject 3.2
    try:
        Gtk.TreePath()[0]
    except TypeError:
        Gtk.TreePath.__getitem__ = lambda self, index: list(self)[index]
        Gtk.TreePath.__len__ = lambda self: self.get_depth()

    # GTK+ 3.4+ constants
    if not hasattr(Gdk, "BUTTON_PRIMARY"):
        Gdk.BUTTON_PRIMARY = 1
        Gdk.BUTTON_MIDDLE = 2
        Gdk.BUTTON_SECONDARY = 3

    # Force menu/button image related settings. We might show too many atm
    # but this makes sure we don't miss cases where we forgot to force them
    # per widget.
    settings = Gtk.Settings.get_default()
    settings.set_property("gtk-button-images", True)
    settings.set_property("gtk-menu-images", True)

    # Make sure PyGObject includes support for foreign cairo structs
    some_window = Gtk.OffscreenWindow()
    some_window.show()
    try:
        some_window.get_surface()
    except TypeError:
        print_e("PyGObject is missing cairo support")
        exit(1)

    # CSS overrides
    style_provider = Gtk.CssProvider()
    style_provider.load_from_data("""
        /* Make GtkPaned look like in <=3.12, we depend on the spacing */
        GtkPaned {
            -GtkPaned-handle-size: 6;
            background-image: none;
            margin: 0;
        }
    """)
    Gtk.StyleContext.add_provider_for_screen(
        Gdk.Screen.get_default(), style_provider,
        Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)

    # https://bugzilla.gnome.org/show_bug.cgi?id=708676
    warnings.filterwarnings('ignore', '.*g_value_get_int.*', Warning)

    # We don't want python-gst, it changes API..
    assert "gi.overrides.Gst" not in sys.modules
    sys.modules["gi.overrides.Gst"] = None

    # We don't depend on Gst overrides, so make sure it's initialized.
    try:
        gi.require_version("Gst", "1.0")
        from gi.repository import Gst
    except (ValueError, ImportError):
        pass
    else:
        if not Gst.is_initialized():
            try:
                ok, argv = Gst.init_check(sys.argv)
            except GLib.GError:
                print_e("Failed to initialize GStreamer")
                # Uninited Gst segfaults: make sure no one can use it
                sys.modules["gi.repository.Gst"] = None
            else:
                sys.argv = argv

                # https://bugzilla.gnome.org/show_bug.cgi?id=710447
                import threading
                threading.Thread(target=lambda: None).start()

    # some code depends on utf-8 default encoding (pygtk used to set it)
    reload(sys)
    sys.setdefaultencoding("utf-8")

    # blacklist some modules, simply loading can cause segfaults
    sys.modules["gtk"] = None
    sys.modules["gpod"] = None
    sys.modules["glib"] = None
    sys.modules["gobject"] = None
    sys.modules["gnome"] = None

    from quodlibet.qltk import pygobject_version
    if pygobject_version < (3, 9):
        GObject.threads_init()

    theme = Gtk.IconTheme.get_default()
    theme.append_search_path(quodlibet.const.IMAGEDIR)

    if icon:
        Gtk.Window.set_default_icon_name(icon)
예제 #36
0
 def __init__(self):
     Gst.init_check(None)
     self.IS_GST010 = Gst.version()[0] == 0
     self.player = Gst.ElementFactory.make('playbin', None)
예제 #37
0
from __future__ import absolute_import

from threading import Lock
from gi.repository import GObject
from .Log import log

try:
    from gi.repository import Gst
    Gst.init_check(None)

except ImportError as e:
    log.error("Unable to import gstreamer. All sound will be mute.\n%s" % e)
    class Player (GObject.GObject):
        __gsignals__ = {
            'end': (GObject.SignalFlags.RUN_FIRST, None, ()),
            'error': (GObject.SignalFlags.RUN_FIRST, None, (object,))
        }
        def checkSound(self):
            self.emit("error", None)
        def play(self, uri):
            pass

else:
    class Player (GObject.GObject):
        __gsignals__ = {
            'end': (GObject.SignalFlags.RUN_FIRST, None, ()),
            'error': (GObject.SignalFlags.RUN_FIRST, None, (object,))
        }
        
        def __init__(self):
            GObject.GObject.__init__(self)
from raphodo.constants import (
    ThumbnailSize, ExtractionTask, ExtractionProcessing, ThumbnailCacheStatus,
    ThumbnailCacheDiskStatus
)
from raphodo.rpdfile import RPDFile, Video, Photo
from raphodo.constants import FileType
from raphodo.utilities import (
    stdchannel_redirected, show_errors, image_large_enough_fdo
)
from raphodo.filmstrip import add_filmstrip
from raphodo.cache import ThumbnailCacheSql, FdoCacheLarge, FdoCacheNormal
import raphodo.exiftool as exiftool
from raphodo.heif import have_heif_module, load_heif


have_gst = Gst.init_check(None)


def gst_version() -> str:
    """
    :return: version of gstreamer, if it exists and is functioning, else ''
    """

    if have_gst:
        try:
            return Gst.version_string().replace('GStreamer ', '')
        except Exception:
            pass
    return ''

예제 #39
0
# -*- coding: utf-8 -*-

# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers.

from fenrirscreenreader.core import debug
import time, threading
from fenrirscreenreader.core.soundDriver import soundDriver

_gstreamerAvailable = False
try:
    import gi        
    from gi.repository import GLib        
    gi.require_version('Gst', '1.0')
    from gi.repository import Gst
    _gstreamerAvailable, args = Gst.init_check(None)   
except Exception as e:
    _gstreamerAvailable = False
    _availableError = str(e)

class driver(soundDriver):
    def __init__(self):
        soundDriver.__init__(self)
        self._source = None
        self._sink = None
        
    def initialize(self, environment):
        self.env = environment
        global _gstreamerAvailable
        self._initialized = _gstreamerAvailable              
        if not self._initialized:
예제 #40
0
def main():
    logging.basicConfig(level=logging.INFO)
    options = get_options().parse_args()
    Gst.init_check(None)
    command = SAMPLE_PIPELINE
    if options.camera:
        command = CAMERA_PIPELINE
    pipe = pipeline.Pipe('sample', command)
    pipe.run()

    def capture_output():
        """Capture output to a file for a few seconds to demonstrate adding/removing pipeline elements"""
        filesink_bin = Gst.parse_bin_from_description(
            ' '.join([
                'queue', 'name=capture-queue', '!', 'filesink',
                'location=/var/www/capture.ts'
            ]), True)
        queue = filesink_bin.pads[0]  # ick!
        filesink_bin.set_state(Gst.State.PAUSED)
        source = pipe.components.output_tee
        pad = source.get_request_pad('src_2')

        def stop_capture():
            def on_blocked(*args, **named):
                pad.remove_probe(probe)
                pad.unlink(queue)
                pipe.pipeline.remove(filesink_bin)
                queue.send_event(Gst.Event.new_eos())
                # after we've finished, do cleanup on the filesink_bin
                return Gst.PadProbeReturn.OK

            probe = pad.add_probe(
                Gst.PadProbeType.BLOCK,
                on_blocked,
            )

        def on_blocked(*args, **named):
            pad.remove_probe(probe)
            pipe.pipeline.add(filesink_bin)
            pad.link(queue)
            pipe.pipeline.set_state(Gst.State.PLAYING)
            GObject.timeout_add(5000, stop_capture)
            return Gst.PadProbeReturn.OK

        probe = pad.add_probe(
            Gst.PadProbeType.BLOCK,
            on_blocked,
        )

    def rotate_pattern(*args, **named):
        videotest = pipe.components.videotest
        if not videotest:
            return
        pattern = videotest.get_property('pattern')
        pattern = (pattern + 1) % 24
        videotest.set_property('pattern', pattern)
        GObject.timeout_add(100, rotate_pattern)

    GObject.timeout_add(3000, capture_output)
    rotate_pattern()
    log.info("Muxer: %s", pipe.components.muxer)
    pipeline.LOOP.run()
예제 #41
0
def main():
    Gst.init_check(sys.argv)
    app = GUI()
    Gtk.main()
예제 #42
0
def main():
    GObject.threads_init()
    Gst.init_check(sys.argv)
    app = FlipBuqUI()
    Gtk.main()
    def __init__(self):
        self.playing = False
        self.ispaused = False

        # A free example sound track
        self.uri = "file:///home/tj/my/antkillerfarm_rubbish/python/2012.mp3"

        # GTK window and widgets
        self.window = Gtk.Window()
        self.window.set_size_request(300,50)
        self.window.set_title("My Gstreamer Player V1.0")

        vbox = Gtk.Box(Gtk.Orientation.HORIZONTAL, 0)
        vbox.set_margin_top(3)
        vbox.set_margin_bottom(3)
        self.window.add(vbox)

        self.playButtonImage = Gtk.Image()
        self.playButtonImage.set_from_icon_name("media-playback-start", Gtk.IconSize.BUTTON)
        self.playButton = Gtk.Button()
        self.playButton.add(self.playButtonImage)
        self.playButton.connect("clicked", self.playToggled)
        Gtk.Box.pack_start(vbox, self.playButton, False, False, 0)

        self.playButtonImage2 = Gtk.Image()
        self.playButtonImage2.set_from_icon_name("media-playback-pause", Gtk.IconSize.BUTTON)
        self.playButton2 = Gtk.Button()
        self.playButton2.add(self.playButtonImage2)
        self.playButton2.connect("clicked", self.pauseToggled)
        self.playButton2.set_sensitive(False)
        Gtk.Box.pack_start(vbox, self.playButton2, False, False, 0)

        self.playButtonImage3 = Gtk.Image()
        self.playButtonImage3.set_from_icon_name("media-seek-forward", Gtk.IconSize.BUTTON)
        self.playButton3 = Gtk.Button()
        self.playButton3.add(self.playButtonImage3)
        self.playButton3.connect("clicked", self.pauseToggled)
        self.playButton3.set_sensitive(False)
        Gtk.Box.pack_start(vbox, self.playButton3, False, False, 0)

        self.slider = Gtk.HScale()
        self.slider.set_margin_left(6)
        self.slider.set_margin_right(6)
        self.slider.set_draw_value(False)
        self.slider.set_range(0, 100)
        self.slider.set_increments(1, 10)
        #self.slider.connect("value-changed", self.sliderValueChanged)
        self.slider.connect("change-value", self.sliderChangeValue)
        Gtk.Box.pack_start(vbox, self.slider, True, True, 0)

        self.label = Gtk.Label(label='0:00')
        self.label.set_margin_left(6)
        self.label.set_margin_right(6)
        Gtk.Box.pack_start(vbox, self.label, False, False, 0)

        self.window.connect("destroy", self.playerQuit)
        self.window.show_all()

        # GStreamer Setup
        Gst.init_check(None)
        self.IS_GST010 = Gst.version()[0] == 0
        self.player = Gst.ElementFactory.make("playbin", "player")
        fakesink = Gst.ElementFactory.make("fakesink", "fakesink")
        self.player.set_property("video-sink", fakesink)
        bus = self.player.get_bus()
        #bus.add_signal_watch_full()
        bus.connect("message", self.on_message)
        self.player.connect("about-to-finish",  self.on_finished)
예제 #44
0
def main():
    Gst.init_check(sys.argv)  #inicializar GStreamer
    app = GUI()
    Gtk.main()
    def __init__(self):
        self.playing = False
        self.ispaused = False
        self.isforward = False

        # A free example sound track
        self.src = "/home/tj/my/crazy/python/2012.avi"
        self.uri = "file://" + self.src

        # GTK window and widgets
        self.window = Gtk.Window()
        self.window.set_size_request(300,50)
        self.window.set_title("My Gstreamer Player V1.0")

        vbox = Gtk.Box(Gtk.Orientation.HORIZONTAL, 0)
        vbox.set_margin_top(3)
        vbox.set_margin_bottom(3)
        self.window.add(vbox)

        self.playButtonImage = Gtk.Image()
        self.playButtonImage.set_from_icon_name("media-playback-start", Gtk.IconSize.BUTTON)
        self.playButton = Gtk.Button()
        self.playButton.add(self.playButtonImage)
        self.playButton.connect("clicked", self.playToggled)
        Gtk.Box.pack_start(vbox, self.playButton, False, False, 0)

        self.pauseButtonImage = Gtk.Image()
        self.pauseButtonImage.set_from_icon_name("media-playback-pause", Gtk.IconSize.BUTTON)
        self.pauseButton = Gtk.Button()
        self.pauseButton.add(self.pauseButtonImage)
        self.pauseButton.connect("clicked", self.pauseToggled)
        self.pauseButton.set_sensitive(False)
        Gtk.Box.pack_start(vbox, self.pauseButton, False, False, 0)

        self.forwardButtonImage = Gtk.Image()
        self.forwardButtonImage.set_from_icon_name("media-seek-forward", Gtk.IconSize.BUTTON)
        self.forwardButton = Gtk.Button()
        self.forwardButton.add(self.forwardButtonImage)
        self.forwardButton.connect("clicked", self.forwardToggled)
        self.forwardButton.set_sensitive(False)
        Gtk.Box.pack_start(vbox, self.forwardButton, False, False, 0)

        self.slider = Gtk.HScale()
        self.slider.set_margin_left(6)
        self.slider.set_margin_right(6)
        self.slider.set_draw_value(False)
        self.slider.set_range(0, 100)
        self.slider.set_increments(1, 10)
        #self.slider.connect("value-changed", self.sliderValueChanged)
        self.slider.connect("change-value", self.sliderChangeValue)
        Gtk.Box.pack_start(vbox, self.slider, True, True, 0)

        self.label = Gtk.Label(label='0:00')
        self.label.set_margin_left(6)
        self.label.set_margin_right(6)
        Gtk.Box.pack_start(vbox, self.label, False, False, 0)

        self.window.connect("destroy", self.playerQuit)
        self.window.show_all()

        # GStreamer Setup
        Gst.init_check(None)
        self.IS_GST010 = Gst.version()[0] == 0

##        self.player = Gst.ElementFactory.make("playbin", "player")
##        fakesink = Gst.ElementFactory.make("fakesink", "fakesink")
##        self.player.set_property("video-sink", fakesink)

        self.player = Gst.parse_launch("filesrc location="+self.src+\
                                       " ! decodebin name=dmux dmux. ! \
                                       queue ! audioconvert ! autoaudiosink \
                                       dmux. ! queue ! videoconvert ! \
                                       ximagesink")
        
        bus = self.player.get_bus()
        #bus.add_signal_watch_full()
        bus.connect("message", self.on_message)
예제 #46
0
def main():
	Gst.init_check(sys.argv)
	app = GUI()
	Gtk.main()
예제 #47
0
파일: player.py 프로젝트: nesterow/semgtk
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('Gst', '1.0')

from gi.repository import Gtk, Gst
Gst.init(None)
Gst.init_check(None)


class GstWidget(Gtk.Box):
    def __init__(self, pipeline):
        super().__init__()
        # Only setup the widget after the window is shown.
        self.connect('realize', self._on_realize)

        # Parse a gstreamer pipeline and create it.
        self._bin = Gst.parse_bin_from_description(pipeline, True)

    def _on_realize(self, widget):
        pipeline = Gst.Pipeline()
        factory = pipeline.get_factory()
        gtksink = factory.make('gtksink')
        pipeline.add(self._bin)
        pipeline.add(gtksink)
        # Link the pipeline to the sink that will display the video.
        self._bin.link(gtksink)
        self.pack_start(gtksink.props.widget, True, True, 0)
        gtksink.props.widget.show()
        # Start the video
        pipeline.set_state(Gst.State.PLAYING)
예제 #48
0
파일: sound_utils.py 프로젝트: pvagner/orca
 def __init__(self):
     if not gstreamerAvailable:
         return
     Gst.init_check()
예제 #49
0
파일: try.py 프로젝트: akshaydixi/gtk-works
	def __init__(self):
		Gst.init_check(sys.argv)
		self.builder = Gtk.Builder()
		self.builder.add_from_file("/home/akshay/yetAnotherWorkspace/glade/saregama.glade")
		self.builder.connect_signals(self)
예제 #50
0
        source.set_property('freq', 329.63)
        pipeline.add(source)
        pipeline.add(sink)
        source.link(sink)
        pipeline.set_state(Gst.State.PLAYING)

        GObject.timeout_add(5000, self.pipeline_stop, pipeline)
        #pipeline.set_state(Gst.State.NULL)
        entry = builder.get_object('entry1')
        entry.set_text('звук пошел')

    def pipeline_stop(self, pipeline):
        pipeline.set_state(Gst.State.NULL)
        return False

Gst.init_check(sys.argv)
builder = Gtk.Builder()
builder.add_from_file("audiobooks.glade")
builder.connect_signals(Handler())

liststore1 = builder.get_object('liststore1')
liststore1.append({'1 скок поскок'})

liststore2 = builder.get_object('liststore2')
liststore2.append({'1.mp3'})
liststore2.append({'2.mp3'})
liststore2.append({'3.mp3'})
liststore2.append({'4.mp3'})
liststore2.append({'5.mp3'})
liststore2.append({'6.mp3'})
liststore2.append({'7.mp3'})