رفتن به مطلب

مشکلی کوچک در کد Vast


پست های پیشنهاد شده

سلام

این یک کد کامل هستش که باهاش میتونین تبلیغات Vast رو روی ویدیوها نمایش بدید.

Quick Start

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
    <!-- loading IMA on your own -->
    <script src="https://imasdk.googleapis.com/js/sdkloader/ima3.js"></script>
    <!-- and the vast-ima-player -->
    <script src="https://unpkg.com/@glomex/vast-ima-player@1/dist/vast-ima-player.umd.js"></script>
    <title>My VAST-IMA-Player</title>
  </head>
  <body>
    <div id="videoContainer" style="max-width:600px; position:relative;">
      <video style="width:100%; height:100%;" id="mediaElement" controls playsinline poster="https://glomex.github.io/vast-ima-player/big-buck-bunny.png" preload="none">
        <source type="video/mp4" src="https://glomex.github.io/vast-ima-player/big-buck-bunny.mp4">
      </video>
      <!-- the ad-container needs to be placed above the video container -->
      <div id="adContainer" style="position:absolute; left:0; top:0;"></div>
    </div>
    <button id="playAd">Play Ad</button>
    <script>
      var adsRenderingSettings = new google.ima.AdsRenderingSettings();
      var imaPlayer = new vastImaPlayer.Player(
        google.ima,
        document.getElementById('mediaElement'),
        document.getElementById('adContainer'),
        adsRenderingSettings
      );
      document.getElementById('playAd').addEventListener('click', function() {
        var playAdsRequest = new google.ima.AdsRequest();
        playAdsRequest.adTagUrl = 'https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_ad_samples&sz=640x480&cust_params=sample_ct%3Dlinear&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator=';
        imaPlayer.playAds(playAdsRequest);
      });
    </script>
  </body>
</html>

 

این کد رو میتونید اینجا لینک ها تنها برای اعضای سایت قابل نمایش است.

یک مشکل این کد داره که برای پخش تبلیغ روی ویدیو باید روی دکمه play ad کلیک کرد.

خواستم بدونم که چه جوری میشه کاریش کرد که تبلیغ وقتی رو دکمه پخش ویدیوی خود ویدیو میزنی خودکار اول ویدیو پخش بشه؟

لینک به دیدگاه
به اشتراک گذاری در سایت های دیگر

مهمان
این موضوع برای عدم ارسال قفل گردیده است.
×
×
  • اضافه کردن...