Python gi.repository.Gst.CLOCK_TIME_NONE Examples
The following are 18
code examples of gi.repository.Gst.CLOCK_TIME_NONE().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
gi.repository.Gst
, or try the search function
.
Example #1
Source File: player.py From lplayer with MIT License | 6 votes |
def set_position(self, position): if self.player is not None: self.player.get_state(Gst.CLOCK_TIME_NONE) self.player.set_state(Gst.State.PAUSED) try: assert self.player.seek_simple(Gst.Format.TIME, Gst.SeekFlags.FLUSH, position * Gst.SECOND) self.player.get_state(Gst.CLOCK_TIME_NONE) pos = self.player.query_position(Gst.Format.TIME)[1] self.player.seek(self.speed, Gst.Format.TIME, Gst.SeekFlags.FLUSH, Gst.SeekType.SET, pos, Gst.SeekType.NONE, -1) except AssertionError as e: print(e) self.player.set_state(Gst.State.PLAYING)
Example #2
Source File: player.py From Audio-Cutter with GNU General Public License v3.0 | 6 votes |
def __init__(self): GObject.GObject.__init__(self) GstPbutils.pb_utils_init() self._discoverer = GstPbutils.Discoverer.new(10 * Gst.SECOND) self.is_playing = False self.filepath = None self._duration = Gst.CLOCK_TIME_NONE self.asset = None self._playbin = Gst.ElementFactory.make("playbin", "player") bus = self._playbin.get_bus() bus.add_signal_watch() bus.connect("message::error", self.__on_bus_error) bus.connect("message::eos", self.__on_bus_eos) bus.connect("message::element", self.__on_bus_element) bus.connect("message::stream-start", self._on_stream_start)
Example #3
Source File: player.py From pomodoro-indicator with GNU General Public License v3.0 | 6 votes |
def set_position(self, position): if self.player is not None: self.player.get_state(Gst.CLOCK_TIME_NONE) self.player.set_state(Gst.State.PAUSED) try: assert self.player.seek_simple(Gst.Format.TIME, Gst.SeekFlags.FLUSH, position * Gst.SECOND) self.player.get_state(Gst.CLOCK_TIME_NONE) pos = self.player.query_position(Gst.Format.TIME)[1] self.player.seek(self.speed, Gst.Format.TIME, Gst.SeekFlags.FLUSH, Gst.SeekType.SET, pos, Gst.SeekType.NONE, -1) except AssertionError as e: print(e) self.player.set_state(Gst.State.PLAYING)
Example #4
Source File: player.py From pomodoro-indicator with GNU General Public License v3.0 | 5 votes |
def get_status(self): ''' Get the status of the player ''' if self.player is not None: if self.player.get_state(Gst.CLOCK_TIME_NONE)[1] ==\ Gst.State.PLAYING: return Status.PLAYING elif self.player.get_state(Gst.CLOCK_TIME_NONE)[1] ==\ Gst.State.PAUSED: return Status.PAUSED return Status.STOPPED
Example #5
Source File: playsound.py From playsound with MIT License | 5 votes |
def _playsoundNix(sound, block=True): """Play a sound using GStreamer. Inspired by this: https://gstreamer.freedesktop.org/documentation/tutorials/playback/playbin-usage.html """ if not block: raise NotImplementedError( "block=False cannot be used on this platform yet") # pathname2url escapes non-URL-safe characters import os try: from urllib.request import pathname2url except ImportError: # python 2 from urllib import pathname2url import gi gi.require_version('Gst', '1.0') from gi.repository import Gst Gst.init(None) playbin = Gst.ElementFactory.make('playbin', 'playbin') if sound.startswith(('http://', 'https://')): playbin.props.uri = sound else: playbin.props.uri = 'file://' + pathname2url(os.path.abspath(sound)) set_result = playbin.set_state(Gst.State.PLAYING) if set_result != Gst.StateChangeReturn.ASYNC: raise PlaysoundException( "playbin.set_state returned " + repr(set_result)) # FIXME: use some other bus method than poll() with block=False # https://lazka.github.io/pgi-docs/#Gst-1.0/classes/Bus.html bus = playbin.get_bus() bus.poll(Gst.MessageType.EOS, Gst.CLOCK_TIME_NONE) playbin.set_state(Gst.State.NULL)
Example #6
Source File: audiotsmcli_gst.py From audiotsm with MIT License | 5 votes |
def save(self, path): """Save the output of the TSM procedure to path, then quit the GObject loop.""" self.sink.set_property('location', path) self.set_state(Gst.State.PAUSED) self.get_state(Gst.CLOCK_TIME_NONE) self.playbin.seek(self._speed, Gst.Format.BYTES, Gst.SeekFlags.FLUSH, Gst.SeekType.SET, 0, Gst.SeekType.NONE, -1) self.set_state(Gst.State.PLAYING)
Example #7
Source File: playsound.py From goreviewpartner with GNU General Public License v3.0 | 5 votes |
def _playsoundNix(sound, block=True): """Play a sound using GStreamer. Inspired by this: https://gstreamer.freedesktop.org/documentation/tutorials/playback/playbin-usage.html """ if not block: raise NotImplementedError( "block=False cannot be used on this platform yet") # pathname2url escapes non-URL-safe characters import os try: from urllib.request import pathname2url except ImportError: # python 2 from urllib import pathname2url import gi gi.require_version('Gst', '1.0') from gi.repository import Gst Gst.init(None) playbin = Gst.ElementFactory.make('playbin', 'playbin') if sound.startswith(('http://', 'https://')): playbin.props.uri = sound else: playbin.props.uri = 'file://' + pathname2url(os.path.abspath(sound)) set_result = playbin.set_state(Gst.State.PLAYING) if set_result != Gst.StateChangeReturn.ASYNC: raise PlaysoundException( "playbin.set_state returned " + repr(set_result)) # FIXME: use some other bus method than poll() with block=False # https://lazka.github.io/pgi-docs/#Gst-1.0/classes/Bus.html bus = playbin.get_bus() bus.poll(Gst.MessageType.EOS, Gst.CLOCK_TIME_NONE) playbin.set_state(Gst.State.NULL)
Example #8
Source File: util.py From AstroBox with GNU Affero General Public License v3.0 | 5 votes |
def waitToReachState(element, state, timeout= 3.0, attempts= 1): import logging while attempts: stateReturn, currentState, pending = element.get_state( (timeout * Gst.SECOND) if timeout != Gst.CLOCK_TIME_NONE else Gst.CLOCK_TIME_NONE) if currentState == state and ( stateReturn == Gst.StateChangeReturn.SUCCESS or stateReturn == Gst.StateChangeReturn.NO_PREROLL ): return True attempts -= 1 if attempts: time.sleep(0.1) return False
Example #9
Source File: player.py From pomodoro-indicator with GNU General Public License v3.0 | 5 votes |
def get_duration(self): if self.player is not None: self.player.get_state(Gst.CLOCK_TIME_NONE) duration_nanosecs = self.player.query_duration(Gst.Format.TIME)[1] duration = float(duration_nanosecs) / Gst.SECOND return duration return 0
Example #10
Source File: player.py From pomodoro-indicator with GNU General Public License v3.0 | 5 votes |
def get_position(self): if self.player is not None: self.player.get_state(Gst.CLOCK_TIME_NONE) nanosecs = self.player.query_position(Gst.Format.TIME)[1] position = float(nanosecs) / Gst.SECOND return position return 0
Example #11
Source File: player.py From pomodoro-indicator with GNU General Public License v3.0 | 5 votes |
def play(self): ''' Play the player ''' if self.player is not None: self.player.set_state(Gst.State.PLAYING) self.player.get_state(Gst.CLOCK_TIME_NONE) self.player.get_by_name('removesilence').set_property( 'remove', self.removesilence) self.player.get_by_name('volume').set_property('volume', self.volume) self.player.get_by_name('equalizer').set_property( 'band0', self.equalizer['band0']) self.player.get_by_name('equalizer').set_property( 'band1', self.equalizer['band1']) self.player.get_by_name('equalizer').set_property( 'band2', self.equalizer['band2']) self.player.get_by_name('equalizer').set_property( 'band3', self.equalizer['band3']) self.player.get_by_name('equalizer').set_property( 'band4', self.equalizer['band4']) self.player.get_by_name('equalizer').set_property( 'band5', self.equalizer['band5']) self.player.get_by_name('equalizer').set_property( 'band6', self.equalizer['band6']) self.player.get_by_name('equalizer').set_property( 'band7', self.equalizer['band7']) self.player.get_by_name('equalizer').set_property( 'band8', self.equalizer['band8']) self.player.get_by_name('equalizer').set_property( 'band9', self.equalizer['band9']) pos = self.player.query_position(Gst.Format.TIME)[1] self.player.seek(self.speed, Gst.Format.TIME, Gst.SeekFlags.FLUSH, Gst.SeekType.SET, pos, Gst.SeekType.NONE, -1) self.status = Status.PLAYING self.emit('started', self.get_position())
Example #12
Source File: gstreamer.py From project-posenet with Apache License 2.0 | 5 votes |
def run(self): # Start inference worker. self.running = True inf_worker = threading.Thread(target=self.inference_loop) inf_worker.start() render_worker = threading.Thread(target=self.render_loop) render_worker.start() # Run pipeline. self.pipeline.set_state(Gst.State.PLAYING) self.pipeline.get_state(Gst.CLOCK_TIME_NONE) # We're high latency on higher resolutions, don't drop our late frames. if self.overlaysink: sinkelement = self.overlaysink.get_by_interface(GstVideo.VideoOverlay) else: sinkelement = self.pipeline.get_by_interface(GstVideo.VideoOverlay) sinkelement.set_property('sync', False) sinkelement.set_property('qos', False) try: Gtk.main() except: pass # Clean up. self.pipeline.set_state(Gst.State.NULL) while GLib.MainContext.default().iteration(False): pass with self.condition: self.running = False self.condition.notify_all() inf_worker.join() render_worker.join()
Example #13
Source File: audio_graph.py From Audio-Cutter with GNU General Public License v3.0 | 5 votes |
def nsToPixelAccurate(cls, duration): """Returns the pixel equivalent of the specified duration.""" # Here, a long time ago (206f3a05), a pissed programmer said: # DIE YOU CUNTMUNCH CLOCK_TIME_NONE UBER STUPIDITY OF CRACK BINDINGS !! if duration == Gst.CLOCK_TIME_NONE: return 0 return ((float(duration) / Gst.SECOND) * cls.zoomratio)
Example #14
Source File: audio_graph.py From Audio-Cutter with GNU General Public License v3.0 | 5 votes |
def nsToPixel(cls, duration): """Returns the pixel equivalent of the specified duration""" # Here, a long time ago (206f3a05), a pissed programmer said: # DIE YOU CUNTMUNCH CLOCK_TIME_NONE UBER STUPIDITY OF CRACK BINDINGS !! if duration == Gst.CLOCK_TIME_NONE: return 0 return int((float(duration) / Gst.SECOND) * cls.zoomratio)
Example #15
Source File: player.py From lplayer with MIT License | 5 votes |
def get_duration(self): if self.player is not None: self.player.get_state(Gst.CLOCK_TIME_NONE) duration_nanosecs = self.player.query_duration(Gst.Format.TIME)[1] duration = float(duration_nanosecs) / Gst.SECOND return duration return 0
Example #16
Source File: player.py From lplayer with MIT License | 5 votes |
def get_position(self): if self.player is not None: self.player.get_state(Gst.CLOCK_TIME_NONE) nanosecs = self.player.query_position(Gst.Format.TIME)[1] position = float(nanosecs) / Gst.SECOND return position return 0
Example #17
Source File: player.py From lplayer with MIT License | 5 votes |
def play(self): ''' Play the player ''' if self.player is not None: self.player.set_state(Gst.State.PLAYING) self.player.get_state(Gst.CLOCK_TIME_NONE) self.player.get_by_name('removesilence').set_property( 'remove', self.removesilence) self.player.get_by_name('volume').set_property('volume', self.volume) self.player.get_by_name('amplification').set_property( 'amplification', self.amplification) equalizer = self.player.get_by_name('equalizer') for i in range(0, 18): band = 'band{0}'.format(i) if band in self.equalizer.keys(): equalizer.get_child_by_index(i).set_property( 'gain', self.equalizer[band]) else: equalizer.get_child_by_index(i).set_property( 'gain', 0) pos = self.player.query_position(Gst.Format.TIME)[1] self.player.seek(self.speed, Gst.Format.TIME, Gst.SeekFlags.FLUSH, Gst.SeekType.SET, pos, Gst.SeekType.NONE, -1) self.status = Status.PLAYING self.emit('started', self.get_position())
Example #18
Source File: player.py From lplayer with MIT License | 5 votes |
def get_status(self): ''' Get the status of the player ''' if self.player is not None: if self.player.get_state(Gst.CLOCK_TIME_NONE)[1] ==\ Gst.State.PLAYING: return Status.PLAYING elif self.player.get_state(Gst.CLOCK_TIME_NONE)[1] ==\ Gst.State.PAUSED: return Status.PAUSED return Status.STOPPED