コード例 #1
0
ファイル: mpdclient.py プロジェクト: alip/boogie
    def seek(self, timespec, position=None):
        status = self.mpc.status()

        if position is None:
            # Default is current song
            position = int(status["song"])
            elapsedtime, totaltime = parseTimeStatus(status["time"])
        else:
            stats = self.mpc.playlistinfo(position)
            # Check if the position refers to the current song.
            if status["songid"] == stats[0]["id"]:
                elapsedtime, totaltime = parseTimeStatus(status["time"])
            else:
                elapsedtime = 0
                totaltime = int(stats[0]["time"])

        seekto = parseTimeSpec(timespec, elapsedtime, totaltime)

        if self.output:
            printByName("seek", position=position, seekto=seekto)
        ret = self.mpc.seek(position, seekto)
        if self.after_status:
            self.status(after_command=True)

        return ret
コード例 #2
0
ファイル: mpdclient.py プロジェクト: alip/boogie
    def seekid(self, timespec, songid=None):
        status = self.mpc.status()

        if songid is None:
            # Default is current song
            songid = int(status["songid"])
            elapsedtime, totaltime = parseTimeStatus(status["time"])
        else:
            # Check if the position refers to the current song.
            if songid == int(status["songid"]):
                elapsedtime, totaltime = parseTimeStatus(status["time"])
            else:
                stats = self.mpc.playlistid(songid)
                elapsedtime = 0
                totaltime = int(stats[0]["time"])

        seekto = parseTimeSpec(timespec, elapsedtime, totaltime)

        if self.output: printByName("seekid", songid=songid, seekto=seekto)
        ret = self.mpc.seekid(songid, seekto)
        if self.after_status:
            self.status(after_command=True)

        return ret