MediaElement.js 广告无效

MediaElement.js Ads not work

我想在使用 Media ElementJs 播放视频之前设置视频广告 我从以下位置下载最新版本的 MediaElementJS: https://github.com/mediaelement/mediaelement/zipball/master

在演示文件夹中: 我编辑这个 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:'
    });
}

但是我在播放视频之前看不到我的视频广告 请帮助我谢谢。

您需要使用 https://github.com/mediaelement/mediaelement-plugins 存储库为广告设置 URL,然后 adsPrerollMediaUrl 应该是一个数组,而不仅仅是一个字符串