Set Player Playlist
Does not validate whether or not YouTube playlist exists.


@param string $playlist Can be a URL or just the ID

@throws AudioPlayerException

@return $this
493123
public function playlist($playlist)
    {
        $oldSource = $this->source;
        $this->source = $playlist;

        $parsedURL = parse_url($playlist);

        // 1 thing, assume playlist.
        if (count($parsedURL) === 1) {
            $this->type = static::TYPE_PLAYLIST;
            $this->id = $parsedURL['path'];

            return $this->cookies()->theme(static::THEME_LIGHT);
        }

        // both playlist types use list=

        $parsedQuery = explode('&', $parsedURL['query']);
        // Find list=
        foreach ($parsedQuery as $v) {
            if (substr(strtolower($v), 0, 5) == 'list=') {
                $this->type = static::TYPE_PLAYLIST;
                $this->id = substr($v, 5);

                return $this->cookies()->theme(static::THEME_LIGHT);
            }
        }

        // If we don't find list=, then its not a playlist.
        $this->source = $oldSource;
        throw new AudioPlayerException('Could not identify playlist');
    }
647917
def current_song(self, song):
        
        self._last_song = self.current_song
        if song is None:
            self._current_song = None
        # add it to playlist if song not in playlist
        elif song in self._songs:
            self._current_song = song
        else:
            self.insert(song)
            self._current_song = song
        self.song_changed.emit(song)
361472
def setPlaylistCollaborating(playlist,collaborating)
      method = 'setPlaylistCollaborating'
      type = Boolean
      args = {:playlist=>playlist,:collaborating=>collaborating}
      return_object type,method,args,true
    end
858596
def playlist
      @_playlist ||= if playlists.any?
                       key, value = playlists.first
                       value
                     else
                       Playlist.new("Default")
                     end
    end
1310225
public function setAudio($audio)
	{
		if (is_string($audio)) {
			$this->audio = $audio;
		} else if (is_resource($audio)) {
			$this->addMultipart("audio", $audio);
			$this->audio = "attach://audio";
		} else if ($audio instanceof InputFile) {
			$this->addMultipart("audio", $audio->getFile());
			$this->audio = "attach://audio";
		}
	}
570291
private function setMatch(EloVersusInterface $match)
    {
        if (!in_array($match->getWinner(), array(0, 0.5, 1))) {
            throw new \RuntimeException(sprintf(
                'Invalid parameter, accept 0, 0.5 or 1, but %s given', $match->getWinner()
            ));
        }

        if (is_null($match->getPlayerA()) || is_null($match->getPlayerB())) {
            throw new \RuntimeException('The players A and B must be set.');
        }

        if ($match->getPlayerA()->getUser()->getId() == $match->getPlayerB()->getUser()->getId()) {
            throw new \RuntimeException('The players A and B are the same.');
        }

        $this->match = $match;

        return $this;
    }
1319673
public function cookies($useCookies = true)
    {
        if (!$useCookies && $this->getType() == static::TYPE_PLAYLIST) {
            throw new AudioPlayerException('Can not disable cookies with playlists.  YouTube limitation.');
        }

        if ($useCookies) {
            $this->cookies = true;
        } else {
            $this->cookies = false;
        }

        return $this;
    }
507477
public function setAudio($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\Speech\V1p1beta1\RecognitionAudio::class);
        $this->audio = $var;

        return $this;
    }
972023
function setMaxPlayers($maxPlayers, $multicall = false)
    {
        if (!is_int($maxPlayers)) {
            throw new InvalidArgumentException('maxPlayers = ' . print_r($maxPlayers, true));
        }

        return $this->execute(ucfirst(__FUNCTION__), array($maxPlayers), $multicall);
    }
389627
public function setFrequency($frequency)
	{
		if ( ! is_numeric($frequency) || $frequency < 1)
		{
			throw new \InvalidArgumentException('Wrong sample frequency value.');
		}
		
		$this->audioFrequency = $frequency;
		
		return $this;
	}
898017
public function setPlayers(array $players = [])
    {
        if (empty($players)
            || count($players) != 2
            || array_unique(array_filter($players)) < 2
        ) {
            return false;
        }

        $this->players = $players;
    }
258866
def loadlist(self, playlist, mode='replace'):
        """"""
        self.command('loadlist', playlist.encode(fs_enc), mode)
200276
def download_playlist_by_id(self, playlist_id, playlist_name):
        

        try:
            songs = self.crawler.get_playlist_songs(
                playlist_id)
        except RequestException as exception:
            click.echo(exception)
        else:
            folder = os.path.join(self.folder, playlist_name)
            for song in songs:
                self.download_song_by_id(song.song_id, song.song_name, folder)
1153837
public function setPlayer(Player $v = null)
    {
        if ($v === null) {
            $this->setPlayerId(NULL);
        } else {
            $this->setPlayerId($v->getId());
        }

        $this->aPlayer = $v;

        // Add binding for other direction of this n:n relationship.
        // If this object has already been added to the Player object, it will not be re-added.
        if ($v !== null) {
            $v->addRecord($this);
        }


        return $this;
    }
1065189
public function setMedia($src)
    {
        $src = str_replace(
            [
                'youtube.com/',
                'youtu.be',
                '?rel=0',
            ],
            [
                'youtube.com/embed/',
                'youtube.com/embed/',
                '',
            ],
            $src
        );

        if (strpos($src, 'youtube') !== false) {
            $src .= '?rel=0';
        }

        $this->media->attributes->addAttribute('src', $src);

        return $this;
    }
665706
public function playSingle($base64)
    {
        try {
            /**
             * Decode Path
             */
            $base64 = base64_decode($base64);

            /**
             * Path to File on Disk
             */
            $path = $this->getSearchPath() . '/' . $base64;

            /**
             * Path to Web URL
             */
            $file = ltrim($this->getBaseDir() . '/' . $base64, '/');

            /**
             * Server URL
             */
            $serverUrl = $this->serverUrl->get('serverurl')
                                         ->__invoke('/');

            clearstatcache();

            if (is_file($path)) {
                switch ($this->getFormat()) {
                    /**
                     * The most common playlist format
                     */
                    case 'm3u':
                        header("Content-Type: audio/mpegurl");
                        header("Content-Disposition: attachment; filename=" . basename($file) . ".m3u");

                        echo $serverUrl . str_replace(' ', '%20', $file);

                        exit;

                        break;

                    /**
                     * Shoutcast / Icecast / Winamp
                     */
                    case 'pls':
                        header("Content-Type: audio/x-scpls");
                        header("Content-Disposition: attachment; filename=" . basename($file) . ".pls");

                        $id3 = $this->getId3($path);

                        $name = !empty($id3['comments_html']['title'])
                            ? implode(
                                '<br>',
                                $id3['comments_html']['title']
                            )
                            : basename($path);

                        $playlist = '[Playlist]' . "\n";
                        $playlist .= 'File1=' . $serverUrl . str_replace(' ', '%20', $file) . "\n";
                        $playlist .= 'Title1=' . $name . "\n";
                        $playlist .= 'Length1=-1' . "\n";
                        $playlist .= 'Numberofentries=1' . "\n";
                        $playlist .= 'Version=2' . "\n";

                        echo $playlist;

                        exit;

                        break;

                    /**
                     * Error
                     */
                    default:
                        throw new \Exception(
                            $this->translate->translate(
                                'Format is not currently supported. Supported formats are: pls, m3u',
                                'mp3'
                            )
                        );
                }
            } else {
                throw new \Exception(
                    $path . ' ' . $this->translate->translate(
                        'was not found',
                        'mp3'
                    )
                );
            }
        } catch (\Exception $e) {
            throw $e;
        }
    }
1100776
protected function getPlaylistIdFromUrl($playlistUrl)
	{
		$playlistId = $playlistUrl;
		$urlPart = parse_url($playlistUrl);

		if (isset($urlPart['query']))
		{
			$query = $this->decodeString($urlPart['query']);

			if (isset($query['list']))
				$playlistId = $query['list'];
			elseif (isset($query['p']))
				$playlistId = $query['p'];
		}

		return $playlistId;
	}