如何使用 javascript 防止 chrome 的闪光音频模式
How to prevent flash audio mode for chrome with javascript
版本 49
存在 Chrome 错误
这影响了我基于此 api http://soundcloud.lrdiv.co/ ( github repo https://github.com/lrdiv/ember-soundcloud )
的应用程序
基本上问题是 Soundcloud Api 使用 soundmanager2 作为处理音频流的基础,它本身有 2 种模式 flash 和 html5。问题是,如果 Flash 播放器可用,它会尝试使用它并失败,而如果它不可用,它只会使用 html5 并立即工作。
证据是,如果您转到此处 chrome://plugins/ 并停用 Flash 播放器,音频流将在 Chrome 中再次工作。
在此讨论 https://github.com/soundcloud/soundcloud-javascript/issues/39#issuecomment-206726301 中,一种可能的临时破解方法是检测 chrome 和 return 是否在 Flash 模式下播放。
function d() {
var t, e, n, i;
if ("undefined" != typeof window.ActiveXObject)
try {
i = new window.ActiveXObject("ShockwaveFlash.ShockwaveFlash"),
i && (t = i.GetVariable("$version"))
} catch (r) {}
else
window.navigator && window.navigator.plugins && window.navigator.plugins.length > 0 && (n = "application/x-shockwave-flash",
e = window.navigator.mimeTypes,
e && e[n] && e[n].enabledPlugin && e[n].enabledPlugin.description && (t = e[n].enabledPlugin.description));
// @todo, chrome flash player bug, if under chrome, dont return true here, more info:
// https://github.com/soundcloud/soundcloud-javascript/issues/39
**if (!!window.chrome) {
return false
}**
return t
}
我想在我的 sdk.js 中做同样的事情,但不太清楚我在哪一行我必须阻止 chrome
的闪存流
在我的 sdk.js 中,我不得不添加
soundManager.preferFlash = false;
不要将 Flash 插件用作音频播放器
版本 49
存在 Chrome 错误这影响了我基于此 api http://soundcloud.lrdiv.co/ ( github repo https://github.com/lrdiv/ember-soundcloud )
的应用程序基本上问题是 Soundcloud Api 使用 soundmanager2 作为处理音频流的基础,它本身有 2 种模式 flash 和 html5。问题是,如果 Flash 播放器可用,它会尝试使用它并失败,而如果它不可用,它只会使用 html5 并立即工作。
证据是,如果您转到此处 chrome://plugins/ 并停用 Flash 播放器,音频流将在 Chrome 中再次工作。
在此讨论 https://github.com/soundcloud/soundcloud-javascript/issues/39#issuecomment-206726301 中,一种可能的临时破解方法是检测 chrome 和 return 是否在 Flash 模式下播放。
function d() {
var t, e, n, i;
if ("undefined" != typeof window.ActiveXObject)
try {
i = new window.ActiveXObject("ShockwaveFlash.ShockwaveFlash"),
i && (t = i.GetVariable("$version"))
} catch (r) {}
else
window.navigator && window.navigator.plugins && window.navigator.plugins.length > 0 && (n = "application/x-shockwave-flash",
e = window.navigator.mimeTypes,
e && e[n] && e[n].enabledPlugin && e[n].enabledPlugin.description && (t = e[n].enabledPlugin.description));
// @todo, chrome flash player bug, if under chrome, dont return true here, more info:
// https://github.com/soundcloud/soundcloud-javascript/issues/39
**if (!!window.chrome) {
return false
}**
return t
}
我想在我的 sdk.js 中做同样的事情,但不太清楚我在哪一行我必须阻止 chrome
的闪存流在我的 sdk.js 中,我不得不添加
soundManager.preferFlash = false;
不要将 Flash 插件用作音频播放器