Google Chrome不会提示用户在我的网站上启用Flash [英] Google Chrome is not prompting the users to enable flash on my site

查看:431
本文介绍了Google Chrome不会提示用户在我的网站上启用Flash的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Google Chrome不再提示用户在我的网站上启用播放用户上传的视频所需的Flash。这是一个最近的变化,我认为这是由于Chrome缓慢禁用2017年的闪存(我没有改变任何东西)。它可以在Firefox上正常工作。



最好的解决方案是将视频转换为mp4而不是flv,但现在这一秒我需要解决这个问题,主动使用现场。我需要一种方法来强制浏览器提示用户启用闪存。我知道这是可能的,因为我在其他网站上看到它,但我不知道如何ATM。任何想法?



以下是播放视频的代码:

  < script type ='text / javascript'src ='/ jwplayer / swfobject.js'> / script> 
< div id ='mediaspaceX'>这段文字将被替换< / div>

< script type ='text / javascript'>
var so = new SWFObject('/ jwplayer / player.swf','mpl',640,480,'9');
so.addParam('allowfullscreen','true');
so.addParam('allowscriptaccess','always');
so.addParam('wmode','opaque');
so.addVariable('file',escape('the_video.flv'));
so.addVariable('backcolor','111111');
so.addVariable('frontcolor','7fc9eb');
so.addVariable('lightcolor','cd6a28');
so.addVariable('screencolor','000000');

so.addVariable('playlistsize','0');
so.addVariable('skin','/ jwplayer / stylish.swf');
so.write('mediaspaceX');
< / script>


解决方案



  / ** 
*尝试显示浏览器启用闪存的提示
*
* Chrome从56版开始,Edge从15开始禁用flash
*。要提醒用户启用Flash,他们建议将用户发送到
* flash播放器下载页面。然后这个浏览器会捕获这样的请求
*并向用户显示一个提示:
* https://www.chromium.org/flash-roadmap#TOC-Developer-Recommendations
*在这个方法,我们强迫这样的promt导航用户adobe
*站点在iframe,而不是顶部窗口
* /
函数requestFlashPermission(){
var iframe = document.createElement( 'IFRAME');
iframe.src ='https://get.adobe.com/flashplayer';
iframe.sandbox ='';
document.body.appendChild(iframe);
document.body.removeChild(iframe);
}


var isNewEdge =(navigator.userAgent.match(/ Edge \ /(\d +)/)|| [])[1]> 14;
var isNewSafari =(navigator.userAgent.match(/ OS X(\ d +)/)|| [])[1]> 9;
var isNewChrome =(navigator.userAgent.match(/ Chrom(e | ium)\ /(\ d +)/)|| [])[2]> 56
&& !/Mobile/i.test(navigator.userAgent的);
var canRequestPermission = isNewEdge || isNewSafari || isNewChrome;

if(!swfobject.hasFlashPlayerVersion('10')&& canRequestPermission){
//如果flash不可用,请尝试提示用户启用
requestFlashPermission();
// Chrome需要用户点击以允许iframe嵌入
$(window).one('click',requestFlashPermission);

基于: https://www.chromium.org/flash-roadmap#TOC-Developer-Recommendations


Google Chrome is no longer prompting users on my site to enable flash which is required to play the videos that the users upload. This is a recent change and I think it's due to Chrome slowly disabling flash over the year 2017 (I haven't changed anything). It works fine on Firefox.

The best solution is to convert videos to mp4 rather than flv, but right now this second I need to fix the problem for those actively using the site. I need a way to force the browser to prompt the user to enable flash. I know it's possible as I've seen it on other sites but I'm not sure how ATM. Any ideas?

Here's the code that plays the video:

<script type='text/javascript' src='/jwplayer/swfobject.js'>/script>
<div id='mediaspaceX'>This text will be replaced</div>

<script type='text/javascript'>
  var so = new SWFObject('/jwplayer/player.swf','mpl',640,480,'9');
  so.addParam('allowfullscreen','true');
  so.addParam('allowscriptaccess','always');
  so.addParam('wmode','opaque');
  so.addVariable('file',escape('the_video.flv'));
  so.addVariable('backcolor','111111');
  so.addVariable('frontcolor','7fc9eb');
  so.addVariable('lightcolor','cd6a28');
  so.addVariable('screencolor','000000');

  so.addVariable('playlistsize','0');
  so.addVariable('skin','/jwplayer/stylish.swf');
  so.write('mediaspaceX');
</script>

解决方案

You can force browser to show permission prompt using this hack:

/**
 * Tries to show browser's promt for enabling flash
 *
 * Chrome starting from 56 version and Edge from 15 are disabling flash
 * by default. To promt user to enable flash, they suggest to send user to
 * flash player download page. Then this browser will catch such request
 * and show a promt to user:
 * https://www.chromium.org/flash-roadmap#TOC-Developer-Recommendations
 * In this method we are forcing such promt by navigating user to adobe
 * site in iframe, instead of top window
 */
function requestFlashPermission() {
    var iframe = document.createElement('iframe');
    iframe.src = 'https://get.adobe.com/flashplayer';
    iframe.sandbox = '';
    document.body.appendChild(iframe);
    document.body.removeChild(iframe);
}


var isNewEdge = (navigator.userAgent.match(/Edge\/(\d+)/) || [])[1] > 14;
var isNewSafari = (navigator.userAgent.match(/OS X (\d+)/) || [])[1] > 9;
var isNewChrome = (navigator.userAgent.match(/Chrom(e|ium)\/(\d+)/) || [])[2] > 56
    && !/Mobile/i.test(navigator.userAgent);
var canRequestPermission = isNewEdge || isNewSafari || isNewChrome;

if (!swfobject.hasFlashPlayerVersion('10') && canRequestPermission) {
    // in case, when flash is not available, try to prompt user to enable it
    requestFlashPermission();
    // Chrome requires user's click in order to allow iframe embeding
    $(window).one('click', requestFlashPermission);
}

Based on: https://www.chromium.org/flash-roadmap#TOC-Developer-Recommendations

这篇关于Google Chrome不会提示用户在我的网站上启用Flash的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆