Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
带有google IMA插件的reactJS中的VideoJS_Reactjs_Video.js_Google Ima - Fatal编程技术网

带有google IMA插件的reactJS中的VideoJS

带有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(

我们正在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(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)
        })
    }

如果您导入它,它看起来将不起作用。 我不太喜欢我所做的,但它很管用

  • 需要在index.html的头部添加脚本/css
  • 
    
    顺便问一下,如果我尝试调用这个.player.ima(),我也会得到“ima不是函数”。您使用的是官方插件还是链接的插件?两者都会引发此错误吗?在Next.js中尝试了此方法,在custom_document.js中添加了上述链接标记,但是,获取player.ima不是一个函数