當前位置: 首頁>>代碼示例>>Python>>正文


Python nullbe.NullPlayer類代碼示例

本文整理匯總了Python中quodlibet.player.nullbe.NullPlayer的典型用法代碼示例。如果您正苦於以下問題:Python NullPlayer類的具體用法?Python NullPlayer怎麽用?Python NullPlayer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了NullPlayer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: TVolume

class TVolume(TestCase):
    def setUp(self):
        self.p = NullPlayer()
        self.v = Volume(self.p)

    def test_setget(self):
        for i in [0.0, 1.2, 0.24, 1.0, 0.9]:
            self.v.set_value(i)
            self.failUnlessAlmostEqual(self.p.volume, self.v.get_value() ** 3)

    def test_add(self):
        self.v.set_value(0.5)
        self.v += 0.1
        self.failUnlessAlmostEqual(self.p.volume, 0.6 ** 3)

    def test_sub(self):
        self.v.set_value(0.5)
        self.v -= 0.1
        self.failUnlessAlmostEqual(self.p.volume, 0.4 ** 3)

    def test_add_boundry(self):
        self.v.set_value(0.95)
        self.v += 0.1
        self.failUnlessAlmostEqual(self.p.volume, 1.0)

    def test_sub_boundry(self):
        self.v.set_value(0.05)
        self.v -= 0.1
        self.failUnlessAlmostEqual(self.p.volume, 0.0)

    def tearDown(self):
        self.p.destroy()
        self.v.destroy()
開發者ID:LudoBike,項目名稱:quodlibet,代碼行數:33,代碼來源:test_player.py

示例2: setUp

 def setUp(self):
     config.init()
     player = NullPlayer()
     song = AudioFile()
     song.bookmarks = [(10, "bla")]
     song.sanitize("/")
     player.song = song
     self.player = player
開發者ID:silkecho,項目名稱:glowing-silk,代碼行數:8,代碼來源:test_qltk_bookmarks.py

示例3: setUp

 def setUp(self):
     config.init()
     player = NullPlayer()
     song = AudioFile()
     song.bookmarks = [(10, "bla")]
     song.sanitize(fsnative(u"/"))
     player.song = song
     self.player = player
     self.library = SongLibrary()
開發者ID:LudoBike,項目名稱:quodlibet,代碼行數:9,代碼來源:test_qltk_bookmarks.py

示例4: TFIFOControl

class TFIFOControl(TestCase):
    def setUp(self):
        config.init()
        self.p = NullPlayer()
        self.l = SongFileLibrary()
        self.w = gtk.Window()
        self.fifo = FIFOControl(self.l, self.w, self.p)

    def tearDown(self):
        self.p.destroy()
        self.l.destroy()
        self.w.destroy()
        config.quit()

    def __send(self, command):
        f = open(const.CONTROL, "wb")
        f.write(command)
        f.close()
        while gtk.events_pending():
            gtk.main_iteration()

    def test_player(self):
        self.__send("previous")
        self.__send("force_previous")
        self.__send("next")
        self.__send("pause")
        self.__send("play-pause")
        self.__send("stop")
        self.__send("volume +1000")
        self.__send("volume 40")
        self.__send("volume -10")

        #self.__send("seek -10")
        #self.__send("seek +10")
        #self.__send("seek 0")

    def test_misc(self):
        #self.__send("add-directory /dev/null")
        self.__send("add-file /dev/null")
        #self.__send("dump-playlist /dev/null")
        #self.__send("dump_queue /dev/null")
        #self.__send("enqueue /dev/null")
        self.__send("enqueue-files /dev/null")
        #self.__send("filter album=test")
        #self.__send("focus")
        #self.__send("hide-window")
        #self.__send("open-browser 1")
        #self.__send("order shuffle")
        self.__send("properties")
        #self.__send("queue 1")
        self.__send("quit")
        #self.__send("random album")
        #self.__send("refresh")
        #self.__send("repeat 0")
        #self.__send("set-browser 1")
        self.__send("set-rating 0.5")
開發者ID:silkecho,項目名稱:glowing-silk,代碼行數:56,代碼來源:test_qltk_remote.py

示例5: test_main

    def test_main(self):
        WaveformScale = self.mod.WaveformScale

        player = NullPlayer()
        player.info = AudioFile({"~#length": 10})
        scale = WaveformScale(player)
        scale.compute_redraw_interval()
        scale.compute_redraw_area()

        with visible(scale):
            scale.compute_redraw_interval()
            scale.compute_redraw_area()
開發者ID:LudoBike,項目名稱:quodlibet,代碼行數:12,代碼來源:test_waveformseekbar.py

示例6: TFSInterface

class TFSInterface(TestCase):
    def setUp(self):
        self.p = NullPlayer()
        self.dir = mkdtemp()
        self.filename = os.path.join(self.dir, "foo")
        self.fs = FSInterface(self.filename, self.p)

    def tearDown(self):
        self.p.destroy()
        shutil.rmtree(self.dir)

    def do(self):
        while Gtk.events_pending():
            Gtk.main_iteration()

    def test_init(self):
        self.do()
        self.failIf(os.path.exists(self.filename))

    def test_start(self):
        self.p.emit('song_started', AudioFile({"woo": "bar", "~#length": 10}))
        self.do()
        self.failUnless("woo=bar\n" in file(self.filename).read())

    def test_song_ended(self):
        self.p.emit('song-started', AudioFile({"woo": "bar", "~#length": 10}))
        self.do()
        self.p.emit('song-ended', {}, False)
        self.do()
        self.failIf(os.path.exists(self.filename))
開發者ID:vrasidas,項目名稱:quodlibet,代碼行數:30,代碼來源:test_qltk_tracker.py

示例7: TFSInterface

class TFSInterface(TestCase):
    def setUp(self):
        self.p = NullPlayer()
        self.fs = FSInterface(self.p)

    def do(self):
        while gtk.events_pending(): gtk.main_iteration()

    def test_init(self):
        self.do()
        self.failIf(os.path.exists(const.CURRENT))

    def test_start(self):
        self.p.emit('song_started', AudioFile({"woo": "bar", "~#length": 10}))
        self.do()
        self.failUnless("woo=bar\n" in file(const.CURRENT).read())

    def test_song_ended(self):
        self.p.emit('song-started', AudioFile({"woo": "bar", "~#length": 10}))
        self.do()
        self.p.emit('song-ended', {}, False)
        self.do()
        self.failIf(os.path.exists(const.CURRENT))

    def tearDown(self):
        self.p.destroy()
        try: os.unlink(const.CURRENT)
        except EnvironmentError: pass
開發者ID:silkecho,項目名稱:glowing-silk,代碼行數:28,代碼來源:test_qltk_remote.py

示例8: TSongTracker

class TSongTracker(TestCase):
    def setUp(self):
        config.init()
        self.p = NullPlayer()
        self.w = SongLibrary()
        self.s1 = AudioFile(
            {"~#playcount": 0, "~#skipcount": 0, "~#lastplayed": 10,
             "~filename": "foo", "~#length": 1.5})
        self.s2 = AudioFile(
            {"~#playcount": 0, "~#skipcount": 0, "~#lastplayed": 10,
             "~filename": "foo", "~#length": 1.5})
        self.cm = SongTracker(self.w, self.p, self)
        self.current = None

    def do(self):
        while Gtk.events_pending():
            Gtk.main_iteration()

    def test_destroy(self):
        self.cm.destroy()

    def test_play(self):
        import time
        # Allow at least 2 second to elapse to simulate playing
        self.p.song = self.s1
        self.p.paused = False
        time.sleep(2)
        self.do()
        self.p.emit('song-ended', self.s1, False)
        self.do()
        t = time.time()
        self.assertEquals(self.s1["~#playcount"], 1)
        self.assertEquals(self.s1["~#skipcount"], 0)
        self.failUnless(t - self.s1["~#lastplayed"] <= 1)

    def test_skip(self):
        self.p.emit('song-ended', self.s1, True)
        self.do()
        self.assertEquals(self.s1["~#playcount"], 0)
        self.assertEquals(self.s1["~#skipcount"], 1)
        self.failUnless(self.s1["~#lastplayed"], 10)

    def test_error(self):
        self.current = self.p.song = self.s1
        self.p._error('Test error')
        self.do()
        self.assertEquals(self.s1["~#playcount"], 0)
        self.assertEquals(self.s1["~#skipcount"], 0)
        self.failUnless(self.s1["~#lastplayed"], 10)

    def test_restart(self):
        self.current = self.s1
        self.p.emit('song-ended', self.s1, True)
        self.do()
        self.assertEquals(self.s1["~#playcount"], 0)
        self.assertEquals(self.s1["~#skipcount"], 0)

    def tearDown(self):
        self.w.destroy()
        config.quit()
開發者ID:vrasidas,項目名稱:quodlibet,代碼行數:60,代碼來源:test_qltk_tracker.py

示例9: setUp

 def setUp(self):
     self.q = PlaylistModel()
     self.pl = PlaylistModel()
     self.p = NullPlayer()
     self.mux = PlaylistMux(self.p, self.q, self.pl)
     self.p.setup(self.mux, None, 0)
     self.failUnless(self.pl.current is None)
開發者ID:faubiguy,項目名稱:quodlibet,代碼行數:7,代碼來源:test_qltk_songmodel.py

示例10: setUp

 def setUp(self):
     self.p = NullPlayer()
     self.w = SongLibrary()
     self.s1 = AudioFile(
         {"~#playcount": 0, "~#skipcount": 0, "~#lastplayed": 10,
          "~filename": "foo", "~#length": 1.5})
     self.s2 = AudioFile(
         {"~#playcount": 0, "~#skipcount": 0, "~#lastplayed": 10,
          "~filename": "foo", "~#length": 1.5})
     self.cm = SongTracker(self.w, self.p, self)
     self.current = None
開發者ID:silkecho,項目名稱:glowing-silk,代碼行數:11,代碼來源:test_qltk_tracker.py

示例11: setUp

 def setUp(self):
     config.init()
     self.p = NullPlayer()
     self.v = Volume(self.p)
開發者ID:kriskielce88,項目名稱:xn--ls8h,代碼行數:4,代碼來源:test_player.py

示例12: TPlaylistMux

class TPlaylistMux(TestCase):
    def setUp(self):
        self.q = PlaylistModel()
        self.pl = PlaylistModel()
        self.p = NullPlayer()
        self.mux = PlaylistMux(self.p, self.q, self.pl)
        self.p.setup(self.mux, None, 0)
        self.failUnless(self.pl.current is None)

    def test_destroy(self):
        self.mux.destroy()

    def test_only_pl(self):
        self.pl.set(range(10))
        do_events()
        self.failUnless(self.mux.current is None)
        songs = [self.next() for i in range(10)]
        self.failUnlessEqual(songs, list(range(10)))
        self.next()
        self.failUnless(self.mux.current is None)

    def test_only_q(self):
        self.q.set(range(10))
        do_events()
        self.failUnless(self.mux.current is None)
        songs = [self.next() for i in range(10)]
        self.failUnlessEqual(songs, list(range(10)))
        self.next()
        self.failUnless(self.mux.current is None)

    def test_mixed(self):
        self.q.set(range(5))
        self.pl.set(range(5, 10))
        do_events()
        self.failUnless(self.mux.current is None)
        songs = [self.next() for i in range(10)]
        self.failUnlessEqual(songs, list(range(10)))
        self.next()
        self.failUnless(self.mux.current is None)

    def test_newplaylist(self):
        self.pl.set(range(5, 10))
        do_events()
        self.failUnless(self.mux.current is None)
        self.mux.go_to(7)
        self.failUnlessEqual(self.mux.current, 7)
        self.pl.set([3, 5, 12, 11])
        do_events()
        self.failUnlessEqual(self.mux.current, None)
        self.pl.set([19, 8, 12, 3])
        do_events()
        self.failUnlessEqual(self.mux.current, None)
        self.pl.set([3, 7, 9, 11])
        do_events()
        self.mux.next()
        self.failUnlessEqual(self.mux.current, 9)

    def test_halfway(self):
        self.pl.set(range(10))
        do_events()
        self.failUnless(self.mux.current is None)
        songs = [self.next() for i in range(5)]
        self.q.set(range(100, 105))
        do_events()
        songs.extend([self.next() for i in range(10)])
        self.failUnlessEqual(
            songs, [0, 1, 2, 3, 4, 100, 101, 102, 103, 104, 5, 6, 7, 8, 9])
        self.next()
        self.failUnless(self.mux.current is None)

    def test_removal(self):
        self.pl.set(range(0, 5))
        self.q.set(range(10, 15))
        do_events()
        songs = [self.next() for i in range(3)]
        self.q.remove(self.q.find(14))
        self.q.remove(self.q.find(13))
        songs.extend([self.next() for i in range(5)])
        self.failUnlessEqual(songs, [10, 11, 12, 0, 1, 2, 3, 4])

    def next(self):
        self.mux.next()
        song = self.mux.current
        self.p.emit('song-started', self.mux.current)
        do_events()
        return song

    def test_goto(self):
        self.pl.set(range(10))
        self.q.set(range(10, 20))
        do_events()
        self.failUnless(self.mux.current is None)
        self.mux.go_to(5)
        self.failUnlessEqual(self.mux.current, 5)
        self.mux.go_to(2)
        self.failUnlessEqual(self.mux.current, 2)
        self.failUnlessEqual(self.next(), 10)
        self.mux.go_to(7)
        self.failUnlessEqual(self.mux.current, 7)
        self.failUnlessEqual(self.next(), 11)
#.........這裏部分代碼省略.........
開發者ID:faubiguy,項目名稱:quodlibet,代碼行數:101,代碼來源:test_qltk_songmodel.py

示例13: setUp

 def setUp(self):
     self.p = NullPlayer()
     self.fs = FSInterface(self.p)
開發者ID:silkecho,項目名稱:glowing-silk,代碼行數:3,代碼來源:test_qltk_remote.py

示例14: setUp

 def setUp(self):
     self.p = NullPlayer()
     self.v = Volume(self.p)
開發者ID:LudoBike,項目名稱:quodlibet,代碼行數:3,代碼來源:test_player.py

示例15: setUp

 def setUp(self):
     self.p = NullPlayer()
     self.dir = mkdtemp()
     self.filename = os.path.join(self.dir, "foo")
     self.fs = FSInterface(self.filename, self.p)
開發者ID:vrasidas,項目名稱:quodlibet,代碼行數:5,代碼來源:test_qltk_tracker.py


注:本文中的quodlibet.player.nullbe.NullPlayer類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。