Samik Chattopadhyay
Samik Chattopadhyay

Reputation: 1860

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.

Upvotes: 39

Views: 137422

Answers (8)

MrAvgProgrammer
MrAvgProgrammer

Reputation: 1

I am extremely late to the discussion, however the work around I found that worked with Bookstack was to set the Youtube video to unlisted. Then generate embed code, and use.

Then go into Youtube and set video to Private. My embedded video still works, however if the user tries to copy URL and play it outside of my Bookstack Youtube says the video is Private.

Upvotes: 0

Viktor
Viktor

Reputation: 71

Came across this issue in 2023 and it seems like other alternatives like Vimeo are a better solution to a case where private video needs to be embedded onto a page. I am dealing with a custom web application which shows videos under a course that has been bought and was expecting that YouTube would serve as a hosting platform and videos could be retrieved by their ID's.

I tried many different things and even though "unlisted" videos serve as part of the solution, I encourage using Vimeo as it provides extra features, although it is paid.

Upvotes: 5

Paulo Dias
Paulo Dias

Reputation: 41

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!

The video must be embeddable!

Upvotes: 1

HENG Vongkol
HENG Vongkol

Reputation: 941

You cannot embed private video to your website because it's private, so cannot show to public viewer in your website.

Until now Youtube has three licences:

1 - Public: your video can be viewed publicly
2 - Unlisted: your video can seen or embedded by url or link and not show up in search result or your channel
3 - Private: your video is private, cannot be viewed

Upvotes: 3

Wessam El Mahdy
Wessam El Mahdy

Reputation: 467

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

Upvotes: 11

PaperThick
PaperThick

Reputation: 2799

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.

Upvotes: 111

Vacilando
Vacilando

Reputation: 3057

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.

Upvotes: 5

user1244123
user1244123

Reputation: 163

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.

Upvotes: 3

Related Questions