youtube-downloader
youtube-downloader copied to clipboard
Can't load another url when video is playing
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?...');
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);
}