Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div id="player"></div>
<div id="controls">
  <button id="ad-toggle" disabled>
    Toggle ad playback
  </button>
  <p>The button will be enabled only during ads</p>
</div>
<script async src="//acdn.adnxs.com/prebid/not-for-prod/1/prebid.js"></script>
<script src="//cdn.flowplayer.com/releases/native/stable/plugins/ads.min.js"></script>
<script src="//cdn.flowplayer.com/releases/native/stable/flowplayer.min.js"></script>
<script src="//imasdk.googleapis.com/js/sdkloader/ima3.js"></script>

              
            
!

CSS

              
                @import url('//cdn.flowplayer.com/releases/native/edge/style/flowplayer.css');
  
#player {
  max-width: 40em;
  width: 100%;
  float: left;
}

#controls {
  float: left;
  padding: 1em;
}

              
            
!

JS

              
                      var pbjs = pbjs || {};
      pbjs.que = pbjs.que || [];

      // The ad tag in Flowplayer can be actual ad tag or promise to an ad tag.
      // We return the ad tag if it is available before the player is ready to play
      // Otherwise the player waits for 2 secs for tag to be available.
      var adtag = null
      var timeout = 2000
      var asyncTag = function() {
        if (adtag) return Promise.resolve(adtag)

        return new Promise(function (resolve) {
          setTimeout(function() {
            resolve(adtag)
          }, timeout)
        })
      }

      /*
       Prebid Video adUnit
       */

      var videoAdUnit = {
        code: 'video1',
        sizes: [640,480],
        mediaTypes: {
          video: {
            context: "instream"
          }
        },
        bids: [
          {
            bidder: 'appnexus',
            params: {
              placementId: '13232361', // Add your own placement id here
              video: {
                skipppable: true,
                playback_method: ['auto_play_sound_off']
              }
            }
          }
        ]
      };

      pbjs.que.push(function(){
        pbjs.addAdUnits(videoAdUnit); // add your ad units to the bid request

        pbjs.setConfig({
          debug: true,
          cache: {
            url: 'https://prebid.adnxs.com/pbc/v1/cache'
          }
        });

        pbjs.requestBids({
          bidsBackHandler: function(bids) {
            var videoUrl = pbjs.adServers.dfp.buildVideoUrl({
              adUnit: videoAdUnit,
              params: {
                iu: '/19968336/prebid_cache_video_adunit',
                cust_params: {
                  section: "blog",
                  anotherKey: "anotherValue"
                },
                output: "vast"
              }
            });
            adtag = videoUrl;
          }
        });
      });
        
var player = flowplayer('#player', { 
  src: "//edge.flowplayer.org/drive.mp4",
  title: "Flowplayer demo",
  description: "Demo showing ads",
  ima: {
    ads: [
      {"time":0,"adTag":asyncTag}
    ]
  },                 
  token:"eyJraWQiOiJ0QTB3ZXhqODhrUHciLCJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NiJ9.eyJjIjoie1wiYWNsXCI6NixcImlkXCI6XCJ0QTB3ZXhqODhrUHdcIixcImRvbWFpblwiOltcInMuY29kZXBlbi5pb1wiXX0iLCJpc3MiOiJGbG93cGxheWVyIn0.PB25ufW_Kuuf7otErbIK50Q8N73TbP5F8qeCBUbJNqiq81yxjbLUgYkdkyNSRosGRAlkbTmtEUGp8KykRIXzig"
})

var btn = document.querySelector('#ad-toggle');

btn.addEventListener('click', function() {
  if (player.ads.adPlaying) player.ads.pause();
  else player.ads.resume();
})

function toggleDisabled(disabled) {
  return function() { btn.disabled = disabled }
}

player.ads.on(flowplayer.AdEvents.AD_STARTED, toggleDisabled(false));
player.ads.on(flowplayer.AdEvents.AD_COMPLETED, toggleDisabled(true));
player.ads.on(flowplayer.AdEvents.AD_SKIPPED, toggleDisabled(true));

              
            
!
999px

Console