ruffle.js
Ruffle 是一款开源免费的浏览器 Flash Player 插件解决方案,可以为您解决一些网页需要flash支持的解决方案
- Github ruffle-rs/ruffle: A Flash Player emulator written in Rust (github.com)
- 官网 Ruffle | Flash Player emulator written in the Rust programming language
- 从官网下载 ruffle.js相关资源
- 在你的webServer配置支持
.wasm文件和application/wasm
- 页面引入 ruffle.js
<script src="./js/ruffle/ruffle.js"></script>
- 创建id为'container'的标签('container'可以是任何值,可以有多个)
- 初始化
window.RufflePlayer = window.RufflePlayer || {};
window.RufflePlayer.config = {
"preloader": true,
};
window.addEventListener("load", (event) => {
const ruffle = window.RufflePlayer.newest();
const player = ruffle.createPlayer();
const container = document.getElementById("container");
container.appendChild(player);
player.load({
url: "test.swf",
backgroundColor: "#fff",
});
player.style.width = "1025px";
player.style.height = "770px";
});
- 修改加载时Logo和背景
使用# CSS variables
{
:root {
--preloader-background: no-repeat url("你的素材地址") center center;
--logo-display: none;
}
}
- ruffle.js的配置项,详情参考GitHub
window.RufflePlayer = window.RufflePlayer || {};
window.RufflePlayer.config = {
"publicPath": undefined,
"polyfills": true,
"autoplay": "auto",
"unmuteOverlay": "visible",
"backgroundColor": null,
"wmode": "window",
"letterbox": "fullscreen",
"warnOnUnsupportedContent": true,
"contextMenu": true,
"showSwfDownload": false,
"upgradeToHttps": window.location.protocol === "https:",
"maxExecutionDuration": {"secs": 15, "nanos": 0},
"logLevel": "error",
"base": null,
"menu": true,
"salign": "",
"scale": "showAll",
"quality": "high",
"preloader": true,
};