def run(self): self.xmms = xmmsclient.XMMS('PyXMMS') try: self.xmms.connect(os.getenv("XMMS_PATH")) except IOError as detail: print("Connection failed:" + str(detail)) sys.exit(1) self.xmms.playback_current_id(self._get_info) self.xmms.broadcast_playback_current_id(self._get_info) while not self.thread.stopflag.is_set(): fd = self.xmms.get_fd() if self.xmms.want_ioout(): self.xmms.ioout() (i, o, e) = select.select([fd], [], [fd], 0.1) if i and i[0] == fd: self.xmms.ioin() if e and e[0] == fd: self.xmms.disconnect() self.thread.stopflag.set() nerve.log("exiting XMMS2 maintenance thread.")
def __init__(self, path=None, name='ccx2'): super(XmmsService, self).__init__() self.xmms = xmmsclient.XMMS(name) self.xmms_s = xmmsclient.XMMSSync(name + '-sync') self.path = path or os.environ.get("XMMS_PATH", None) self.connected = False self.connect()
def reconnect(self): '''reconnect, only call if disconnected. return True if connected''' try: self.client = xmmsclient.XMMS("emesene2") self.client.connect(None) return True except IOError: return False
def __init__(self): self.ml = gobject.MainLoop(None, False) self.xmms = xmmsclient.XMMS("ubuntu-sound-menu") try: self.xmms.connect(os.getenv("XMMS_PATH"), self.dieme) except IOError, detail: print "Connection failed:", detail sys.exit(1)
def __init__(self, options): self.x = xmmsclient.XMMS('VIM') try: self.x.connect() except IOError: os.system('xmms2-launcher > /dev/null') self.x.connect() self.options = options self.system_encoding = locale.getdefaultlocale()[1]
def __init__ (self): panflute.daemon.connector.PollingConnector.__init__ (self, "xmms2", "XMMS2") # Note that syncronous and asychronous calls on the same connection # tend to raise libxmmsclient errors, so we'll use separate connections # for each type of call. We'll use async when we can and sync when we # must. self.__async = xmmsclient.XMMS ("Panflute") self.__sync_connector = None self.__async_connector = None
def __init__(self): self.xmms = xmmsclient.XMMS("Xmms2Base") try: self.xmms.connect(os.getenv("XMMS_PATH")) except IOError, detail: print "connection to xmms2d failed, restarting" os.system("xmms2-launcher") try: self.xmms.connect(os.getenv("XMMS_PATH")) except: print "Restart of xmms2d failed" sys.exit(1)
def __wm_init__(self): """Create a mode window message and connect to the XMMS2 server.""" self.wm_xmms2_message = modewindow.Message(self.mw_xmms2_position, self.mw_xmms2_justification) self.mw_xmms2_connection = xmmsclient.XMMS("mw_xmms2") self.mw_xmms2_connect () for s in self.screens: s.modewindow_add_message(self.wm_xmms2_message) self.dispatch.add_handler(XMMS2TimerEvent, self.mw_xmms2_tick) self.dispatch.add_handler(XMMS2ReconnectEvent, self.mw_xmms2_reconnect) self.mw_xmms2_update()
def __init__(self, conf): musicapplet.player.PluginBase.__init__(self, conf, INFO["name"], INFO["icon-name"]) import xmmsclient self.min_rating = 0.0 self.max_rating = 5.0 self.__client = xmmsclient.XMMS("MusicApplet") self.__connector = None self.__poll_source = None self.__current_id = 0 self.__art_url = None
def prepare_single (self, prefix, user, password): """ Perform setup before each test. """ self.rmdirs ("~/.config/xmms2") command = os.path.join (prefix, "bin/xmms2-launcher") launcher = self.run_command ([command]) launcher.wait () self.__xmms = xmmsclient.XMMS ("Panflute-Tester") self.__xmms.connect (os.getenv ("XMMS_PATH")) result = self.__xmms.playlist_clear () result.wait () for uri in self.TONE_URIS: result = self.__xmms.playlist_add_url (uri) result.wait ()
class XMMS2(Control, IMusic): CLIENT_NAME = 'gDesklets-XMMS2' def __init__(self): self._current = -1 self._server = None self._artist = "" self._album = "" self._title = "" self._tracknr = None self._duration = None self._date = None self._genre = None self._playtime = 0 self._start = False self._albumart = None # Stores the result of the currently queried media info and playtime self._media_info_res = None self._confdir = os.path.join(xmmsclient.userconfdir_get(), 'clients', XMMS2.CLIENT_NAME) Control.__init__(self) #self._add_timer(500, self.__start) def __set_server(self, value): self._server = value def __get_current(self): return self._current def __get_artist(self): return self._artist def __get_album(self): return self._album def __get_title(self): return self._title def __get_tracknr(self): return self._tracknr def __get_duration(self): return self._duration def __get_date(self): return self._date def __get_genre(self): return self._genre def __get_albumart(self): return self._albumart def __get_playtime(self): return self._playtime def __get_start(self): return self._start def __set_start(self, value): if value: self._start or self.__start() else: self._start and self.__stop() def __start(self): print "__start()" try: os.makedirs(self._confdir) os.makedirs(os.path.join(self._confdir, 'albumart')) except OSError, inst: print inst def _medialib_get_info_cb(result): # if it's not the result of the current song, discard it if result != self._media_info_res: return prop = result.get_propdict() self._artist = prop.get('artist') self._title = prop.get('title') self._album = prop.get('album') self._tracknr = prop.get('tracknr') self._duration = prop.get('duration') self._date = prop.get('date') self._genre = prop.get('genre') self._update("get_current") pic_hash = prop.get('picture_front') if pic_hash: pic = os.path.join(self._confdir, 'albumart', pic_hash) print pic if os.path.isfile(pic): self._albumart = urllib.pathname2url(pic) self._update("get_albumart") else: def _pic_bindata_cb(result): open(pic, 'w').write(result.get_bin()) self._albumart = urllib.pathname2url(pic) self._update("get_albumart") self._xc.bindata_retrieve(pic_hash, _pic_bindata_cb) else: self._albumart = None self._update("get_albumart") return def _playback_playtime_cb(result): self._playtime = result.get_uint() self._update("get_playtime") result.restart() return def _playback_current_id_cb(result): self._current = result.get_uint() self._media_info_res = self._xc.medialib_get_info( self._current, _medialib_get_info_cb) return self._xc = xmmsclient.XMMS(XMMS2.CLIENT_NAME) try: self._xc.connect(self._server, self.__stop) except IOError: self._start = False return self._xc.playback_current_id(_playback_current_id_cb) self._xc.broadcast_playback_current_id(_playback_current_id_cb) self._xc.signal_playback_playtime(_playback_playtime_cb) # self._updated = 0 # self._refresh = 0 # self._status = 1 # self._update("status") # gtk.gdk.threads_enter(self._loop, ()) thread.start_new_thread(self._loop, ()) self._start = True self._update("start")
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # This file is a part of the XMMS2 client tutorial #2 # Here we will learn to retrieve results from a command import xmmsclient import os import sys """ The first part of this program is commented in tut1.py See that one for instructions """ xmms = xmmsclient.XMMS("tutorial2") try: xmms.connect(os.getenv("XMMS_PATH")) except IOError, detail: print "Connection failed:", detail sys.exit(1) """ Now we send a command that will return a result. Let's find out which entry is currently playing. Note that this program has be run while xmms2 is playing something, otherwise XMMS.playback_current_id will return 0. """ result = xmms.playback_current_id()
def __init__(self, name): self.client = xmmsclient.XMMS(name) self.client.connect(os.getenv("XMMS_PATH"))
return self def __exit__(self, type, value, traceback): self.tk.deletefilehandler(self.fd) if __name__ == "__main__": import os import sys import xmmsclient try: import tkinter except ImportError: import Tkinter as tkinter xmms = xmmsclient.XMMS("TkConnector") try: xmms.connect(os.getenv("XMMS_PATH")) except IOerror as err: print("Connection failed:", err) sys.exit(1) root = tkinter.Tk() def print_mid(res): print("mid =", res.value()) root.quit() TkConnector(root, xmms) xmms.playback_current_id(print_mid) root.mainloop()
def __init__( self ): CurrentSong.CurrentSong.__init__( self ) self.connected = False self.status = 'not connected' self.xmms = xmmsclient.XMMS("emesene") self.id_song = 0
print i.get('shortname'), i.get('description') def xform_media_browse_cb(result): print result.get_type() print result.get_dict() def sigint_callback(signal, frame): xc.exit_loop() print xmmsclient.userconfdir_get() signal.signal(signal.SIGINT, sigint_callback) xc = xmmsclient.XMMS() while True: try: print 'trying to connect..' xc.connect() break except IOError: pass #res = xc.signal_playback_playtime(pt_callback) res = xc.broadcast_playback_current_id(playback_current_id_cb) xc.playback_current_id(playback_current_id_cb) xc.plugin_list(xmmsclient.PLUGIN_TYPE_ALL, plugin_list_cb) xc.xform_media_browse("file:///fat16kb/music/", xform_media_browse_cb)
def xmms2(self): """ Function to get xmms2 currently playing song """ # To communicate with xmms2d, you need an instance of the xmmsclient.XMMS object, which abstracts the connection try: import xmmsclient except ImportError as error: log.addwarning( _("ERROR: xmms2: failed to load xmmsclient module: %(error)s") % {"error": error}) return None xmms = xmmsclient.XMMS("NPP") # Now we need to connect to xmms2d try: xmms.connect(os.getenv("XMMS_PATH")) except IOError as error: log.addwarning( _("ERROR: xmms2: connecting failed: %(error)s") % {"error": error}) return None # Retrieve the current playing entry result = xmms.playback_current_id() result.wait() if result.iserror(): log.addwarning( _("ERROR: xmms2: playback current id error: %(error)s") % {"error": result.get_error()}) return None id = result.value() # Entry 0 is non valid if id == 0: log.addwarning(_("ERROR: xmms2: nothing is playing")) return None result = xmms.medialib_get_info(id) result.wait() # This can return error if the id is not in the medialib if result.iserror(): log.addwarning( _("ERROR: xmms2: medialib get info error: %(error)s") % {"error": result.get_error()}) return None # Extract entries from the dict minfo = result.value() try: self.title["artist"] = str(minfo["artist"]) self.title["nowplaying"] = str(minfo["artist"]) except KeyError: pass try: self.title["title"] = str(minfo["title"]) self.title["nowplaying"] += " - " + str(minfo["title"]) except KeyError: pass try: self.title["album"] = str(minfo["album"]) except KeyError: pass try: self.title["bitrate"] = str(minfo["bitrate"]) except KeyError: pass try: self.title["filename"] = str(minfo["url"]) except KeyError: pass try: self.title["length"] = self.get_length_time(minfo["duration"] / 1000) except KeyError: pass try: self.title["track"] = str(minfo["tracknr"]) except KeyError: pass try: self.title["year"] = str(minfo["date"]) except KeyError: pass return True
def __init__(self, *args, **kwargs): super(Xmms2, self).__init__(*args, **kwargs) self.client = xmmsclient.XMMS('crowdmixer') self.client.connect(os.getenv('XMMS_PATH'))