【问题标题】:How to check browser compatibility/support for image and video?如何检查浏览器对图像和视频的兼容性/支持?
【发布时间】:2019-12-06 08:10:19
【问题描述】:

我只是想检查浏览器与 Reactjs 网站应用程序中的图像和视频的兼容性。如果图像/视频的扩展不支持,则它必须显示警报消息或操作。如何做到这一点?

尝试过Modernizr

【问题讨论】:

标签: c# reactjs


【解决方案1】:

我试过了,给定的代码对我有用:

videoBrowserSupportValidation() {
    const extension = filename.split('.').pop(); // This is to get extenstion of your video file and filename is video file name
    const vidpath1 = "video/";
    var obj = document.createElement('video');
    var videoType = obj.canPlayType(vidpath1+extension); 
    if (videoType == "") {
        console.log("Invalid file , browser does not recognize video formats ");          
        // write your action
    }
    else {
        console.log("Valid file");  
        // write your action
    }

【讨论】:

  • 这仅适用于视频
猜你喜欢
  • 2012-03-15
  • 2012-08-15
  • 2021-08-04
  • 1970-01-01
  • 2014-03-27
  • 1970-01-01
  • 1970-01-01
  • 2013-07-25
  • 1970-01-01
相关资源
最近更新 更多