Remove song from playlist. O(n)

        If song is current song, remove the song and play next. Otherwise,
        just remove it.
185418
def remove(self, song):
        
        if song in self._songs:
            if self._current_song is None:
                self._songs.remove(song)
            elif song == self._current_song:
                next_song = self.next_song
                # 随机模式下或者歌单只剩一首歌曲，下一首可能和当前歌曲相同
                if next_song == self.current_song:
                    self.current_song = None
                    self._songs.remove(song)
                    self.current_song = self.next_song
                else:
                    self.current_song = self.next_song
                    self._songs.remove(song)
            else:
                self._songs.remove(song)
            logger.debug('Remove {} from player playlist'.format(song))
        else:
            logger.debug('Remove failed: {} not in playlist'.format(song))

        if song in self._bad_songs:
            self._bad_songs.remove(song)
1301643
private void fireMusicEnded() {
		playing = false;
		for (int i=0;i<listeners.size();i++) {
			((MusicListener) listeners.get(i)).musicEnded(this);
		}
	}
1240171
function(playlist) {
  this.playlist = playlist;
  this.index = 0;

  // Display the title of the first track.
  track.innerHTML = '1. ' + playlist[0].title;

  // Setup the playlist display.
  playlist.forEach(function(song) {
    var div = document.createElement('div');
    div.className = 'list-song';
    div.innerHTML = song.title;
    div.onclick = function() {
      player.skipTo(playlist.indexOf(song));
    };
    list.appendChild(div);
  });
}
766135
async def remove_items(self, *items):
    '''
    '''
    items = [i.id for i in (await self.process(items)) if i in self.items]
    if not items:
      return

    await self.connector.delete(
      'Playlists/{Id}/Items'.format(Id=self.id),
      EntryIds=','.join(items),
      remote=False
    )
1332820
def remove(self, sound):
        
        with self.chunk_available:
            sound.playing = False
            self.sounds.remove(sound)
797985
async def remove(self, index=""):
        

        if not self.state == 'ready':
            logger.debug("Trying to remove from wrong state '{}'".format(self.state))
            return

        if index == "":
            self.statuslog.error("Must provide index to remove")
            return
        elif index == "all":
            self.queue = []
            self.update_queue()
            self.statuslog.info("Removed all songs")
            return

        indexes = index.split("-")
        self.logger.debug("Removing {}".format(indexes))

        try:
            if len(indexes) == 0:
                self.statuslog.error("Remove must specify an index or range")
                return
            elif len(indexes) == 1:
                num_lower = int(indexes[0]) - 1
                num_upper = num_lower + 1
            elif len(indexes) == 2:
                num_lower = int(indexes[0]) - 1
                num_upper = int(indexes[1])
            else:
                self.statuslog.error("Cannot have more than 2 indexes for remove range")
                return
        except TypeError:
            self.statuslog.error("Remove index must be a number")
            return
        except ValueError:
            self.statuslog.error("Remove index must be a number")
            return

        if num_lower < 0 or num_lower >= len(self.queue) or num_upper > len(self.queue):
            if len(self.queue) == 0:
                self.statuslog.warning("No songs in queue")
            elif len(self.queue) == 1:
                self.statuslog.error("Remove index must be 1 (only 1 song in queue)")
            else:
                self.statuslog.error("Remove index must be between 1 and {}".format(len(self.queue)))
            return

        if num_upper <= num_lower:
            self.statuslog.error("Second index in range must be greater than first")
            return

        lower_songname = self.queue[num_lower][1]
        for num in range(0, num_upper - num_lower):
            self.logger.debug("Removed {}".format(self.queue[num_lower][1]))
            self.queue.pop(num_lower)

        if len(indexes) == 1:
            self.statuslog.info("Removed {}".format(lower_songname))
        else:
            self.statuslog.info("Removed songs {}-{}".format(num_lower + 1, num_upper))

        self.update_queue()
897389
private void doMoveSelectedEntriesInList(int moveBy)
	{
		PlayListEntry [] selected = playList.getSelectedEntries();
		if (selected!=null)
		{
			playlistUpdateThread.halt();
			try
			{
				if (moveBy < 0)
				{
					// Moveup --> Still possible?
					if ((selected[0].getIndexInPlaylist() + moveBy) < 0)
						moveBy = selected[0].getIndexInPlaylist();
					if (moveBy == 0) return;
					
					for (int i=0; i<selected.length; i++)
					{
						int fromIndex = selected[i].getIndexInPlaylist();
						playList.move(fromIndex, fromIndex + moveBy);
					}
				}
				else
				{
					// Movedown --> Still possible?
					int lastIndex = selected.length - 1;
					if ((selected[lastIndex].getIndexInPlaylist() + moveBy) >= playList.size())
						moveBy = playList.size() - 1 - selected[lastIndex].getIndexInPlaylist();
					if (moveBy == 0) return;
					
					for (int i=lastIndex; i>=0; i--)
					{
						int fromIndex = selected[i].getIndexInPlaylist();
						playList.move(fromIndex, fromIndex + moveBy);
					}
				}
				int showIndex = (moveBy<0)?selected[0].getIndexInPlaylist()-PLUS_LINES_VISABLE:selected[selected.length-1].getIndexInPlaylist()+PLUS_LINES_VISABLE;   
				createList(showIndex);
				firePlaylistChanged();
			}
			finally
			{
				playlistUpdateThread.restart();
			}
		}
	}
423351
def run_mp(songs):
    
    stats = Stats()
    if CONFIG['debug']:
        good = open('found', 'w')
        bad = open('notfound', 'w')

    logger.debug('Launching a pool of %d processes\n', CONFIG['jobcount'])
    chunksize = math.ceil(len(songs) / os.cpu_count())
    try:
        with Pool(CONFIG['jobcount']) as pool:
            for result in pool.imap_unordered(get_lyrics, songs, chunksize):
                if result is None:
                    continue

                for source, runtime in result.runtimes.items():
                    stats.add_result(source, result.source == source, runtime)

                found = process_result(result)
                if CONFIG['debug']:
                    if found:
                        good.write(f'{id_source(source)}: {result.song}\n')
                        good.flush()
                    else:
                        bad.write(str(result.song) + '\n')
                        bad.flush()

    finally:
        if CONFIG['debug']:
            good.close()
            bad.close()

    return stats
613625
function removeAllTracks(tracks, token, count, callback) {
    var track = tracks[count];

    if (!track) {
        return callback('done');
    }

    var options = {
        id: track.id,
        oauth_token: token.oauth_token
    };

    removeTrack(options).then(function (track) {
        if (DEBUG_MODE_ON) {
            console.log('removeTrack, ', track);
        }
        count = count + 1;
        removeAllTracks(tracks, token, count, callback)
    }).catch(function (err) {
        console.log('ERROR: removeTrack, ', err);
        count = count + 1;
        removeAllTracks(tracks, token, count, callback)
    })
}
361373
private void fireMusicSwapped(Music newMusic) {
		playing = false;
		for (int i=0;i<listeners.size();i++) {
			((MusicListener) listeners.get(i)).musicSwapped(this, newMusic);
		}
	}
858940
function play(name) {
        if (name === 'list') {
            return Object.keys(audio);
        }
        if (!(name in audio)) {
            d.error("Invalid audio name:", name);
            return;
        }

        audio[name].play();
    }
339084
public SoundCloudTrack remove(int trackIndex) {

        SoundCloudTrack removedTrack = null;
        ArrayList<SoundCloudTrack> tracks = mSoundCloudPlaylist.getTracks();

        // check if track is in the playlist
        if (trackIndex >= 0 && trackIndex < tracks.size()) {
            removedTrack = tracks.remove(trackIndex);

            if (tracks.size() == 0) {
                // track list empty after removal
                mCurrentTrackIndex = 0;
            } else if (trackIndex == tracks.size()) {
                // last song removed
                mCurrentTrackIndex = (mCurrentTrackIndex - 1) % tracks.size();
            } else if (trackIndex >= 0 && trackIndex < mCurrentTrackIndex) {
                // tracks translated on the right after a deletion before current played one.
                mCurrentTrackIndex = (mCurrentTrackIndex - 1) % tracks.size();
            }
        }
        return removedTrack;
    }
1071592
async def play(self):
        
        if self.repeat and self.current is not None:
            self.queue.append(self.current)

        self.current = None
        self.position = 0
        self._paused = False

        if not self.queue:
            await self.stop()
        else:
            self._is_playing = True
            if self.shuffle:
                track = self.queue.pop(randrange(len(self.queue)))
            else:
                track = self.queue.pop(0)

            self.current = track
            log.debug("Assigned current.")
            await self.node.play(self.channel.guild.id, track)
521763
def removeFromPlaylist(playlist,index,count,tracks)
      method = 'removeFromPlaylist'
      type = TODO
      args = {:playlist=>playlist,:index=>index,
        :count=>count,:tracks=>Rdio::keys(tracks)}
      return_object type,method,args,true
    end
477292
def select_one_song(songs):
        

        if len(songs) == 1:
            select_i = 0
        else:
            table = PrettyTable(['Sequence', 'Song Name', 'Artist Name'])
            for i, song in enumerate(songs, 1):
                table.add_row([i, song['name'], song['ar'][0]['name']])
            click.echo(table)

            select_i = click.prompt('Select one song', type=int, default=1)
            while select_i < 1 or select_i > len(songs):
                select_i = click.prompt('Error Select! Select Again', type=int)

        song_id, song_name = songs[select_i-1]['id'], songs[select_i-1]['name']
        song = Song(song_id, song_name)
        return song
804406
def play_song(self, song):
        
        if song is not None and song == self.current_song:
            logger.warning('The song is already under playing.')
        else:
            self._playlist.current_song = song
1070383
def library_remove(song)
      fail ArgumentError, 'Song object required' unless song.is_a?(Song)
      req = { userID: @id,
              songID: song.id,
              albumID: song.album_id,
              artistID: song.artist_id }
      @client.request('userRemoveSongFromLibrary', req)
    end