question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I get "Uncaught TypeError: player.ima is not a function"

See original GitHub issue

Hi,

I always get this error “Uncaught TypeError: player.ima is not a function” but I don’t know why. Anyone can help me ?

ads.js code

var player = videojs('content_video');

var options = {
  id: 'content_video',
  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='
};

player.ima(options);

// Remove controls from the player on iPad to stop native controls from stealing
// our click
var contentPlayer =  document.getElementById('content_video_html5_api');
if ((navigator.userAgent.match(/iPad/i) ||
      navigator.userAgent.match(/Android/i)) &&
    contentPlayer.hasAttribute('controls')) {
  contentPlayer.removeAttribute('controls');
}

// Initialize the ad container when the video player is clicked, but only the
// first time it's clicked.
var startEvent = 'click';
if (navigator.userAgent.match(/iPhone/i) ||
    navigator.userAgent.match(/iPad/i) ||
    navigator.userAgent.match(/Android/i)) {
  startEvent = 'touchend';
}

player.one(startEvent, function() {
    player.ima.initializeAdDisplayContainer();
    player.ima.requestAds();
    player.play();
});

my php code

<link href="//vjs.zencdn.net/5.3/video-js.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/videojs-contrib-ads/4.2.6/videojs.ads.css" />
<link rel="stylesheet" href="css/videojs.ima.css" />

<video id="content_video" class="video-js vjs-default-skin" controls autoplay preload="auto" height="400"
                  poster="img/<?php echo $element['img_normal']; ?>" data-setup="{}">
                    <source src="video/<?php echo $element['video']; ?>" type='video/mp4'>
                  </video>
    <script src="https://s0.2mdn.net/instream/video/client.js" async="" type="text/javascript"></script>
    <script src="//vjs.zencdn.net/5.10.7/video.js"></script>
    <script src="//imasdk.googleapis.com/js/sdkloader/ima3.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/videojs-contrib-ads/4.2.6/videojs.ads.min.js"></script>
    <script type="text/javascript" src="script/videojs.ima.js"></script>
    <script type="text/javascript" src="script/ads.js"></script>

Sorry for my bad english.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
MrWiLofDoomcommented, Jun 19, 2018

I sorted it out. Spent a lot of time on the blogs, tried a inch of solutions and then everything and tried again. Last attempt got it all working.

On Tue, Jun 19, 2018, 4:46 PM Shawn Busolits notifications@github.com wrote:

Do you have a live page where I can take a look? It should be compatible with ES6.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/googleads/videojs-ima/issues/361#issuecomment-398539761, or mute the thread https://github.com/notifications/unsubscribe-auth/AJhJc8qLsmktwQ_jKr4OkdmBPHUgc1Dkks5t-WMTgaJpZM4NDb-v .

1reaction
jackson-sandlandcommented, Mar 15, 2018

Having the same issue…there should be one npm install that gets you everything you need. Obviously, the ima library cannot be found.

Read more comments on GitHub >

github_iconTop Results From Across the Web

I get "Uncaught TypeError: player.ima is not a function" #345
It appears that your code is trying to initialize the Google IMA plugin multiple times. You should make sure that this.player.ima(options); only ...
Read more >
Videojs-ima plugin with requirejs not including plugins on load
You probably have initialized player.ads yourself (not provided in question) and IMA expect player.ads to be a function, what it is before ...
Read more >
VideoJS IMA Plugin is failing on Crunchyroll...but only on Chrome : r ...
It just gives me the error "Uncaught (in promise) TypeError: player.ima is not a function". Bizarrely, it works just fine in Firefox.
Read more >
IMA SDK v3 for Video.js - Google Groups
I am trying to start a preroll with no sound. setVolume(0) works fine, but the controlbar´s CSS is not correct. The mute-button and...
Read more >
Resolve VAST and IMA SDK errors - Google Ad Manager Help
Behavior varies by player implementation. error, Fatal errors likely stopped the ad request. Warning, Potentially non-fatal errors may have continued to play ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found