Check if device can decode video or not using Cord

2019-07-13 07:17发布

I'm using VR view in my Ionic (Cordova) app. VR view's docs state that "some older devices cannot decode video larger than 1080p (1920x1080)".

In my app, the user downloads the video file first, so it's not streaming the video.

I have two videos: one for newer devices (in 4k), and one for the older devices (in 1080p). I want to check if the device is capable of decoding the 4k video. If not, it should download the 1080p video.

How could I check if a device is capable of decoding 4k? I was thinking about trying to play a very short baked-in 4k video and catching the error, but I can't get it to work without the video player showing up. It should be done in the background.

Is there a more elegant solution to this?

1条回答
仙女界的扛把子
2楼-- · 2019-07-13 07:49

I don't see much for native Cordova APIs that respond with what is the maximum supported playback resolution. I personally would try a more elegant approach, just getting the device's resolution and seeing if it is above HD or equal-below HD resolution.

Use the following to figure out the display size in pixels:

function getDeviceDimension() {
    console.log("Device Dimension using PhoneGap");
    console.log("Width = " + screen.width);
    console.log("Height = " + screen.height);
}
查看更多
登录 后发表回答