Comments (3)
Yes, if i remember well, the Clappr "can-autoplay" internal method is exposed in Utils module.
It should be reacheable, for exemple :
Clappr.Utils.canAutoPlayMedia(function(result, error) {
if (result) {
// can autoplay
} else {
// cannot autoplay
console.log(error);
}
});
See also html5 playback wrapper function (which take account of mobile devices).
from clappr-google-ima-html5-preroll.
Basically I'm running into an issue where ads are being skipped if autoplay isn't enabled in the browser. What's the best route to go in order to autostart the ads only if the browser allows it?
from clappr-google-ima-html5-preroll.
You could starts with something like this :
<html>
<head>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/clappr@latest/dist/clappr.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/clappr-google-ima-html5-preroll-plugin@latest/dist/clappr-google-ima-html5-preroll-plugin.min.js"></script>
<style>
.player {
width: 640px;
height: 360px;
overflow: hidden;
}
</style>
</head>
<body>
<div class="player"></div>
<script>
(function () {
var playerElement = document.querySelector('.player');
var apOpts = {
timeout: 500,
inline: false,
muted: false,
}
// Single Inline Linear. See https://developers.google.com/interactive-media-ads/docs/sdks/html5/tags
var vastTag = 'https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/124319096/external/single_ad_samples&ciu_szs=300x250&impl=s&gdfp_req=1&env=vp&output=vast&unviewed_position_start=1&cust_params=deployment%3Ddevsite%26sample_ct%3Dlinear&correlator=';
Clappr.Utils.canAutoPlayMedia(function(ap, err){
var player = new Clappr.Player({
source: 'http://clappr.io/highline.mp4',
parent: playerElement,
height: 360,
width: 640,
// Set to false and use plugin autostart option (or set to true if tag is false)
autoPlay: false,
plugins: {
core: [ClapprGoogleImaHtml5PrerollPlugin],
},
googleImaHtml5PrerollPlugin: {
tag: vastTag, // VAST tag URL (or false to disable plugin)
vpaid: 2, // Default is 0 (0 is DISABLED, 1 is ENABLED and 2 is INSECURE)
autostart: ap,
}
});
}, apOpts);
})();
</script>
</body>
</html>
from clappr-google-ima-html5-preroll.
Related Issues (17)
- Seek bar is not working after ad display (vod)
- Enable media control HOT 4
- HLS not playing after ad on IOS HOT 3
- Issue with Responsive container HOT 2
- Non linear ad support HOT 2
- Companion Ads HOT 3
- Skippable Ads on iOS 10+ HOT 1
- Poster not visible HOT 3
- Fullscreen is broken after ad display HOT 3
- Ad error: AdError 1005: The provided ad type: skippablevideo is not supported. HOT 5
- feat: trigger a new plugin event for ima custom settings
- This is only pre roll? mid rolls? HOT 1
- Autoplay Off but the video start everytime HOT 2
- Access-Control-Allow-Credentials Error HOT 11
- Not working with Clappr.FlasHLS plugin HOT 2
- VAST not working HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clappr-google-ima-html5-preroll.