コード例 #1
0
ファイル: codecs.py プロジェクト: ktosiu/lollypop
 def install(self):
     """
         Install missing plugins
     """
     try:
         context = GstPbutils.InstallPluginsContext.new()
         try:
             context.set_desktop_id('lollypop.desktop')
         except:
             pass  # Not supported by Ubuntu VIVID
         details = []
         for message in self._messages:
             detail = \
                 GstPbutils.missing_plugin_message_get_installer_detail(
                     message)
             details.append(detail)
         GstPbutils.install_plugins_async(
             details,
             context,
             self._null)
         if Lp.notify is not None:
             GLib.timeout_add(
                 10000,
                 Lp.notify.send,
                 _("Restart lollypop after installing codecs"))
     except Exception as e:
         print("Codecs::__init__(): %s" % e)
コード例 #2
0
    def __init__(self, parent_window):
        super().__init__()

        self._parent_window = parent_window

        self._playlist = PlayerPlaylist()
        self._playlist.connect('song-validated', self._on_song_validated)
        self._playlist.bind_property(
            'repeat-mode', self, 'repeat-mode',
            GObject.BindingFlags.SYNC_CREATE
            | GObject.BindingFlags.BIDIRECTIONAL)

        self._new_clock = True

        Gst.init(None)
        GstPbutils.pb_utils_init()

        self._gst_player = GstPlayer()
        self._gst_player.connect('clock-tick', self._on_clock_tick)
        self._gst_player.connect('eos', self._on_eos)
        self._gst_player.bind_property('duration', self, 'duration',
                                       GObject.BindingFlags.SYNC_CREATE)
        self._gst_player.bind_property('state', self, 'state',
                                       GObject.BindingFlags.SYNC_CREATE)

        root_window = parent_window.get_toplevel()
        self._inhibit_suspend = InhibitSuspend(root_window, self)

        self._lastfm = LastFmScrobbler()
コード例 #3
0
ファイル: pithos.py プロジェクト: just-digital/pithos
 def on_gst_element(self, bus, message):
     if GstPbutils.is_missing_plugin_message(message):
         if GstPbutils.install_plugins_supported():
             details = GstPbutils.missing_plugin_message_get_installer_detail(message)
             GstPbutils.install_plugins_async([details,], None, self.on_gst_plugin_installed, None)
         else:
             self.error_dialog(_("Missing codec"), None,
                     submsg=_("GStreamer is missing a plugin and it could not be automatically installed. Either manually install it or try another quality setting."))
コード例 #4
0
ファイル: pithos.py プロジェクト: Greenginer/pithos
 def on_gst_element(self, bus, message):
     if GstPbutils.is_missing_plugin_message(message):
         if GstPbutils.install_plugins_supported():
             details = GstPbutils.missing_plugin_message_get_installer_detail(message)
             GstPbutils.install_plugins_async([details,], None, self.on_gst_plugin_installed, None)
         else:
             self.error_dialog(_("Missing codec"), None,
                     submsg=_("GStreamer is missing a plugin and it could not be automatically installed. Either manually install it or try another quality setting."))
コード例 #5
0
ファイル: editorperspective.py プロジェクト: rebel3742/pitivi
    def _installPlugins(self, details, missingPluginsCallback):
        context = GstPbutils.InstallPluginsContext()
        if self.app.system.has_x11():
            context.set_xid(self.window.xid)

        res = GstPbutils.install_plugins_async(details, context,
                                               missingPluginsCallback)
        return res
コード例 #6
0
ファイル: gstplayer.py プロジェクト: glennimoss/pithos
 def _on_element(self, bus, message):
     if GstPbutils.is_missing_plugin_message(message):
         if GstPbutils.install_plugins_supported():
             details = (
                 GstPbutils.missing_plugin_message_get_installer_detail(
                     message))
             GstPbutils.install_plugins_async(
                 [details], None, self._plugin_installation_complete, None)
         else:
             self.emit("error", "Missing codec",
                       "GStreamer is missing a plugin and it could not be "
                       "automatically installed. Either manually install "
                       "it or try another quality setting.",
                       False)
コード例 #7
0
ファイル: mediaLibrary.py プロジェクト: tymofij/gframecatcher
 def __getMissingElement(self, message, window_id = 0):
     if gst.pygst_version < (0, 10, 10):
         print _("This version of gstreamer can't handle missing elements")
         return
     self.errors.append(str(message.structure["type"]))
     self.errors.append(str(message.structure["detail"]))
     self.errors.append(str(message.structure["name"]))
     detail = pbutils.missing_plugin_message_get_installer_detail(message)
     context = pbutils.InstallPluginsContext()
     
     if window_id:
         context.set_x_id(window_id)
         
     msg = pbutils.install_plugins_async([detail], context,self.__pbutils_plugin_installed_cb)
コード例 #8
0
    def __message(self, bus, message, librarian):
        if message.type == Gst.MessageType.EOS:
            print_d("Stream EOS")
            if not self._in_gapless_transition:
                self._source.next_ended()
            self._end(False)
        elif message.type == Gst.MessageType.TAG:
            self.__tag(message.parse_tag(), librarian)
        elif message.type == Gst.MessageType.ERROR:
            err, debug = message.parse_error()
            err = str(err).decode(const.ENCODING, 'replace')
            self._error(err)
        elif message.type == Gst.MessageType.STREAM_START:
            if self._in_gapless_transition:
                print_d("Stream changed")
                self._end(False)
        elif message.type == Gst.MessageType.ASYNC_DONE:
            if self._active_seeks:
                song, pos = self._active_seeks.pop(0)
                if song is self.song:
                    self.emit("seek", song, pos)
        elif message.type == Gst.MessageType.ELEMENT:
            message_name = message.get_structure().get_name()

            if message_name == "missing-plugin":
                self.stop()
                details = \
                    GstPbutils.missing_plugin_message_get_installer_detail(
                        message)
                if details is not None:
                    message = (_(
                        "No GStreamer element found to handle the following "
                        "media format: %(format_details)r") %
                        {"format_details": details})
                    print_w(message)

                    context = GstPbutils.InstallPluginsContext.new()

                    # TODO: track success
                    def install_done_cb(*args):
                        Gst.update_registry()
                    res = GstPbutils.install_plugins_async(
                        [details], context, install_done_cb, None)
                    print_d("Gstreamer plugin install result: %r" % res)
                    if res in (GstPbutils.InstallPluginsReturn.HELPER_MISSING,
                            GstPbutils.InstallPluginsReturn.INTERNAL_FAILURE):
                        self._error(message)

        return True
コード例 #9
0
    def __getMissingElement(self, message, window_id=0):
        if gst.pygst_version < (0, 10, 10):
            print _("This version of gstreamer can't handle missing elements")
            return
        self.errors.append(str(message.structure["type"]))
        self.errors.append(str(message.structure["detail"]))
        self.errors.append(str(message.structure["name"]))
        detail = pbutils.missing_plugin_message_get_installer_detail(message)
        context = pbutils.InstallPluginsContext()

        if window_id:
            context.set_x_id(window_id)

        msg = pbutils.install_plugins_async([detail], context,
                                            self.__pbutils_plugin_installed_cb)
コード例 #10
0
    def __init__(self, parent_window):
        GObject.GObject.__init__(self)
        self._parent_window = parent_window
        self.playlist = None
        self.playlistType = None
        self.playlistId = None
        self.playlistField = None
        self.currentTrack = None
        self.currentTrackUri = None
        self._lastState = Gst.State.PAUSED
        self.cache = AlbumArtCache.get_default()
        self._noArtworkIcon = self.cache.get_default_icon(ART_SIZE, ART_SIZE)
        self._loadingIcon = self.cache.get_default_icon(
            ART_SIZE, ART_SIZE, True)
        self._missingPluginMessages = []

        Gst.init(None)
        GstPbutils.pb_utils_init()

        self.discoverer = GstPbutils.Discoverer()
        self.discoverer.connect('discovered', self._on_discovered)
        self.discoverer.start()
        self._discovering_urls = {}

        self.player = Gst.ElementFactory.make('playbin', 'player')
        self.bus = self.player.get_bus()
        self.bus.add_signal_watch()
        self.setup_replaygain()

        self._settings = Gio.Settings.new('org.gnome.Music')
        self._settings.connect('changed::repeat',
                               self._on_repeat_setting_changed)
        self._settings.connect('changed::replaygain',
                               self._on_replaygain_setting_changed)
        self.repeat = self._settings.get_enum('repeat')
        self.replaygain = self._settings.get_value('replaygain') is not None
        self.toggle_replaygain(self.replaygain)

        self.bus.connect('message::state-changed', self._on_bus_state_changed)
        self.bus.connect('message::error', self._onBusError)
        self.bus.connect('message::element', self._on_bus_element)
        self.bus.connect('message::eos', self._on_bus_eos)
        self._setup_view()

        self.playlist_insert_handler = 0
        self.playlist_delete_handler = 0

        self._check_last_fm()
コード例 #11
0
    def __init__(self):
        GObject.GObject.__init__(self)
        self.playlist = None
        self.playlistType = None
        self.playlistId = None
        self.playlistField = None
        self.currentTrack = None
        self._lastState = Gst.State.PAUSED
        self.cache = AlbumArtCache.get_default()
        self._symbolicIcon = self.cache.make_default_icon(ART_SIZE, ART_SIZE)

        Gst.init(None)

        self.discoverer = GstPbutils.Discoverer()
        self.discoverer.connect('discovered', self._on_discovered)
        self.discoverer.start()
        self._discovering_urls = {}

        self.player = Gst.ElementFactory.make('playbin', 'player')
        self.bus = self.player.get_bus()
        self.bus.add_signal_watch()

        self._settings = Gio.Settings.new('org.gnome.Music')
        self._settings.connect('changed::repeat', self._on_settings_changed)
        self.repeat = self._settings.get_enum('repeat')

        self.bus.connect('message::state-changed', self._on_bus_state_changed)
        self.bus.connect('message::error', self._onBusError)
        self.bus.connect('message::eos', self._on_bus_eos)
        self._setup_view()

        self.playlist_insert_handler = 0
        self.playlist_delete_handler = 0
コード例 #12
0
ファイル: albumartcache.py プロジェクト: rz6iox/gnome-music
    def __init__(self):
        super().__init__()

        try:
            Gst.init(None)
            GstPbutils.pb_utils_init()
        except GLib.Error as error:
            logger.warning("Error: {}, {}".format(error.domain, error.message))
            return

        self._media_art = MediaArt.Process.new()

        self._album = None
        self._artist = None
        self._media = None
        self._path = None
コード例 #13
0
 def set_uri(self, uri):
     """Set the URI of the file to play."""
     self.ready = False
     self._playbin.props.uri = uri
     self.subtitle_text = ""
     try:
         # Find out the exact framerate to be able
         # to convert between position types.
         from gi.repository import GstPbutils
         discoverer = GstPbutils.Discoverer()
         self._info = discoverer.discover_uri(uri)
         streams = self._info.get_stream_list()
         stream_types = [x.get_stream_type_nick() for x in streams]
         if "video" not in stream_types:
             raise Exception(_("No video streams found"))
         stream = self._info.get_video_streams()[0]
         num = float(stream.get_framerate_num())
         denom = float(stream.get_framerate_denom())
         self.calc = aeidon.Calculator(num/denom)
         self.ready = True
     except Exception as error:
         title = _("Failed to initialize playback")
         dialog = gaupol.ErrorDialog(None, title, str(error))
         dialog.add_button(_("_OK"), Gtk.ResponseType.OK)
         dialog.set_default_response(Gtk.ResponseType.OK)
         gaupol.util.flash_dialog(dialog)
     else:
         # Make stream tags available from _playbin
         self._playbin.set_state(Gst.State.PAUSED)
         self._playbin.get_state(Gst.CLOCK_TIME_NONE)
コード例 #14
0
ファイル: embedded.py プロジェクト: christiands/rhythmbox
	def search (self, key, last_time, store, callback, *args):
		location = key.get_info("location")
		if location is None:
			print("not searching, we don't have a location")
			callback(args)
			return

		if location.startswith("file://") is False:
			print("not searching in non-local file %s" % location)
			callback(args)
			return

		# should avoid checking the playing entry, since the player already handles that

		self.callback = callback
		self.callback_args = args
		self.store = store
		self.search_key = key

		print("discovering %s" % location)
		self.discoverer = GstPbutils.Discoverer(timeout=Gst.SECOND*5)
		self.discoverer.connect('finished', self.finished_cb)
		self.discoverer.connect('discovered', self.discovered_cb)
		self.discoverer.start()
		self.discoverer.discover_uri_async(location)
コード例 #15
0
ファイル: player.py プロジェクト: rffontenelle/gaupol
 def set_uri(self, uri):
     """Set the URI of the file to play."""
     self.ready = False
     self._playbin.props.uri = uri
     # XXX: On Windows, we'd need HWND instead of XID,
     # but there seems to be no clear way to do this.
     # http://stackoverflow.com/q/23021327/653825
     self._xid = self.widget.get_window().get_xid()
     self.subtitle_text = ""
     try:
         # Find out the exact framerate to be able
         # to convert between position types.
         from gi.repository import GstPbutils
         discoverer = GstPbutils.Discoverer()
         self._info = discoverer.discover_uri(uri)
         stream = self._info.get_video_streams()[0]
         num = float(stream.get_framerate_num())
         denom = float(stream.get_framerate_denom())
         self.calc = aeidon.Calculator(num / denom)
         self.ready = True
     except Exception as error:
         title = _("Failed to initialize playback")
         dialog = gaupol.ErrorDialog(None, title, str(error))
         dialog.add_button(_("_OK"), Gtk.ResponseType.OK)
         dialog.set_default_response(Gtk.ResponseType.OK)
         gaupol.util.flash_dialog(dialog)
コード例 #16
0
ファイル: albumartcache.py プロジェクト: GNOME/gnome-music
    def __init__(self):
        super().__init__()

        try:
            Gst.init(None)
            GstPbutils.pb_utils_init()
        except GLib.Error as error:
            logger.warning("Error: {}, {}".format(error.domain, error.message))
            return

        self._media_art = MediaArt.Process.new()

        self._album = None
        self._artist = None
        self._media = None
        self._path = None
コード例 #17
0
ファイル: player.py プロジェクト: thisfred/quodlibet
    def __handle_missing_plugin(self, message):
        get_installer_detail = \
            GstPbutils.missing_plugin_message_get_installer_detail
        get_description = GstPbutils.missing_plugin_message_get_description

        details = get_installer_detail(message)
        if details is None:
            return

        self.stop()

        format_desc = get_description(message)
        title = _(u"No GStreamer element found to handle media format")
        error_details = _(u"Media format: %(format-description)s") % {
            "format-description": format_desc.decode("utf-8")}

        def install_done_cb(plugins_return, *args):
            print_d("Gstreamer plugin install return: %r" % plugins_return)
            Gst.update_registry()

        context = GstPbutils.InstallPluginsContext.new()
        res = GstPbutils.install_plugins_async(
            [details], context, install_done_cb, None)
        print_d("Gstreamer plugin install result: %r" % res)

        if res in (GstPbutils.InstallPluginsReturn.HELPER_MISSING,
                GstPbutils.InstallPluginsReturn.INTERNAL_FAILURE):
            self._error(PlayerError(title, error_details))
コード例 #18
0
ファイル: player.py プロジェクト: thisfred/quodlibet
    def __handle_missing_plugin(self, message):
        get_installer_detail = \
            GstPbutils.missing_plugin_message_get_installer_detail
        get_description = GstPbutils.missing_plugin_message_get_description

        details = get_installer_detail(message)
        if details is None:
            return

        self.stop()

        format_desc = get_description(message)
        title = _(u"No GStreamer element found to handle media format")
        error_details = _(u"Media format: %(format-description)s") % {
            "format-description": format_desc.decode("utf-8")
        }

        def install_done_cb(plugins_return, *args):
            print_d("Gstreamer plugin install return: %r" % plugins_return)
            Gst.update_registry()

        context = GstPbutils.InstallPluginsContext.new()
        res = GstPbutils.install_plugins_async([details], context,
                                               install_done_cb, None)
        print_d("Gstreamer plugin install result: %r" % res)

        if res in (GstPbutils.InstallPluginsReturn.HELPER_MISSING,
                   GstPbutils.InstallPluginsReturn.INTERNAL_FAILURE):
            self._error(PlayerError(title, error_details))
コード例 #19
0
    def __init__(self, parent_window):
        super().__init__()

        self._parent_window = parent_window
        self.playlist = None
        self.playlistType = None
        self.playlistId = None
        self.playlistField = None
        self.currentTrack = None
        self.currentTrackUri = None
        scale = parent_window.get_scale_factor()
        self.cache = AlbumArtCache(scale)
        self._loading_icon_surface = DefaultIcon(scale).get(
            DefaultIcon.Type.loading,
            ArtSize.XSMALL)
        self._missingPluginMessages = []

        Gst.init(None)
        GstPbutils.pb_utils_init()

        self.discoverer = GstPbutils.Discoverer()
        self.discoverer.connect('discovered', self._on_discovered)
        self.discoverer.start()
        self._discovering_urls = {}

        self.player = Gst.ElementFactory.make('playbin', 'player')
        self.bus = self.player.get_bus()
        self.bus.add_signal_watch()
        self.setup_replaygain()

        self._settings = Gio.Settings.new('org.gnome.Music')
        self._settings.connect('changed::repeat', self._on_repeat_setting_changed)
        self._settings.connect('changed::replaygain', self._on_replaygain_setting_changed)
        self.repeat = self._settings.get_enum('repeat')
        self.replaygain = self._settings.get_value('replaygain') is not None
        self.toggle_replaygain(self.replaygain)

        self.bus.connect('message::state-changed', self._on_bus_state_changed)
        self.bus.connect('message::error', self._onBusError)
        self.bus.connect('message::element', self._on_bus_element)
        self.bus.connect('message::eos', self._on_bus_eos)
        self._setup_view()

        self.playlist_insert_handler = 0
        self.playlist_delete_handler = 0

        self._lastfm = LastFmScrobbler()
コード例 #20
0
    def __init__(self, parent_window):
        GObject.GObject.__init__(self)
        self._parent_window = parent_window
        self.playlist = None
        self.playlistType = None
        self.playlistId = None
        self.playlistField = None
        self.currentTrack = None
        self.currentTrackUri = None
        self._lastState = Gst.State.PAUSED
        scale = parent_window.get_scale_factor()
        self.cache = AlbumArtCache(scale)
        self._loading_icon_surface = DefaultIcon(scale).get(
            DefaultIcon.Type.loading,
            ArtSize.xsmall)
        self._missingPluginMessages = []

        Gst.init(None)
        GstPbutils.pb_utils_init()

        self.discoverer = GstPbutils.Discoverer()
        self.discoverer.connect('discovered', self._on_discovered)
        self.discoverer.start()
        self._discovering_urls = {}

        self.player = Gst.ElementFactory.make('playbin', 'player')
        self.bus = self.player.get_bus()
        self.bus.add_signal_watch()
        self.setup_replaygain()

        self._settings = Gio.Settings.new('org.gnome.Music')
        self._settings.connect('changed::repeat', self._on_repeat_setting_changed)
        self._settings.connect('changed::replaygain', self._on_replaygain_setting_changed)
        self.repeat = self._settings.get_enum('repeat')
        self.replaygain = self._settings.get_value('replaygain') is not None
        self.toggle_replaygain(self.replaygain)

        self.bus.connect('message::state-changed', self._on_bus_state_changed)
        self.bus.connect('message::error', self._onBusError)
        self.bus.connect('message::element', self._on_bus_element)
        self.bus.connect('message::eos', self._on_bus_eos)
        self._setup_view()

        self.playlist_insert_handler = 0
        self.playlist_delete_handler = 0

        self._check_last_fm()
コード例 #21
0
ファイル: player_bin.py プロジェクト: gitter-badger/lollypop
 def __on_bus_element(self, bus, message):
     """
         Set elements for missings plugins
         @param bus as Gst.Bus
         @param message as Gst.Message
     """
     if GstPbutils.is_missing_plugin_message(message):
         self.__codecs.append(message)
コード例 #22
0
ファイル: player.py プロジェクト: new-na/Audio-Cutter
    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)
コード例 #23
0
ファイル: player_bin.py プロジェクト: Nikhil-z/lollypop
 def _on_bus_element(self, bus, message):
     """
         Set elements for missings plugins
         @param bus as Gst.Bus
         @param message as Gst.Message
     """
     if GstPbutils.is_missing_plugin_message(message):
         self._codecs.append(message)
コード例 #24
0
ファイル: preset.py プロジェクト: cfoch/pitivi
    def loadAll(self):
        """Loads profiles from GstEncodingTarget and add them to self.combo.

        Override from PresetManager
        """
        for target in GstPbutils.encoding_list_all_targets():
            if target.get_category() != GstPbutils.ENCODING_CATEGORY_FILE_EXTENSION:
                self._add_target(target)
コード例 #25
0
def get_video_info(filename):
    uri = pathlib.Path(filename).absolute().as_uri()
    discoverer = GstPbutils.Discoverer()
    info = discoverer.discover_uri(uri)

    streams = info.get_video_streams()
    assert len(streams) == 1
    return streams[0]
コード例 #26
0
ファイル: player.py プロジェクト: rz6iox/gnome-music
    def __init__(self):
        super().__init__()

        GstPbutils.pb_utils_init()

        self._songs = []
        self._shuffle_indexes = []
        self._current_index = 0

        self._type = -1
        self._id = -1

        self._validation_indexes = None
        self._discoverer = GstPbutils.Discoverer()
        self._discoverer.connect('discovered', self._on_discovered)
        self._discoverer.start()

        self.connect("notify::repeat-mode", self._on_repeat_mode_changed)
コード例 #27
0
    def loadAll(self):
        """Loads profiles from GstEncodingTarget and add them to self.combo.

        Override from PresetManager
        """
        for target in GstPbutils.encoding_list_all_targets():
            if target.get_category(
            ) != GstPbutils.ENCODING_CATEGORY_FILE_EXTENSION:
                self._add_target(target)
コード例 #28
0
 def _gst_plugins_base_check_version(self, major, minor, micro):
     gst_major, gst_minor, gst_micro, gst_nano = GstPbutils.plugins_base_version(
     )
     return ((gst_major > major)
             or (gst_major == major and gst_minor > minor)
             or (gst_major == major and gst_minor == minor
                 and gst_micro >= micro)
             or (gst_major == major and gst_minor == minor
                 and gst_micro + 1 == micro and gst_nano > 0))
コード例 #29
0
ファイル: player.py プロジェクト: GNOME/gnome-music
    def __init__(self):
        super().__init__()

        GstPbutils.pb_utils_init()

        self._songs = []
        self._shuffle_indexes = []
        self._current_index = 0

        self._type = -1
        self._id = -1

        self._validation_indexes = None
        self._discoverer = GstPbutils.Discoverer()
        self._discoverer.connect('discovered', self._on_discovered)
        self._discoverer.start()

        self.connect("notify::repeat-mode", self._on_repeat_mode_changed)
コード例 #30
0
ファイル: missing_plugin.py プロジェクト: exaile/exaile
def __handle_plugin_missing_message(message, engine):

    desc = GstPbutils.missing_plugin_message_get_description(message)
    installer_details = GstPbutils.missing_plugin_message_get_installer_detail(message)
    LOGGER.warn("A plugin for %s is missing, stopping playback", desc)

    user_message = _(
        "A GStreamer 1.x plugin for %s is missing. "
        "Without this software installed, Exaile will not be able to play the current file. "
        "Please install the required software on your computer. See %s for details."
    ) % (desc, MISSING_PLUGIN_URL)
    # TODO make URL clickable by utilizing xlgui.widgets.dialogs.MessageBar

    engine.stop()
    __notify_user_on_error(user_message, engine)
    if GstPbutils.install_plugins_supported():
        if __run_installer_helper(installer_details):
            return
    LOGGER.warn("Installation of GStreamer plugins not supported on this platform.")
コード例 #31
0
 def __init__(self, arg, uri=os.path.dirname(os.path.abspath(__file__))):
     self.arg = arg
     self.uri = uri
     stream = GstPbutils.Discoverer()
     path_1 = f'file://{self.arg}'
     path_2 = f'file://{uri}{self.arg}'
     try:
         self._info = stream.discover_uri(path_1)
     except GLib.Error:
         self._info = stream.discover_uri(path_2)
コード例 #32
0
ファイル: player.py プロジェクト: isabella232/gnome-music
    def __init__(self, application):
        super().__init__()

        GstPbutils.pb_utils_init()

        self._app = application
        self._log = application.props.log
        self._position = 0

        self._validation_songs = {}
        self._discoverer = GstPbutils.Discoverer()
        self._discoverer.connect("discovered", self._on_discovered)
        self._discoverer.start()

        self._coremodel = self._app.props.coremodel
        self._model = self._coremodel.props.playlist_sort
        self._model_recent = self._coremodel.props.recent_playlist

        self.connect("notify::repeat-mode", self._on_repeat_mode_changed)
コード例 #33
0
ファイル: missing_plugin.py プロジェクト: unkie/exaile
def __handle_plugin_missing_message(message, engine):

    desc = GstPbutils.missing_plugin_message_get_description(message)
    installer_details = GstPbutils.missing_plugin_message_get_installer_detail(message)
    LOGGER.warning("A plugin for %s is missing, stopping playback", desc)

    user_message = _(
        "A GStreamer 1.x plugin for %s is missing. "
        "Without this software installed, Exaile will not be able to play the current file. "
        "Please install the required software on your computer. See %s for details."
    ) % (desc, MISSING_PLUGIN_URL)
    # TODO make URL clickable by utilizing xlgui.widgets.dialogs.MessageBar

    engine.stop()
    __notify_user_on_error(user_message, engine)
    if GstPbutils.install_plugins_supported():
        if __run_installer_helper(installer_details):
            return
    LOGGER.warning("Installation of GStreamer plugins not supported on this platform.")
コード例 #34
0
	def on_sync_message(self, bus, message, window_id):
		# print 'On sync message called: ' + message.get_structure().get_name()
		if not message.get_structure() is None:
			if message.get_structure().get_name() == 'prepare-window-handle':
				# print 'Setting window xid'
				image_sink = message.src 
				image_sink.set_property('force-aspect-ratio', True)
				image_sink.set_window_handle(self.window_id)
			if message.get_structure().get_name() == 'missing-plugin':
				print 'Gstreamer missing plugin: ' + gstpb.missing_plugin_message_get_description(message)
コード例 #35
0
ファイル: lyrics.py プロジェクト: christiands/rhythmbox
    def search_tags(self):
        """
		Initiate fetching meta tags.

		Result will be handled in search_tags_result
		"""
        location = self.entry.get_playback_uri()
        self.discoverer = GstPbutils.Discoverer(timeout=Gst.SECOND * 3)
        self.discoverer.connect('discovered', self.search_tags_result)
        self.discoverer.start()
        self.discoverer.discover_uri_async(location)
コード例 #36
0
def __create_context():
    LOGGER.info("Initializing connector for GstPbutils...")
    cntxt = GstPbutils.InstallPluginsContext()
    cntxt.set_confirm_search(True)

    # See https://standards.freedesktop.org/desktop-entry-spec/latest/ape.html
    cntxt.set_desktop_id("exaile.desktop")
    # TODO
    # cntxt.set_startup_notification_id()
    # cntxt.set_xid()
    return cntxt
コード例 #37
0
    def gst_discover_duration(pathname):
        # use gstreamer to find get_duration
        print("gst_discover_duration")
        discoverer = GstPbutils.Discoverer()
        # try:
        d = discoverer.discover_uri('file://{}'.format(pathname))
        seconds = d.get_duration() / float(Gst.SECOND)
        #except :
        #    seconds=None

        return seconds
コード例 #38
0
ファイル: pithos.py プロジェクト: just-digital/pithos
    def on_gst_error(self, bus, message):
        err, debug = message.parse_error()
        logging.error("Gstreamer error: %s, %s, %s" % (err, debug, err.code))
        if self.current_song:
            self.current_song.message = "Error: "+str(err)

        self.gstreamer_error = str(err)
        self.gstreamer_errorcount_1 += 1

        if not GstPbutils.install_plugins_installation_in_progress():
            self.next_song()
コード例 #39
0
ファイル: pithos.py プロジェクト: Greenginer/pithos
    def on_gst_error(self, bus, message):
        err, debug = message.parse_error()
        logging.error("Gstreamer error: %s, %s, %s" % (err, debug, err.code))
        if self.current_song:
            self.current_song.message = "Error: "+str(err)

        self.gstreamer_error = str(err)
        self.gstreamer_errorcount_1 += 1

        if not GstPbutils.install_plugins_installation_in_progress():
            self.next_song()
コード例 #40
0
    def _start_plugin_installation(self, missing_plugin_messages, confirm_search):
        install_ctx = GstPbutils.InstallPluginsContext.new()

        if self._gst_plugins_base_check_version(1, 5, 0):
            install_ctx.set_desktop_id('org.gnome.Music.desktop')
            install_ctx.set_confirm_search(confirm_search)

            startup_id = '_TIME%u' % Gtk.get_current_event_time()
            install_ctx.set_startup_notification_id(startup_id)

        installer_details = []
        for message in missing_plugin_messages:
            installer_detail = GstPbutils.missing_plugin_message_get_installer_detail(message)
            installer_details.append(installer_detail)

        def on_install_done(res):
            # We get the callback too soon, before the installation has
            # actually finished. Do nothing for now.
            pass

        GstPbutils.install_plugins_async(installer_details, install_ctx, on_install_done)
コード例 #41
0
ファイル: player.py プロジェクト: saifulbkhan/gnome-music
    def _start_plugin_installation(self, missing_plugin_messages, confirm_search):
        install_ctx = GstPbutils.InstallPluginsContext.new()

        if self._gst_plugins_base_check_version(1, 5, 0):
            install_ctx.set_desktop_id('gnome-music.desktop')
            install_ctx.set_confirm_search(confirm_search)

            startup_id = '_TIME%u' % Gtk.get_current_event_time()
            install_ctx.set_startup_notification_id(startup_id)

        installer_details = []
        for message in missing_plugin_messages:
            installer_detail = GstPbutils.missing_plugin_message_get_installer_detail(message)
            installer_details.append(installer_detail)

        def on_install_done(res):
            # We get the callback too soon, before the installation has
            # actually finished. Do nothing for now.
            pass

        GstPbutils.install_plugins_async(installer_details, install_ctx, on_install_done)
コード例 #42
0
 def install(self):
     """
         Install missing plugins
     """
     if not GstPbutils.install_plugins_supported():
         return
     try:
         context = GstPbutils.InstallPluginsContext.new()
         try:
             context.set_desktop_id('org.gnome.Lollypop.desktop')
         except:
             pass  # Not supported by Ubuntu VIVID
         details = []
         for message in self._messages:
             detail = \
                 GstPbutils.missing_plugin_message_get_installer_detail(
                     message)
             details.append(detail)
         GstPbutils.install_plugins_async(details, context, self.__null)
     except Exception as e:
         print("Codecs::__init__(): %s" % e)
コード例 #43
0
    def on_message(self, bus, message):
        mtype = message.type
        # print(mtype)
        if mtype == Gst.MessageType.ERROR:
            print("we got an error, life is shit")
            err, debug = message.parse_error()
            print(err)
            print(debug)
            Gst.debug_bin_to_dot_file (self.pipeline, \
            Gst.DebugGraphDetails.ALL, 'transmageddon-debug-graph')
            #self.emit('got-error', err.message)
        elif mtype == Gst.MessageType.ELEMENT:
            if GstPbutils.is_missing_plugin_message(message):
                print("missing something")
                if self.missingplugin == False:  #don't think this is correct if more than one plugin installed
                    self.missingplugin = message
                    GstPbutils.missing_plugin_message_get_description(message)
                    GstPbutils.missing_plugin_message_get_installer_detail(
                        message)
                    self.uridecoder.set_state(Gst.State.NULL)
                    self.emit('missing-plugin')

        elif mtype == Gst.MessageType.ASYNC_DONE:
            self.emit('ready-for-querying')
        elif mtype == Gst.MessageType.EOS:
            self.usedstreamids = []
            #removing multipass cache file when done
            if (self.streamdata['multipass'] !=
                    0) and (self.streamdata['passcounter'] !=
                            self.streamdata['multipass']):
                if os.access(self.cachefile, os.F_OK):
                    os.remove(self.cachefile)
                    os.remove(self.cachefile + '.mbtree')
            # print(self.streamdata['passcounter'])
            self.emit('got-eos')
            self.pipeline.set_state(Gst.State.NULL)
        elif mtype == Gst.MessageType.APPLICATION:
            self.pipeline.set_state(Gst.State.NULL)
            self.pipeline.remove(self.uridecoder)
        return True
コード例 #44
0
ファイル: codecs.py プロジェクト: IxianPixel/lollypop
 def install(self):
     """
         Install missing plugins
     """
     try:
         context = GstPbutils.InstallPluginsContext.new()
         try:
             context.set_desktop_id('lollypop.desktop')
         except:
             pass  # Not supported by Ubuntu VIVID
         details = []
         for message in self._messages:
             detail = \
                 GstPbutils.missing_plugin_message_get_installer_detail(
                     message)
             details.append(detail)
         GstPbutils.install_plugins_async(
             details,
             context,
             self._null)
     except Exception as e:
         print("Codecs::__init__(): %s" % e)
コード例 #45
0
ファイル: gstplayer.py プロジェクト: GNOME/gnome-music
    def _start_plugin_installation(
            self, missing_plugin_messages, confirm_search):
        install_ctx = GstPbutils.InstallPluginsContext.new()
        application_id = self._application.props.application_id
        install_ctx.set_desktop_id(application_id + '.desktop')
        install_ctx.set_confirm_search(confirm_search)

        startup_id = "_TIME{}".format(Gtk.get_current_event_time())
        install_ctx.set_startup_notification_id(startup_id)

        installer_details = []
        get_details = GstPbutils.missing_plugin_message_get_installer_detail
        for message in missing_plugin_messages:
            installer_detail = get_details(message)
            installer_details.append(installer_detail)

        def on_install_done(res):
            # We get the callback too soon, before the installation has
            # actually finished. Do nothing for now.
            pass

        GstPbutils.install_plugins_async(
            installer_details, install_ctx, on_install_done)
コード例 #46
0
ファイル: gstplayer.py プロジェクト: glennimoss/pithos
    def _on_gst_error(self, bus, message):
        err, debug = message.parse_error()
        logging.error("Gstreamer error from %s: %s, %s, %s",
                      message.src, err, debug, err.code)

        if err.matches(Gst.ResourceError.quark(),
                       Gst.ResourceError.NOT_AUTHORIZED):
            err = 'Playlist entry expired'

        if self._current_song:
            self._current_song.message = "Error: " + str(err)

        if not GstPbutils.install_plugins_installation_in_progress():
            self.emit("song-ended")
コード例 #47
0
    def on_message(self, bus, message):
        mtype = message.type
        # print(mtype)
        if mtype == Gst.MessageType.ERROR:
            print("we got an error, life is shit")
            err, debug = message.parse_error()
            print(err)
            print(debug)
            Gst.debug_bin_to_dot_file(self.pipeline, Gst.DebugGraphDetails.ALL, "transmageddon-debug-graph")
            # self.emit('got-error', err.message)
        elif mtype == Gst.MessageType.ELEMENT:
            if GstPbutils.is_missing_plugin_message(message):
                print("missing something")
                if self.missingplugin == False:  # don't think this is correct if more than one plugin installed
                    self.missingplugin = message
                    GstPbutils.missing_plugin_message_get_description(message)
                    GstPbutils.missing_plugin_message_get_installer_detail(message)
                    self.uridecoder.set_state(Gst.State.NULL)
                    self.emit("missing-plugin")

        elif mtype == Gst.MessageType.ASYNC_DONE:
            self.emit("ready-for-querying")
        elif mtype == Gst.MessageType.EOS:
            self.usedstreamids = []
            # removing multipass cache file when done
            if (self.streamdata["multipass"] != 0) and (self.streamdata["passcounter"] != self.streamdata["multipass"]):
                if os.access(self.cachefile, os.F_OK):
                    os.remove(self.cachefile)
                    os.remove(self.cachefile + ".mbtree")
            # print(self.streamdata['passcounter'])
            self.emit("got-eos")
            self.pipeline.set_state(Gst.State.NULL)
        elif mtype == Gst.MessageType.APPLICATION:
            self.pipeline.set_state(Gst.State.NULL)
            self.pipeline.remove(self.uridecoder)
        return True
コード例 #48
0
ファイル: player.py プロジェクト: zsau/quodlibet
    def __handle_missing_plugin(self, message):
        get_installer_detail = \
            GstPbutils.missing_plugin_message_get_installer_detail
        get_description = GstPbutils.missing_plugin_message_get_description

        details = get_installer_detail(message)
        if details is None:
            return

        self.stop()

        format_desc = get_description(message)
        title = _(u"No GStreamer element found to handle media format")
        error_details = _(u"Media format: %(format-description)s") % {
            "format-description": format_desc}

        def install_done_cb(plugins_return, *args):
            print_d("Gstreamer plugin install return: %r" % plugins_return)
            Gst.update_registry()

        context = GstPbutils.InstallPluginsContext.new()

        # new in 1.6
        if hasattr(context, "set_desktop_id"):
            from gi.repository import Gtk
            context.set_desktop_id(app.id)

        # new in 1.6
        if hasattr(context, "set_startup_notification_id"):
            current_time = Gtk.get_current_event_time()
            context.set_startup_notification_id("_TIME%d" % current_time)

        gdk_window = app.window.get_window()
        if gdk_window:
            try:
                xid = gdk_window.get_xid()
            except AttributeError:  # non X11
                pass
            else:
                context.set_xid(xid)

        res = GstPbutils.install_plugins_async(
            [details], context, install_done_cb, None)
        print_d("Gstreamer plugin install result: %r" % res)

        if res in (GstPbutils.InstallPluginsReturn.HELPER_MISSING,
                GstPbutils.InstallPluginsReturn.INTERNAL_FAILURE):
            self._error(PlayerError(title, error_details))
コード例 #49
0
ファイル: player.py プロジェクト: saifulbkhan/gnome-music
    def _show_codec_confirmation_dialog(self, install_helper_name, missing_plugin_messages):
        dialog = MissingCodecsDialog(self._parent_window, install_helper_name)

        def on_dialog_response(dialog, response_type):
            if response_type == Gtk.ResponseType.ACCEPT:
                self._start_plugin_installation(missing_plugin_messages, False)

            dialog.destroy()

        descriptions = []
        for message in missing_plugin_messages:
            description = GstPbutils.missing_plugin_message_get_description(message)
            descriptions.append(description)

        dialog.set_codec_names(descriptions)
        dialog.connect('response', on_dialog_response)
        dialog.present()
コード例 #50
0
ファイル: missing_plugin.py プロジェクト: exaile/exaile
def handle_message(message, engine):
    """
        Handles `message` by checking whether it is a "missing plugin" message.
        If it is, takes all required steps to make sure that
            * playback is paused
            * the user is notified of the issue
            * the user gets a hint on which software to install

        @param message: a Gst.Message of type Gst.MessageType.Element
        @param engine: an instance of xl.player.gst.engine.ExaileGstEngine

        @return: True if the message was a "missing plugin" message and was
                    being handled. This does not mean that the plugin installed
                    successfully.
                 False if the message should be handled by some other code
                    because it is not related to a missing plugin.
    """
    if not GstPbutils.is_missing_plugin_message(message):
        return False

    __handle_plugin_missing_message(message, engine)
    return True
コード例 #51
0
ファイル: missing_plugin.py プロジェクト: exaile/exaile
def __run_installer_helper(installer_details):
    """

        @return True if the helper might have run. False if did not run for
                    sure.
    """
    cntxt = __create_context()

    LOGGER.info("Prompting user to install missing codec(s): %s", installer_details)

    start_result = GstPbutils.install_plugins_async(
        [installer_details], cntxt, __installer_finished_callback
    )
    LOGGER.debug(
        "GstPbutils.install_plugins_async() return value: %s",
        GstPbutils.InstallPluginsReturn.get_name(start_result),
    )
    if start_result == GstPbutils.InstallPluginsReturn.INTERNAL_FAILURE:
        # should only happen when there is a bug in Exaile or its libs:
        LOGGER.error("Internal failure starting assisted GStreamer plugin installation")
        return False
    elif start_result == GstPbutils.InstallPluginsReturn.HELPER_MISSING:
        # we expect that to happen on some platforms
        LOGGER.warn("Helper missing for assisted installation of Gstreamer plugins")
        return False
    elif start_result == GstPbutils.InstallPluginsReturn.INSTALL_IN_PROGRESS:
        LOGGER.warn("Another assisted plugin installation is already in progress")
        return False
    elif start_result == GstPbutils.InstallPluginsReturn.STARTED_OK:
        LOGGER.info("Successfully started assisted GStreamer plugin installation")
        return True
    else:
        LOGGER.error(
            "Code should not be reached. "
            "Unexpected return value from install_plugins_async: %s",
            GstPbutils.InstallPluginsReturn.get_name(start_result),
        )
        return False
コード例 #52
0
ファイル: playlist_example.py プロジェクト: Dorry/PyCCTV_NVR
                pos = dur
            else:
                pos = pos + 10*Gst.SECOND
            self.slider.set_value(float(pos)/Gst.SECOND)

    def on_next_clicked(self, widget):
        self.play_index += 1
        
        if self.play_index == (len(self.playlist) - 1):
            self.next_btn.set_sensitive(False)
            
        if not self.prev_btn.get_sensitive():
            self.prev_btn.set_sensitive(True)
            
        self.on_stop_clicked(None)
        self._set_uri()
        self.on_play_clicked(None)
        
    
if __name__ == '__main__':
    from gi.repository import GObject
    GObject.threads_init()
    Gst.init(None)
    GstPbutils.pb_utils_init()
    
    vp = VideoPlayer()
    vp.connect('destroy', Gtk.main_quit)
    #vp.set_autostart(False)
    vp.get_videos()
    vp.run()
    Gtk.main()
コード例 #53
0
ファイル: player_bin.py プロジェクト: serkanalgur/lollypop
 def _on_bus_element(self, bus, message):
     if GstPbutils.is_missing_plugin_message(message):
         if self._codecs is not None:
             self._codecs.append(message)
コード例 #54
0
ファイル: tagreader.py プロジェクト: ktosiu/lollypop
 def init_discover(self):
     """
         Init discover
     """
     GstPbutils.pb_utils_init()
     self._tagreader = GstPbutils.Discoverer.new(10*Gst.SECOND)
コード例 #55
0
ファイル: player.py プロジェクト: saifulbkhan/gnome-music
 def _gst_plugins_base_check_version(self, major, minor, micro):
     gst_major, gst_minor, gst_micro, gst_nano = GstPbutils.plugins_base_version()
     return ((gst_major > major) or
             (gst_major == major and gst_minor > minor) or
             (gst_major == major and gst_minor == minor and gst_micro >= micro) or
             (gst_major == major and gst_minor == minor and gst_micro + 1 == micro and gst_nano > 0))
コード例 #56
0
ファイル: player.py プロジェクト: saifulbkhan/gnome-music
 def _on_bus_element(self, bus, message):
     if GstPbutils.is_missing_plugin_message(message):
         self._missingPluginMessages.append(message)
コード例 #57
0
ファイル: test_render.py プロジェクト: jubayed/pitivi
def encoding_target_exists(tname):
    """Checks if a GstEncodingTarget called @name exists."""
    for target in GstPbutils.encoding_list_all_targets():
        if tname in target.get_name().split(";"):
            return True, ""
    return False, "EncodingTarget %s not present on the system" % tname
コード例 #58
0
ファイル: codecs.py プロジェクト: TainakaDrums/lollypop
 def __init__(self):
     """
         Init installer
     """
     GstPbutils.pb_utils_init()
     self._messages = []