youtube-downloader icon indicating copy to clipboard operation
youtube-downloader copied to clipboard

Can't load another url when video is playing

Open taavandais2 opened this issue 4 years ago • 1 comments

Thank for create an awesome library!

I'm using your library in my Laravel project, it's work. But, when i use stream function my web can't open another urls and resources. And, in Safari on MacOS, it works well in localhost. But, when i publish to heroku hosting, it can't play video (the same direct link work well on Chrome).

This is stream function: $youtube = new \YouTube\YouTubeStreamer(); $youtube->stream('https://r4---sn-n4v7knll.googlevideo.com/videoplayback?...');

taavandais2 avatar Nov 12 '20 04:11 taavandais2

The returning video urls are only for a specific client ip address. Your heroku app must parse a video url and then stream it. Try the following code, the $url variable is the full link to your YouTube video (the code is for the latest version):


$youtube = new \YouTube\YouTubeDownloader();

$links = $youtube->getDownloadLinks($url);

$best = $links->getFirstCombinedFormat();

if ($best) {
    $youtube = new \YouTube\YouTubeStreamer();
    $youtube->stream($best->url);
}

AgentSmith0 avatar Jun 07 '21 16:06 AgentSmith0