videojs / videojs-contrib-ads

A Tool for Building Video.js Ad Plugins
http://videojs.github.io/videojs-contrib-ads/
Other
384 stars 257 forks source link

player.ads is not a function #326

Closed vpaskovic closed 6 years ago

vpaskovic commented 6 years ago

I get this error all time .ads is not a function

I use AngularJS (1) and

"video.js": "^5.19.2",
"videojs-contrib-ads": "^5.1.6",
"vjs-video": "^0.1.11"
angular = require('angular');
require('angular-route');
require('angular-ui-bootstrap');
require('videojs-contrib-ads');
require('video.js');
require('vjs-video');

and after

$scope.$on('vjsVideoReady', function (e, data) {
data.player.ads();
})

this throws error

please help

incompl commented 6 years ago

What build tool are you using? I believe you need to register the ads plugin with certain build setups. Try adding this: videojs.registerPlugin('ads', contribAdsPlugin);

incompl commented 6 years ago

We believe this is fixed in master by this PR. The fix will be released soon: https://github.com/videojs/videojs-contrib-ads/pull/321

incompl commented 6 years ago

@vpaskovic Is this still an issue for you?

vpaskovic commented 6 years ago

Yes still not able to implement it to work, has someone else tried in the way described up? Gulp is used.

ldayananda commented 6 years ago

You may also want to require('videojs-contrib-ads'); after require('video.js');.

That said, if you could provide a reduced test case in something like JSBin, it would help with debugging the setup

incompl commented 6 years ago

Also take a look at this example in case it helps: https://github.com/videojs/videojs-contrib-ads/pull/312/files#diff-80b85f7007dced052a8e8ddb693843cb

incompl commented 6 years ago

@vpaskovic Did those suggestions help?

incompl commented 6 years ago

Closing since there hasn't been a response for awhile, please reopen or open a new issue if help is still needed. The new module import example I linked to should hopefully clarify how to do this!