def set_dev(dev='/dev/cdrom'): """ Changes the CD device. Makes change. Dances poorly. """ cd.cd_close() cd.cd.path = str(dev) cd.cd_open() updated = False return
def read_disc_info(self): """ emit an event if cd status has changed. """ if self.is_ripping: return elif CDLow.get_drive_status() in [CDROM.CDS_TRAY_OPEN, CDROM.CDS_NO_DISC, -1]: self.disc_id = None return elif CDLow.get_disc_type() != CDROM.CDS_AUDIO: return disc_id = cd_logic.get_disc_id() #if self.disc_id <> disc_id: self.disc_id = disc_id self.cddb_thd = self.runit(self.get_tracks)
def check_dev(): # print cd.get_drive_status() try: return cd.get_drive_status() except IOError, err: print "IOError. Passing 0. Error was " + str(err) return -1
def update(): try: status = cd.get_status() except: status = 0 if status == 0: updated = True
def get_status(): """ Returns CD's playing state. Yes, this is just a wrapper around get_status. DEAL. ;)""" try: status = cd.get_status() except: # print "Error in play_pause" # # TODO: Do something. :P return 0 return status
def sendUpdate(self): """ something happened. """ if self._status in [CDROM.CDS_TRAY_OPEN, CDROM.CDS_NO_DISC]: self.emit(SIGNAL('ejected()')) elif self._status == CDROM.CDS_DISC_OK: disc_type = CDLow.get_disc_type() if disc_type == CDROM.CDS_AUDIO: self.emit(SIGNAL('audioInserted()')) elif disc_type in (CDROM.CDS_DATA_1, CDROM.CDS_DATA_2): self.emit(SIGNAL('dataInserted()')) else: print 'cdnotify: unknown disc type (%i)' % disc_type elif self._status == -1: print 'cdnotify: status -1' else: print 'cdnotify: unknown status (%i)' % self._status
def play(track = 1): cd.play(track, total_tracks())
def current_track(): # try: temp = cd.get_status(1) return int(temp['cur_t']) # except: return -1
def total_tracks(): #try: return cd.get_tracks_id()['end_t']
def eject(): cd.eject() update()
def get_track_time(): min, sec, temp = cd.get_status(1)['rel'] return ((min * 60) + sec)
def get_cddb_id(): temp = cd.get_tracks_id() id = temp['id'] return id
def get_disc_id(): temp = cd.get_tracks_id() id = temp['id'] return int(id[0])
def jump(seconds): cd.skip(0, seconds)
def pause(): cd.pause() update()
def get_track_time_total(track=None): if not track: track = current_track() t1, t2, t3, min, sec, t4, t5, t6 = cd.get_track_length(track) return ((min * 60) + sec)
def stop(): cd.stop() update()