using unlisted youtube videos

give the following html code I need to make it so users can not download the by using the right mouse click or see the script code.
<script language="javascript">
var tag = document.createElement('script');

tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

// 3. This function creates an <iframe> (and YouTube player)
//    after the API code downloads.
var player;

function onYouTubeIframeAPIReady() {
    player = new YT.Player('player', {
        height: '390',
        width: '640',
     
        videoId: 'VRl66uuwA1E',
       playerVars: { 'autoplay': 1, 'controls': 0 ,'modebranding' :0 ,'showinfo' : 0},
        events: {
            'onReady': onPlayerReady,
                'onStateChange': onPlayerStateChange
        }
    });
}

// 4. The API will call this function when the video player is ready.
function onPlayerReady(event) {
    event.target.playVideo();
}

// 5. The API calls this function when the player's state changes.
//    The function indicates that when playing a video (state=1),
//    the player should play for six seconds and then stop.
var done = false;

function onPlayerStateChange(event) {
    if (event.data == YT.PlayerState.PLAYING && !done) {
        setTimeout(stopVideo, 6000);
        done = true;
    }
}

function stopVideo() {
    player.stopVideo();
}
</script>
<head>
  <meta charset="utf-8">

</head>
<body oncontextmenu="return false">
  <div id="player" ></div>
</body>

Open in new window


I am not fixated on javascript so if it needs to be in something else that is ok.
LVL 1
HalCHubAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
If you use the youtube api, then you will always get the ability to right click on the video and get the context menu including finding the url of the video.  Even if you could do that, the information is in your javascript code which is there for everybody to see.
videoId: 'VRl66uuwA1E',

Open in new window


The next option is to use a 3rd party player like flowplayer to stream youtube videos http://flash.flowplayer.org/demos/plugins/streaming/youtube.html.

If you really want control of your videos, then you will want to place your video on a CDN and you can tighten your controls however you want including only allowing the video to be played via your server.  This option will of course be the most expensive vs free youtube.  For free, you will have to allow some things to slide.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.