本文整理汇总了Python中lollypop.player_shuffle.ShufflePlayer类的典型用法代码示例。如果您正苦于以下问题:Python ShufflePlayer类的具体用法?Python ShufflePlayer怎么用?Python ShufflePlayer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ShufflePlayer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self):
BinPlayer.__init__(self)
QueuePlayer.__init__(self)
LinearPlayer.__init__(self)
ShufflePlayer.__init__(self)
UserPlaylistPlayer.__init__(self)
TagReader.__init__(self)
示例2: set_albums
def set_albums(self, track_id, artist_ids, genre_ids):
"""
Set album list (for next/prev)
@param track id as int
@param artist id as int
@param genre id as int
"""
# Invalid track
if track_id is None:
return
album = Track(track_id).album
self._albums = []
ShufflePlayer.reset_history(self)
# We are not playing a user playlist anymore
self._user_playlist = []
self._user_playlist_id = None
# We are in all artists
if (genre_ids and genre_ids[0] == Type.ALL) or\
(artist_ids and artist_ids[0] == Type.ALL):
self._albums = Lp().albums.get_compilations()
self._albums += Lp().albums.get_ids()
# We are in populars view, add popular albums
elif genre_ids and genre_ids[0] == Type.POPULARS:
if self._shuffle in [Shuffle.TRACKS_ARTIST, Shuffle.ALBUMS_ARTIST]:
self._albums = []
self.next_track = Track()
for album_id in Lp().albums.get_populars():
if Lp().albums.get_artist_id(album_id) == \
album.artist_id:
self._albums.append(album_id)
else:
self._albums = Lp().albums.get_populars()
# We are in recents view, add recent albums
elif genre_ids and genre_ids[0] == Type.RECENTS:
self._albums = Lp().albums.get_recents()
# We are in randoms view, add random albums
elif genre_ids and genre_ids[0] == Type.RANDOMS:
self._albums = Lp().albums.get_cached_randoms()
# We are in compilation view without genre
elif genre_ids and genre_ids[0] == Type.COMPILATIONS:
self._albums = Lp().albums.get_compilations()
# Random tracks/albums for artist
elif self._shuffle in [Shuffle.TRACKS_ARTIST, Shuffle.ALBUMS_ARTIST]:
self._albums = Lp().albums.get_ids([album.artist_id], genre_ids)
# Add all albums for genre
else:
if not artist_ids:
self._albums = Lp().albums.get_compilations(genre_ids)
self._albums += Lp().albums.get_ids(artist_ids, genre_ids)
album.set_genre(genre_ids)
if track_id in album.tracks_ids:
self.context.artist_ids = artist_ids
self.context.genre_ids = genre_ids
# Shuffle album list if needed
self._shuffle_albums()
else: # Error
self.stop()
示例3: __init__
def __init__(self):
BinPlayer.__init__(self)
QueuePlayer.__init__(self)
LinearPlayer.__init__(self)
ShufflePlayer.__init__(self)
UserPlaylistPlayer.__init__(self)
RadioPlayer.__init__(self)
ExternalsPlayer.__init__(self)
示例4: set_party
def set_party(self, party):
"""
Set party mode on if party is True
Play a new random track if not already playing
@param party as bool
"""
ShufflePlayer.set_party(self, party)
self.set_next()
self.set_prev()
self.update_crossfading()
示例5: set_party
def set_party(self, party):
"""
Set party mode on if party is True
Play a new random track if not already playing
@param party as bool
"""
ShufflePlayer.set_party(self, party)
self.set_next()
self.set_prev()
if self.is_playing():
self.emit('next-changed')
示例6: __init__
def __init__(self):
"""
Create all objects
"""
BinPlayer.__init__(self)
QueuePlayer.__init__(self)
LinearPlayer.__init__(self)
ShufflePlayer.__init__(self)
UserPlaylistPlayer.__init__(self)
RadioPlayer.__init__(self)
ExternalsPlayer.__init__(self)
示例7: _on_stream_start
def _on_stream_start(self, bus, message):
"""
On stream start, set next and previous track
"""
if not Lp().scanner.is_locked():
Lp().window.pulse(False)
if self._current_track.id >= 0:
ShufflePlayer._on_stream_start(self, bus, message)
self.set_next()
self.set_prev()
BinPlayer._on_stream_start(self, bus, message)
示例8: __init__
def __init__(self):
"""
Init player
"""
BinPlayer.__init__(self)
QueuePlayer.__init__(self)
LinearPlayer.__init__(self)
ShufflePlayer.__init__(self)
UserPlaylistPlayer.__init__(self)
RadioPlayer.__init__(self)
ExternalsPlayer.__init__(self)
self.update_crossfading()
示例9: _on_stream_start
def _on_stream_start(self, bus, message):
"""
On stream start, set next and previous track
"""
if self.current_track.id >= 0:
ShufflePlayer._on_stream_start(self, bus, message)
if self._queue and self.current_track.id == self._queue[0]:
self._queue.pop(0)
self.emit("queue-changed")
self.set_next()
self.set_prev()
BinPlayer._on_stream_start(self, bus, message)
示例10: set_albums
def set_albums(self, track_id, artist_id, genre_id):
# Invalid track
if track_id is None:
return
album_id = Lp.tracks.get_album_id(track_id)
self._albums = None
ShufflePlayer.reset_history(self)
self.context.genre_id = genre_id
# When shuffle from artist is active, we want only artist's albums,
# we need to ignore genre
# Do not set genre_id directly as it will changes current context
if self._shuffle in [Shuffle.TRACKS_ARTIST, Shuffle.ALBUMS_ARTIST]:
genre_id_lookup = None
else:
genre_id_lookup = genre_id
# We are not playing a user playlist anymore
self._user_playlist = None
# We are in all artists
if genre_id_lookup == Type.ALL or artist_id == Type.ALL:
self._albums = Lp.albums.get_compilations(Type.ALL)
self._albums += Lp.albums.get_ids()
# We are in populars view, add popular albums
elif genre_id_lookup == Type.POPULARS:
self._albums = Lp.albums.get_populars()
# We are in recents view, add recent albums
elif genre_id_lookup == Type.RECENTS:
self._albums = Lp.albums.get_recents()
# We are in randoms view, add random albums
elif genre_id_lookup == Type.RANDOMS:
self._albums = Lp.albums.get_cached_randoms()
# We are in compilation view without genre
elif genre_id_lookup == Type.COMPILATIONS:
self._albums = Lp.albums.get_compilations(None)
# Random tracks/albums for artist
elif self._shuffle in [Shuffle.TRACKS_ARTIST, Shuffle.ALBUMS_ARTIST]:
self._albums = Lp.albums.get_ids(artist_id, genre_id_lookup)
# Add all albums for genre
else:
self._albums = Lp.albums.get_compilations(genre_id_lookup)
self._albums += Lp.albums.get_ids(None, genre_id_lookup)
tracks = Lp.albums.get_tracks(album_id, genre_id_lookup)
if track_id in tracks:
self.context.position = tracks.index(track_id)
self.context.genre_id = genre_id
# Shuffle album list if needed
self._shuffle_albums()
elif self.current_track.id != Type.RADIOS:
self.stop()
示例11: _on_stream_start
def _on_stream_start(self, bus, message):
"""
On stream start, set next and previous track
"""
if not Lp().scanner.is_locked():
Lp().window.pulse(False)
if self.current_track.id >= 0:
ShufflePlayer._on_stream_start(self, bus, message)
if self._queue and self.current_track.id == self._queue[0]:
self._queue.pop(0)
self.emit("queue-changed")
self.set_next()
self.set_prev()
BinPlayer._on_stream_start(self, bus, message)
示例12: __init__
def __init__(self):
"""
Init player
"""
BinPlayer.__init__(self)
QueuePlayer.__init__(self)
LinearPlayer.__init__(self)
ShufflePlayer.__init__(self)
UserPlaylistPlayer.__init__(self)
RadioPlayer.__init__(self)
ExternalsPlayer.__init__(self)
self.update_crossfading()
self.__do_not_update_next = False
Lp().settings.connect('changed::playback', self.__on_playback_changed)
示例13: set_albums
def set_albums(self, track_id, artist_id, genre_id):
"""
Set album list (for next/prev)
@param track id as int
@param artist id as int
@param genre id as int
"""
# Invalid track
if track_id is None:
return
album = Track(track_id).album
self._albums = None
ShufflePlayer.reset_history(self)
# We are not playing a user playlist anymore
self._user_playlist = None
self._user_playlist_id = None
# We are in all artists
if genre_id == Type.ALL or artist_id == Type.ALL:
self._albums = Lp.albums.get_compilations(Type.ALL)
self._albums += Lp.albums.get_ids()
# We are in populars view, add popular albums
elif genre_id == Type.POPULARS:
self._albums = Lp.albums.get_populars()
# We are in recents view, add recent albums
elif genre_id == Type.RECENTS:
self._albums = Lp.albums.get_recents()
# We are in randoms view, add random albums
elif genre_id == Type.RANDOMS:
self._albums = Lp.albums.get_cached_randoms()
# We are in compilation view without genre
elif genre_id == Type.COMPILATIONS:
self._albums = Lp.albums.get_compilations(None)
# Random tracks/albums for artist
elif self._shuffle in [Shuffle.TRACKS_ARTIST, Shuffle.ALBUMS_ARTIST]:
self._albums = Lp.albums.get_ids(artist_id, genre_id)
# Add all albums for genre
else:
self._albums = Lp.albums.get_compilations(genre_id)
self._albums += Lp.albums.get_ids(None, genre_id)
album.set_genre(genre_id)
if track_id in album.tracks_ids:
self.context.position = album.tracks_ids.index(track_id)
self.context.genre_id = genre_id
# Shuffle album list if needed
self._shuffle_albums()
else: # Error
self.stop()
示例14: set_next
def set_next(self):
"""
Play next track
@param sql as sqlite cursor
"""
# Look at externals
self.next_track = ExternalsPlayer.next(self)
# Look at radio
if self.next_track.id is None:
self.next_track = RadioPlayer.next(self)
# Look first at user queue
if self.next_track.id is None:
self.next_track = QueuePlayer.next(self)
# Look at user playlist then
if self.next_track.id is None:
self.next_track = UserPlaylistPlayer.next(self)
# Get a random album/track then
if self.next_track.id is None:
self.next_track = ShufflePlayer.next(self)
# Get a linear track then
if self.next_track.id is None:
self.next_track = LinearPlayer.next(self)
示例15: set_next
def set_next(self):
"""
Play next track
@param sql as sqlite cursor
"""
# Look at externals
self.next_track = ExternalsPlayer.next(self)
# Look at radio
if self.next_track.id is None:
self.next_track = RadioPlayer.next(self)
# Look first at user queue
if self.next_track.id is None:
self.next_track = QueuePlayer.next(self)
if self.next_track.id is not None:
self.context.next_track = LinearPlayer.next(self)
# Look at user playlist then
if self.next_track.id is None:
self.next_track = UserPlaylistPlayer.next(self)
# Get a random album/track then
if self.next_track.id is None:
self.next_track = ShufflePlayer.next(self)
# Get a linear track then
if self.next_track.id is None:
if self.context.next_track is not None:
self.next_track = self.context.next_track
self.context.next_track = None
else:
self.next_track = LinearPlayer.next(self)
self.emit('next-changed')