mvmoay
mvmoay

Reputation: 1635

Video.js: how to find out if the current device has native playback before initializing?

Is there a way to find out if the currently used device will be playing on native controls with video.js before initializing the player?

I am working on a lightbox solution which should be just playing the video natively on iOS and Android if the current browser does support it. Didn't find any API hook or event for this.

Currently working with video.js v5.0.0-rc63.

Upvotes: 1

Views: 1144

Answers (2)

Kaiido
Kaiido

Reputation: 137084

If you only need to check if the video player uses its own controls, you can just check for your video element's controls attribute :

if(document.querySelector('video').controls){
    // native
}else{
    // videojs fallback
}

Upvotes: 1

Muhammad Usman
Muhammad Usman

Reputation: 1362

I have worked on video players. iOS not allow to use the physical controlls by external libraries (by code). but if you want to retrict or allow some device here is some piece of code (jQuery) by that you can check what type of device it is ..

if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
// some code..
}

Upvotes: 0

Related Questions