检查<视频>(Windows上的Safari 5.1.7-HTML5视频)

Check if pause() exists in <video> (Safari 5.1.7 on Windows - HTML5 videos)

本文关键字:视频 7-HTML5 Safari lt gt 检查 Windows 上的      更新时间:2023-09-26

Windows上的Safari 5.1.7在未安装Quicktime时不支持video元素上的play()pause()等。

因此,我想检测一下它是否得到支持。

jQuery('video').each(function(){
    this.pause();
});

返回:TypeError: 'undefined' is not a function (evaluating 'this.pause()')

jQuery('video').each(function(){
    if( <<I need a way to check if pause is in this>> ){
        this.pause();
    }
});

我正在寻找一种适当的方法。任何帮助都将不胜感激!

一些特征检测如何:

if (this.pause) {
  this.pause();
}

你甚至可以测试它是否是一个功能:

if (this.pause && Object.prototype.toString.call(this.pause) === '[object Function]') {
  this.pause();
}
jQuery('video').each( function () {
    if (this.pause) {  //use it as a truthy check
        this.pause();
    }
});