本文整理匯總了Python中quodlibet.player.nullbe.NullPlayer.emit方法的典型用法代碼示例。如果您正苦於以下問題:Python NullPlayer.emit方法的具體用法?Python NullPlayer.emit怎麽用?Python NullPlayer.emit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類quodlibet.player.nullbe.NullPlayer
的用法示例。
在下文中一共展示了NullPlayer.emit方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: TSongTracker
# 需要導入模塊: from quodlibet.player.nullbe import NullPlayer [as 別名]
# 或者: from quodlibet.player.nullbe.NullPlayer import emit [as 別名]
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()
示例2: TFSInterface
# 需要導入模塊: from quodlibet.player.nullbe import NullPlayer [as 別名]
# 或者: from quodlibet.player.nullbe.NullPlayer import emit [as 別名]
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))
示例3: TFSInterface
# 需要導入模塊: from quodlibet.player.nullbe import NullPlayer [as 別名]
# 或者: from quodlibet.player.nullbe.NullPlayer import emit [as 別名]
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
示例4: TPlaylistMux
# 需要導入模塊: from quodlibet.player.nullbe import NullPlayer [as 別名]
# 或者: from quodlibet.player.nullbe.NullPlayer import emit [as 別名]
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)
#.........這裏部分代碼省略.........