我正在尝试使用video.js
和谷歌的 IMA 插件来实现显示视频广告[videojs-ima][1]
在示例代码中有以下部分:
// Initialize the ad container when the video player is clicked, but only the
// first time it's clicked.
var startEvent = 'click';
if (navigator.userAgent.match(/iPhone/i) ||
navigator.userAgent.match(/iPad/i) ||
navigator.userAgent.match(/Android/i)) {
startEvent = 'tap';
}
但是当在移动设备上startEvent
设置为时,我收到以下错误:tap
Uncaught TypeError: document.createTouch is not a function(anonymous function) @ ima3.js:252Ha @ ima3.js:9zm @ ima3.js:252h.Ld @ ima3.js:253Ze @ ima3.js:68h.dispatchEvent @ ima3.js:66im.w @ ima3.js:243We @ ima3.js:63Se @ ima3.js:64(anonymous function) @ ima3.js:62
ima3.js:252
Uncaught TypeError: Cannot read property 'apply' of undefined
当我注释掉这些错误时,startEvent = 'tap'
我不再收到这些错误,但是video.js
播放器的某些功能不起作用,即我无法通过单击视频区域来暂停视频(我需要单击暂停按钮,这很难移动设备)。
我怎样才能让这个“点击”事件在移动设备上正常工作?