How can I embed private youtube video in my site?
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.
I do not think you can embed private youtube videos on your site and even if you do, they will not be able to view it because it's private.
You can embed your private videos but they will only show to you and those with whom you have shared it. See https://support.google.com/youtube/bin/answer.py?hl=en&answer=157177 for more.
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:
- Set the video's privacy status to unlisted through API.
- Embed the video via API in a hidden div.
- 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.
- 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