jwplayer播放一个视频并停止所有其他视频

时间:2017-01-03 13:43:17

标签: javascript jwplayer

我的页面上有多个jwplayer视频,其中包含以下配置:

$(function(){
    //add attributes to your ".video" DIV placeholder to customimize output
    //example: data-autostart="true" - see customSettings Object below.
    if (typeof(jwplayer) !== 'undefined'){
        $('.video').each(function(){
            var vid = $(this),
            videoSettings = {},
            settings = {
                autostart: false,
                width: '100%',
                aspectratio: '16:9',
                image: ''
            },
            customSettings = {
                autostart: vid.attr('data-autostart'),
                width: vid.attr('data-width'),
                aspectratio: vid.attr('data-aspectratio'),
                image: vid.attr('data-image')
            };
            $.extend(videoSettings, settings, customSettings);

            var playerInstance = jwplayer( vid.attr('id') ).setup({
                primary: "flash",
                file: Drupal.settings.basePath + $(this).attr('data-src'),
                autostart: videoSettings.autostart,
                aspectratio: videoSettings.aspectratio,
                image: Drupal.settings.basePath + videoSettings.image,
                skin: "glow",
                stretching: "exactfit",
                width: videoSettings.width,
                ga:{idstring: videoSettings.videotitle,
                    trackingobject: "pageTracker"
                   }
            });
        });
    }
});

我试图添加这个:

                events: {
                    onReady: function ()
                    {
                        jwplayer($('.video').id).stop();
                    }
                },

但是我收到以下错误:

[。PPAPIContext] GL错误:GL_INVALID_ENUM:glTexImage2D:目标是GL_TEXTURE_RECTANGLE_ARB

有没有办法让所有其他视频在播放时停止播放?

1 个答案:

答案 0 :(得分:0)

它对我有用......

  if(typeof jwplayer().stop === "function" ){
      jwplayer().stop();
  }