我们正在 ReactJS 项目中迁移到 VideoJS,除了 google IMA 插件外,一切似乎都运行良好。
有没有关于如何在 React 中使用 google-ima 插件的资源? https://www.npmjs.com/package/videojs-ima-player
我在这里收到“未捕获的错误:插件“ima”不存在”错误
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)
})
}