Example 2.14.00 - Rescheduling with a new playlist



The configuration for this example is:


<script>
var PLAYLISTS = [
       [
          { 
              url: "http://streaming.openvideoads.org/shows/bbb-640x360.mp4",
              duration: 10 
          },
          { 
              url: "http://streaming.openvideoads.org/shows/sintel-1024-stereo.mp4",
              duration: 11 
          }
       ],
       [
          { 
              url: "http://streaming.openvideoads.org/shows/the-black-hole.mp4",
              duration: 12 
          },
          { 
              url: "http://streaming.openvideoads.org/shows/bbb-640x360.mp4",
              duration: 13 
          }
       ]
];
       
var ACTIVE_PLAYLIST_INDEX = 0;

function createOVAConfig(adPosition) {
    var config = {
       debug: { levels: "fatal, config, vast_template, playlist, http_calls, tracking_events" },
       ads: {
          servers: [
             {
                type: "OpenX",
                apiAddress: OVA_OPENX_API
             }
          ],
          notice: { textStyle: "smalltext" },
          schedule: [
             {
                zone: "18",
                position: adPosition
             }
          ]
       }
    };
    return config;
}

function rescheduleWithAdPosition(position) {
   ACTIVE_PLAYLIST_INDEX = ((ACTIVE_PLAYLIST_INDEX == 0) ? 1 : 0);
   if($f().getPlugin('ova').scheduleAds(PLAYLISTS[ACTIVE_PLAYLIST_INDEX], createOVAConfig(position))) {
      debug("OVA successfully rescheduled with " + position + " ad positions");
   }
   else {
	  debug("OVA failed to reschedule with " + position +  " ad positions");
   }
}

flowplayer("a.example", "", {
    playlist: PLAYLISTS[ACTIVE_PLAYLIST_INDEX],

    plugins: {	    
        controls: {
            autoHide: "always"
        },

        ova: {
            url: "",

            "ads": {
                 "servers": [
                     {
                          "type": "OpenX",
                          "apiAddress": "",
                     }
                 ],
                 "notice": { "textStyle": "smalltext" },
                 "schedule": [
                       {
                           "zone": "5",
                           "position": "pre-roll"
                       }
                 ]
            },

            "debug": {
                 "levels": ""
            }
        }
    }
});
</script>

<ul>
  <li><a href="#" onclick="rescheduleWithAdPosition('pre-roll');">
    Reschedule with pre-rolls
  </a></li>
  <li><a href="#" onclick="rescheduleWithAdPosition('post-roll');">
    Reschedule with post-rolls
  </a></li>
</ul>