how to get adTagUrl for videojs-ima

54 Views Asked by At

I am developing a video streaming project on laravel. I need to show ads on my html video player during play the videos like youtube. For this, I have created an account on "Google adsense" and created "ad unit".

I have tried this using "videojs-ima". Which is mentioned in google docs.

https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side

The code is:

        <html>

        <head>
          <!-- Load dependent stylesheets. -->
          <link rel="stylesheet" href="//googleads.github.io/videojs-ima/node_modules/video.js/dist/video-js.min.css" />
          <link rel="stylesheet"
            href="//googleads.github.io/videojs-ima/node_modules/videojs-contrib-ads/dist/videojs.ads.css" />
          <link rel="stylesheet" href="//googleads.github.io/videojs-ima/dist/videojs.ima.css" />
        </head>

        <body>
          <video id="content_video" class="video-js vjs-default-skin" controls preload="auto" width="640" height="360">
            <source src="https://storage.googleapis.com/gvabox/media/samples/android.mp4" type="video/mp4" />
          </video>
          <!-- Load dependent scripts -->
          <script src="//googleads.github.io/videojs-ima/node_modules/video.js/dist/video.min.js"></script>
          <script src="//imasdk.googleapis.com/js/sdkloader/ima3.js"></script>
          <script src="//googleads.github.io/videojs-ima/node_modules/videojs-contrib-ads/dist/videojs.ads.min.js"></script>
          <script src="//googleads.github.io/videojs-ima/dist/videojs.ima.js"></script>

          <script>
            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);
            // On mobile devices, you must call initializeAdDisplayContainer as the result
            // of a user action (e.g. button click). If you do not make this call, the SDK
            // will make it for you, but not as the result of a user action. For more info
            // see our examples, all of which are set up to work on mobile devices.
            // player.ima.initializeAdDisplayContainer();
          </script>
        </body>

        </html>

This is playing videos with ads section. But I wanted to know few things.

  1. Does this need any account like google AdSense or ad manager?
  2. If it needs it, then what do I have to change in the given code?
  3. Is the "adTagUrl" same for all the developer? If not then how can I get my adTagUrl?
  4. How can I manage the ad's timing according to me? Like if I want to shows adds "at start" or after 10 or 20 secnds.

Please guide me. Thankyou.

0

There are 0 best solutions below