使用 videojs-contrib-ads 与 react 和 typescript

问题描述

谁能提供一个使用videojs-vast-vpaid with react + typescript作为videojs插件的详细例子。 我尝试了以下方法 (来源:https://www.npmjs.com/package/videojs-vast-vpaid

videojs.plugin('ads-setup',function (opts) {
    var player = this;
    var adsCancelTimeout = 3000;
 
    var vastAd = player.vastClient({
      //Media tag URL
      adTag: "http://pubads.g.doubleclick.net/gampad/ads?env=....",playAdAlways: true,//Note: As requested we set the preroll timeout at the same place than the adsCancelTimeout
      adCancelTimeout: adsCancelTimeout,adsEnabled: !!options.adsEnabled
    });
});

我尝试将此代码添加到我的类组件中,但效果不佳,因为 this 将引用类组件上下文。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)