mehulved
mehulved

Reputation: 381

Display mediaelement player if fullscreen api is supported by the browser else display youtube player

I am using mediaelement.js to display videos on my site. I'd like to place a check that if fullscreen API is available on the browser, use the mediaelement player, otherwise use the default youtube player.

How can I go about it?

Upvotes: 0

Views: 737

Answers (2)

Peter
Peter

Reputation: 36

if (element.mozRequestFullScreen) {
  // This is how to go into fullscren mode in Firefox
  // Note the "moz" prefix, which is short for Mozilla.
  element.mozRequestFullScreen();
} else if (element.webkitRequestFullScreen) {
  // This is how to go into fullscreen mode in Chrome and Safari
  // Both of those browsers are based on the Webkit project, hence the same prefix.
  element.webkitRequestFullScreen();
}

Upvotes: 2

mehulved
mehulved

Reputation: 381

I finally took a slightly different route. I have used php browser detection plugin for wordpress and used an if condition to serve different code to IE and Opera. Will also include older FF, Chrome, Safari to that list. So, the browser capability detection isn't happening but it works for the time being.

But it would be awesome for future purposes if somebody can answer on how to do this. I believe that can be done with ajax. But, my specific case would require more data - the video url is a custom field in wordpress and it passes through a for loop to get list of all the videos in the custom field.

Upvotes: 0

Related Questions