带有google IMA插件的reactJS中的VideoJS
我们正在ReactJS项目中迁移到VideoJS,除了GoogleIMA插件外,其他一切似乎都很好 有没有关于如何在React中使用google ima插件的资源? 我在这里得到了“未捕获错误:插件“ima”不存在”错误带有google IMA插件的reactJS中的VideoJS,reactjs,video.js,google-ima,Reactjs,Video.js,Google Ima,我们正在ReactJS项目中迁移到VideoJS,除了GoogleIMA插件外,其他一切似乎都很好 有没有关于如何在React中使用google ima插件的资源? 我在这里得到了“未捕获错误:插件“ima”不存在”错误 import React from "react"; import videojs from 'video.js' import 'videojs-ima'; class VideoJS extends React.Component { constructor(
import React from "react";
import videojs from 'video.js'
import 'videojs-ima';
class VideoJS extends React.Component {
constructor(props) {
super(props)
console.log(this.props)
}
generetePlayerOptions = () => {
return (
{
autoplay: true,
controls: true,
language: 'lt',
poster: this.props.playlist[0].image,
aspectRatio: '16:9',
sources: [{
src: this.props.playlist[0].file,
type: 'video/mp4'
}],
plugins: {
ima: {
adTagUrl: 'http://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/124319096/external/ad_rule_samples&ciu_szs=300x250&ad_rule=1&impl=s&gdfp_req=1&env=vp&output=xml_vmap1&unviewed_position_start=1&cust_params=sample_ar%3Dpremidpostpod%26deployment%3Dgmf-js&cmsid=496&vid=short_onecue&correlator='
}
}
}
)
}
componentDidMount() {
// instantiate Video.js
this.player = videojs(this.videoNode, this.generetePlayerOptions(), function onPlayerReady() {
console.log('onPlayerReady', this)
})
}
如果您导入它,它看起来将不起作用。 我不太喜欢我所做的,但它很管用
顺便问一下,如果我尝试调用这个.player.ima(),我也会得到“ima不是函数”。您使用的是官方插件还是链接的插件?两者都会引发此错误吗?在Next.js中尝试了此方法,在custom_document.js中添加了上述链接标记,但是,获取player.ima不是一个函数