本文整理汇总了Python中playlist.Playlist.next_song方法的典型用法代码示例。如果您正苦于以下问题:Python Playlist.next_song方法的具体用法?Python Playlist.next_song怎么用?Python Playlist.next_song使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类playlist.Playlist
的用法示例。
在下文中一共展示了Playlist.next_song方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_next_song_shuffle_is_true
# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import next_song [as 别名]
def test_next_song_shuffle_is_true(self):
song = Song(title="Odin", artist="Manowar", album="The Sons of Odin", length="1:30:44")
song2 = Song(title="Panda", artist="Grizli", album="Panda Dog", length="30:44")
song3 = Song(title="Panda2", artist="Grizli2", album="Panda Dog2", length="44")
song4 = Song(title="Thor", artist="Thor", album="The sons of Odin", length="44")
code_songs = Playlist(name="Code", repeat=False, shuffle=False)
code2_songs = Playlist(name="Code", repeat=False, shuffle=True)
code_songs.add_song(song)
code_songs.add_song(song2)
code_songs.add_song(song3)
code2_songs.add_songs(song4)
code2_songs.add_songs(code_songs.song_list)
code2_songs.next_song()
code2_songs.next_song()
code2_songs.next_song()
code2_songs.next_song()
result = code2_songs.next_song()
self.assertEqual(None, result)
示例2: main
# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import next_song [as 别名]
def main():
path = '/home/kolchakov/Desktop/mp3/CD1/'
crawler = MusicCrawler(path)
songs = crawler.generate_playlist()
my_playlist = Playlist('rock')
my_playlist.add_songs(songs)
while True:
command = input("enter command>>")
if command == "next":
print (my_playlist.next_song())
示例3: test_next_song_repeat_is_true
# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import next_song [as 别名]
def test_next_song_repeat_is_true(self):
song = Song(title="Odin", artist="Manowar", album="The Sons of Odin", length="1:30:44")
song2 = Song(title="Panda", artist="Grizli", album="Panda Dog", length="30:44")
song3 = Song(title="Panda2", artist="Grizli2", album="Panda Dog2", length="44")
song4 = Song(title="Thor", artist="Thor", album="The sons of Odin", length="44")
code_songs = Playlist(name="Code", repeat=False, shuffle=False)
code2_songs = Playlist(name="Code", repeat=True, shuffle=False)
code_songs.add_song(song)
code_songs.add_song(song2)
code_songs.add_song(song3)
code2_songs.add_songs(song4)
code2_songs.add_songs(code_songs.song_list)
result = code2_songs.next_song()
result2 = code2_songs.next_song()
result3 = code2_songs.next_song()
result4 = code2_songs.next_song()
result5 = code2_songs.next_song()
code2_songs.next_song()
result7 = code2_songs.next_song()
self.assertEqual(code2_songs.list_of_songs[0], result)
self.assertEqual(code2_songs.list_of_songs[1], result2)
self.assertEqual(code2_songs.list_of_songs[2], result3)
self.assertEqual(code2_songs.list_of_songs[3], result4)
self.assertEqual(code2_songs.list_of_songs[0], result5)
self.assertEqual(code2_songs.list_of_songs[2], result7)
示例4: __init__
# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import next_song [as 别名]
class Player:
def __init__(self):
self.current_song_proc = None
self.playlist_playing = False
self.playlist = Playlist()
def is_playing(self):
"""True if a song is playing."""
return self.current_song_proc and not self.current_song_proc.returncode
def stop(self):
# We signal the playlist to stop playing
# and press next to stop the current song.
self.playlist_playing = False
self.next()
def next(self):
# Stop the current song but keep the playlist playing.
if self.is_playing():
self.current_song_proc.terminate()
@asyncio.coroutine
def play_song(self, song):
self.current_song_proc = yield From(asyncio.create_subprocess_exec(*['mpg321', song]))
def play(self):
"""Plays the playlist forever!!!"""
self.playlist_playing = True
@asyncio.coroutine
def init(self):
while True:
while self.playlist_playing:
song = self.playlist.next_song()
yield From(self.play_song(song))
yield From(self.current_song_proc.wait())
yield From(asyncio.sleep(0.2))