检查设备是否可以使用Cordova解码视频 [英] Check if device can decode video or not using Cordova

查看:85
本文介绍了检查设备是否可以使用Cordova解码视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Ionic(Cordova)应用中使用 VR视图. VR视图的文档指出某些较旧的设备无法解码大于1080p(1920x1080)的视频".

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.

我有两个视频:一个用于较新的设备(4k),一个用于较旧的设备(1080p).我想检查设备是否能够解码4k视频.如果没有,则应下载1080p视频.

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.

如何检查设备是否能够解码4k?我当时正在考虑尝试播放一段很短的内置4k视频并捕获错误,但是如果没有视频播放器出现,我将无法正常工作.应该在后台完成.

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?

推荐答案

对于响应最高支持的最大播放分辨率的本机Cordova API,我看不到太多.我个人会尝试一种更优雅的方法,只是获得设备的分辨率,然后查看它是否高于HD或等于或低于HD分辨率.

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);
}

这篇关于检查设备是否可以使用Cordova解码视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆