我想在使用Media ElementJs播放视频之前设置视频广告 我从以下网站下载最新版本的MediaElementJS: https://github.com/mediaelement/mediaelement/zipball/master
在demo文件夹中: 我编辑了这个Javascript代码:
<script id="mejs-code">
var mediaElements = document.querySelectorAll('video, audio');
for (var i = 0, total = mediaElements.length; i < total; i++) {
var features = ['prevtrack', 'playpause', 'nexttrack', 'current', 'progress', 'duration', 'speed', 'skipback', 'jumpforward',
'markers', 'volume', 'playlist', 'loop', 'shuffle', 'contextmenu'];
// To demonstrate the use of Chromecast with audio
if (mediaElements[i].tagName === 'AUDIO') {
features.push('chromecast');
}
new MediaElementPlayer(mediaElements[i], {
// This is needed to make Jump Forward to work correctly
pluginPath: 'https://cdnjs.cloudflare.com/ajax/libs/mediaelement/4.2.3/',
shimScriptAccess: 'always',
autoRewind: false,
features: features,
currentMessage: 'Now playing:'
});
}
这些代码:
<script id="mejs-code">
var mediaElements = document.querySelectorAll('video, audio');
for (var i = 0, total = mediaElements.length; i < total; i++) {
var features = ['prevtrack', 'playpause', 'nexttrack', 'current', 'progress', 'duration', 'speed', 'skipback', 'jumpforward',
'markers', 'volume', 'playlist', 'loop', 'shuffle', 'contextmenu','ads'];
// To demonstrate the use of Chromecast with audio
if (mediaElements[i].tagName === 'AUDIO') {
features.push('chromecast');
}
new MediaElementPlayer(mediaElements[i], {
// This is needed to make Jump Forward to work correctly
pluginPath: 'https://cdnjs.cloudflare.com/ajax/libs/mediaelement/4.2.3/',
shimScriptAccess: 'always',
autoRewind: false,
adsPrerollMediaUrl: 'http://media.productionhub.com.s3.amazonaws.com/preroll.mp4',
adsPrerollAdUrl: 'http://www.github.com/',
features: features,
currentMessage: 'Now playing:'
});
}
但在播放视频之前我无法看到我的VideoAds 请帮助我谢谢。
答案 0 :(得分:0)
您需要使用https://github.com/mediaelement/mediaelement-plugins存储库设置广告的网址,然后adsPrerollMediaUrl应该是一个数组而不仅仅是一个字符串