Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ME-14380-lazy-ads #535

Merged
merged 4 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 69 additions & 39 deletions docs/vast-vpaid.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,30 @@

var adTagUrl = "https://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=vmap&unviewed_position_start=1&cust_params=deployment%3Ddevsite%26sample_ar%3Dpreonly&cmsid=496&vid=short_onecue&correlator=";

player = cloudinary.videoPlayer('player', {
player1 = cloudinary.videoPlayer('player', {
cloud_name: 'demo',
ads: {
adTagUrl: adTagUrl,
debug: true
}
});

player.playlistByTag('video_race', {
player1.source('elephants');

player2 = cloudinary.videoPlayer('player-playlist', {
cloud_name: 'demo',
ads: {
adTagUrl: adTagUrl,
debug: true
}
});

player2.playlistByTag('video_race', {
autoAdvance: true,
repeat: true,
}).then(function() {
var divElem = document.querySelector("#playlist-data");
var list = player.playlist().list().map(function(source) {
var list = player2.playlist().list().map(function(source) {
return source.publicId()
}).join(', ');

Expand All @@ -62,17 +72,33 @@
<h1>Cloudinary Video Player</h1>
<h3 class="mb-4">VAST and VPAID</h3>

<video
id="player"
playsinline
controls
muted
autoplay
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the non autoplay was causing a bug it seems that autoplay can be a factor, i would provide two examples one with autoplay and one without.

class="cld-video-player"
width="500"
></video>

<p id="playlist-data"></p>
<div class="video-container mb-4">
<h4>Single video with ads</h4>
<video
id="player"
playsinline
controls
muted
class="cld-video-player"
width="500"
></video>
</div>

<div class="video-container mb-4">
<h4>Playlist with Ads</h4>

<video
id="player-playlist"
playsinline
controls
muted
autoplay
class="cld-video-player"
width="500"
></video>

<p id="playlist-data"></p>
</div>

<p class="mt-4">
<a href="https://cloudinary.com/documentation/video_player_ads_monetization">Ads and monetization documentation</a>
Expand All @@ -84,6 +110,16 @@ <h3 class="mt-4">Example Code:</h3>

&lt;video
id="player"
playsinline
controls
muted
class="cld-video-player"
width="500"&gt;
&lt;/video&gt;

&lt;video
id="player-playlist"
playsinline
controls
muted
autoplay
Expand All @@ -94,36 +130,30 @@ <h3 class="mt-4">Example Code:</h3>
</code>
<code class="language-javascript">

// Initialize player
var player = cloudinary.videoPlayer('player', {
cloud_name: 'demo' ,
plugins: {
vastClient: {
adTagUrl: "https://rtr.innovid.com/r1.5554946ab01d97.36996823;cb={random_number}",
adCancelTimeout: 5000,
adsEnabled: true,
playAdAlways: true
}
player1 = cloudinary.videoPlayer('player', {
cloud_name: 'demo',
ads: {
adTagUrl: AD_TAG_URL,
debug: true
}
});

player1.source('elephants');

player2 = cloudinary.videoPlayer('player-playlist', {
cloud_name: 'demo',
ads: {
adTagUrl: AD_TAG_URL,
debug: true
}
});

// Pass a sorter to sort list in alphabetical order by publicId
var sorter = function(a, b) {
if (a.publicId < b.publicId) return 1;
if (a.publicId > b.publicId) return -1;
return 0;
};

// Fetch playlist by tag. Since this operation involves an API call
// the function returns a Promise when the operation completes.
// The return value is 'player'.
player.playlistByTag('demo', {
sorter: sorter,
autoAdvance: 0,
repeat: true
player2.playlistByTag('video_race', {
autoAdvance: true,
repeat: true,
}).then(function() {
var divElem = document.querySelector("#playlist-data");
var list = player.playlist().list().map(function(source) {
var list = player2.playlist().list().map(function(source) {
return source.publicId()
}).join(', ');

Expand Down
155 changes: 150 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"uuid": "^9.0.0",
"video.js": "8.5.2",
"videojs-contrib-ads": "^7.3.2",
"videojs-ima": "^2.1.0",
"videojs-ima": "^2.3.0",
"videojs-per-source-behaviors": "^3.0.0",
"webfontloader": "^1.6.28"
},
Expand Down
1 change: 1 addition & 0 deletions src/index.all.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import cloudinary from './index.js';

export * from './index.js';
export * from './plugins/dash/videojs-dash.js';
export * from './plugins/ima/ima.js';
export * from './plugins/playlist/playlist.js';
export * from './plugins/styled-text-tracks/styled-text-tracks.js';
export * from './plugins/interaction-areas/interaction-areas.service.js';
Expand Down
Loading
Loading