Rishi Jogle
Rishi Jogle

Reputation: 287

Full Screen Option in Chromeless player using Javascript?

I am using Youtube Javascript API to develop chromeless player. Can you tell me How to Add / Develop "Full Screen Control" using Javascript on player ?

Upvotes: 2

Views: 10845

Answers (1)

Greg Schechter
Greg Schechter

Reputation: 2299

This is not something that currently exists in the YouTube api. Instead you can use the javascript fullscreen api to provide the functionality. Details can be found on MDN here.

https://developer.mozilla.org/en-US/docs/DOM/Using_fullscreen_mode

The code sample would look something like this

var player = new YT.player('#my-video');
// Once the user clicks a custom fullscreen button
var el = document.getElementById('#my-player-element-container');
if (el.requestFullScreen) {
  el.requestFullScreen();
} else if (el.mozRequestFullScreen) {
  el.mozRequestFullScreen();
} else if (el.webkitRequestFullScreen) {
  el.webkitRequestFullScreen();
}

Upvotes: 8

Related Questions