当前位置: 首页>>代码示例>>Python>>正文


Python Playlist.next_song方法代码示例

本文整理汇总了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)
开发者ID:pgenev,项目名称:HackBG-Programing-101-v3,代码行数:21,代码来源:test_Songs_and_playlist.py

示例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())
开发者ID:nkolchakov,项目名称:Programming101-Python,代码行数:12,代码来源:mp3.py

示例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)
开发者ID:pgenev,项目名称:HackBG-Programing-101-v3,代码行数:28,代码来源:test_Songs_and_playlist.py

示例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))
开发者ID:kristjanjonsson,项目名称:elevator-music,代码行数:41,代码来源:player.py


注:本文中的playlist.Playlist.next_song方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。