Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I embed private youtube video in my site?

I have to display some private Youtube videos in my blog. I cannot embed them directly. What should I use to do this.

like image 693
Samik Chattopadhyay Avatar asked Apr 06 '12 15:04

Samik Chattopadhyay


People also ask

Can I embed a private YouTube video on a website?

Yes you can embed private and unlisted files on your website. If private, Youtube will ask for a login (if there is none) and the credentials will give access to watch the content or not, based on you are a manager/admin of the channel or have an invitation (invite emails from dashboard). If unlisted it will show!

How do I get the embed code for an unlisted video on YouTube?

Log in to your YouTube account and go to your unlisted video page. Click the Embed tab. Copy the embed code highlighted in blue.


2 Answers

You should set your videos to "unlisted" instead of "private". That way the video does not show up on your channel or on any search results but anyone with a link to the video can see it and you can embed the video on any site.

like image 129
PaperThick Avatar answered Oct 13 '22 05:10

PaperThick


I didn't try this workaround yet but theoritcally it should work, you need to use YouTube API V 3 and follow the below steps:

  1. Set the video's privacy status to unlisted through API.
  2. Embed the video via API in a hidden div.
  3. Use onPlayerStateChange event to check if the video player is currently playing the video, use the API to pause the video at the first second.
  4. If the state changed to "playing" then send an AJAX request to a server side script to revert the the video's privacy status to be private, once you get a confirmation message display the video and use the API to play it.

This should keep the video private even if the user copy & paste the URL in another tab, s/he should get a message that the video is private.

Here is a reference to YouTube iFrame API, which gives you an example for onPlayerStateChange Event

Please refer to this link to change the privacy status via API v 3

like image 33
Wessam El Mahdy Avatar answered Oct 13 '22 05:10

Wessam El Mahdy