コード例 #1
0
class SongData(object):
    def __init__(self, song, config):
        if song.info["background"]: self.background = song.info["background"]
        else: self.background = os.path.join(image_path, "bg.png")

        for key in [
                "movie", "filename", "title", "artist", "startat", "endat",
                "banner"
        ]:
            self.__dict__[key] = song.info[key]

        self.soffset = song.info["gap"] * 1000

        self.crapout = 0

        self.__dict__.update(config)

        try:
            # if user used some internationalization in the configuration file,
            # so in mainconfig["lyriccolor"], maybe there is invalid colors
            # TODO: not save translated colors in the config file, only English
            clrs = [
                colors.color[_(c)] for c in mainconfig["lyriccolor"].split("/")
            ]
        except:
            clrs = ["cyan", "aqua"]

        clrs.reverse()
        self.lyricdisplay = Lyrics(clrs)

        atsec = 0
        for lyr in song.lyrics:
            self.lyricdisplay.addlyric(*lyr)

    def init(self):
        try:
            music.load(self.filename)
        except:
            print _("Not a supported file type:"), self.filename
            self.crapout = 1

    def play(self):
        music.play(0, self.startat)

    def kill(self):
        music.stop()

    def is_over(self):
        if not music.get_busy(): return True
        elif self.endat and music.get_pos() > self.endat * 1000:
            music.stop()
            return True
        else:
            return False
コード例 #2
0
ファイル: steps.py プロジェクト: EvilDrW/pydance
class SongData(object):
  def __init__(self, song, config):
    if song.info["background"]: self.background = song.info["background"]
    else: self.background = os.path.join(image_path, "bg.png")

    for key in ["movie", "filename", "title", "artist", "startat", "endat",
                "banner"]:
      self.__dict__[key] = song.info[key]

    self.soffset = song.info["gap"] * 1000

    self.crapout = 0

    self.__dict__.update(config)

    try:
        # if user used some internationalization in the configuration file,
	# so in mainconfig["lyriccolor"], maybe there is invalid colors
	# TODO: not save translated colors in the config file, only English
        clrs = [colors.color[_(c)] for c in mainconfig["lyriccolor"].split("/")]
    except:
        clrs = ["cyan","aqua"]

    clrs.reverse()
    self.lyricdisplay = Lyrics(clrs)

    atsec = 0
    for lyr in song.lyrics:
      self.lyricdisplay.addlyric(*lyr)

  def init(self):
    try: music.load(self.filename)
    except:
      print _("Not a supported file type:"), self.filename
      self.crapout = 1

  def play(self):
    music.play(0, self.startat)

  def kill(self):
    music.stop()

  def is_over(self):
    if not music.get_busy(): return True
    elif self.endat and music.get_pos() > self.endat * 1000:
      music.stop()
      return True
    else: return False