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


Python ShufflePlayer.reset_history方法代码示例

本文整理汇总了Python中lollypop.player_shuffle.ShufflePlayer.reset_history方法的典型用法代码示例。如果您正苦于以下问题:Python ShufflePlayer.reset_history方法的具体用法?Python ShufflePlayer.reset_history怎么用?Python ShufflePlayer.reset_history使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lollypop.player_shuffle.ShufflePlayer的用法示例。


在下文中一共展示了ShufflePlayer.reset_history方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: set_albums

# 需要导入模块: from lollypop.player_shuffle import ShufflePlayer [as 别名]
# 或者: from lollypop.player_shuffle.ShufflePlayer import reset_history [as 别名]
    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()
开发者ID:kmf,项目名称:lollypop,代码行数:61,代码来源:player.py

示例2: set_albums

# 需要导入模块: from lollypop.player_shuffle import ShufflePlayer [as 别名]
# 或者: from lollypop.player_shuffle.ShufflePlayer import reset_history [as 别名]
    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()
开发者ID:yoseforb,项目名称:lollypop,代码行数:53,代码来源:player.py

示例3: set_albums

# 需要导入模块: from lollypop.player_shuffle import ShufflePlayer [as 别名]
# 或者: from lollypop.player_shuffle.ShufflePlayer import reset_history [as 别名]
    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()
开发者ID:sebfag,项目名称:lollypop,代码行数:51,代码来源:player.py

示例4: set_albums

# 需要导入模块: from lollypop.player_shuffle import ShufflePlayer [as 别名]
# 或者: from lollypop.player_shuffle.ShufflePlayer import reset_history [as 别名]
    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
        self._albums = []
        self._context.genre_ids = {}
        self._context.aritst_ids = {}
        self._context.prev_track = Track()
        self._context.next_track = Track()
        ShufflePlayer.reset_history(self)

        # We are not playing a user playlist anymore
        self._user_playlist = []
        self._user_playlist_ids = []
        # We are in all artists
        if (genre_ids and genre_ids[0] == Type.ALL) or\
           (artist_ids and artist_ids[0] == Type.ALL):
            # Genres: all, Artists: compilations
            if artist_ids and artist_ids[0] == Type.COMPILATIONS:
                self._albums += Lp().albums.get_compilations()
            # Genres: all, Artists: ids
            elif artist_ids and artist_ids[0] != Type.ALL:
                self._albums += Lp().albums.get_ids(artist_ids)
            # Genres: all, Artists: all
            else:
                if Lp().settings.get_value('show-compilations'):
                    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:
            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()
        # Add albums for artists/genres
        else:
            # If we are not in compilation view and show compilation is on,
            # add compilations
            if artist_ids and artist_ids[0] == Type.COMPILATIONS:
                self._albums += Lp().albums.get_compilations(genre_ids)
            else:
                if not artist_ids and\
                        Lp().settings.get_value('show-compilations'):
                    self._albums += Lp().albums.get_compilations(genre_ids)
                self._albums += Lp().albums.get_ids(artist_ids, genre_ids)

        if Lp().settings.get_value('repeat'):
            self._context.next = NextContext.NONE
        else:
            self._context.next = NextContext.STOP_ALL
        # We do not store genre_ids for ALL/POPULARS/...
        if genre_ids and genre_ids[0] < 0:
            genre_ids = []
        # Set context for each album
        for album_id in self._albums:
            self._context.genre_ids[album_id] = []
            self._context.artist_ids[album_id] = []
            for genre_id in genre_ids:
                if genre_id >= 0:
                    self._context.genre_ids[album_id].append(genre_id)
            for artist_id in artist_ids:
                if artist_id >= 0:
                    self._context.artist_ids[album_id].append(artist_id)
        # Shuffle album list if needed
        self.shuffle_albums(True)
开发者ID:ferranroig,项目名称:lollypop,代码行数:79,代码来源:player.py


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