(self, data:dict, index=0)
方便外部调用。一键添加歌曲。
方便外部调用。一键添加歌曲。
方便外部调用。一键添加歌曲。
def setPlayerAndPlayList(self, data:dict, index=0):
        """方便外部调用。一键添加歌曲。"""
        """防止重复。"""
        logger.info("尝试添加歌曲到播放列表，歌曲信息: {0} \n".format(data))
        authorAndName = data['author'] + data['name']
        for i, mediaInfo in enumerate(self.playList.musicList):
            checkAuthorAndName = mediaInfo['author'] + mediaInfo['name']
            # if data in self.playList.musicList:
            if authorAndName == checkAuthorAndName:
                # index = self.playList.musicList.index(data)
                if self.player.playList.currentIndex == i and i != 0:
                    return

                self.player.setIndex(i)

                return

        # 添加资源当前项到播放列表。
        # if 'qq.com' in data['url']:
            # print(data['url'])
            # return
            
        sureSetUp = self.player.setMusic(data['url'], data)
        if not sureSetUp:
            self.currentMusic.setShortInfo('音乐不可播放', data['author'], data['music_img'])
            return 
            
        self.playList.addMusic(data)

        self.player.playList.tabMusicEvent()
        # 添加显示播放列表的显示项。
        self.playList.addPlayList(data['name'], data['author'], data['time'])
def setPlayerAndPlayList ( self , data : dict , index = 0 ) : """防止重复。""" logger . info ( "尝试添加歌曲到播放列表，歌曲信息: {0} \n".format(data)) authorAndName = data [ 'author' ] + data [ 'name' ] for i , mediaInfo in enumerate ( self . playList . musicList ) : checkAuthorAndName = mediaInfo [ 'author' ] + mediaInfo [ 'name' ] # if data in self.playList.musicList: if authorAndName == checkAuthorAndName : # index = self.playList.musicList.index(data) if self . player . playList . currentIndex == i and i != 0 : return self . player . setIndex ( i ) return # 添加资源当前项到播放列表。 # if 'qq.com' in data['url']: # print(data['url']) # return sureSetUp = self . player . setMusic ( data [ 'url' ] , data ) if not sureSetUp : self . currentMusic . setShortInfo ( '音乐不可播放', data['auth o '],  d ata['mus i c img' ] ) return self . playList . addMusic ( data ) self . player . playList . tabMusicEvent ( ) # 添加显示播放列表的显示项。 self . playList . addPlayList ( data [ 'name' ] , data [ 'author' ] , data [ 'time' ] )