Skip to content

Commit 982e0bc

Browse files
committed
fix throw return
1 parent 5ee6c3d commit 982e0bc

File tree

1 file changed

+43
-55
lines changed

1 file changed

+43
-55
lines changed

src/renderer/components/views/FlashPlayer.tsx

Lines changed: 43 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -26,65 +26,53 @@ const FlashPlayer = ({
2626
const os = useMemo(() => getOS(), []);
2727

2828
useEffect((): any => {
29-
try {
30-
const container = player.current;
31-
container.innerHTML = '';
29+
const container = player.current;
30+
container.innerHTML = '';
3231

33-
let realPath;
34-
if (os === 'Linux' || os === 'macOS') {
35-
realPath = filePath.indexOf('file:') === -1 ? `file:///${filePath}` : filePath;
36-
} else {
37-
realPath = filePath.replace('file:///', '');
38-
}
39-
40-
window.RufflePlayer = window.RufflePlayer || {};
41-
window.RufflePlayer.config = {
42-
autoPlay,
43-
polyfills: false,
44-
preloader: false,
45-
letterbox: config.appConfigLetterbox ? 'on' : 'off',
46-
logLevel: 'error',
47-
contextMenu: !config.appConfigHideContext,
48-
base: `${realPath.indexOf('file:///') === -1 ? 'file:///' : ''}${realPath.substr(
49-
0,
50-
realPath.lastIndexOf(os === 'Windows' ? '\\' : '/'),
51-
)}`,
52-
};
53-
const ruffle = window.RufflePlayer.newest();
54-
const rPlayer = ruffle.createPlayer();
55-
rPlayer.id = 'player';
56-
rPlayer.addEventListener('loadedmetadata', async () => {
57-
const metaData = rPlayer?.metadata;
58-
await ConfigActions.setConfig({
59-
flashFileSwfVer: metaData?.swfVersion,
60-
flashFileFrame: metaData?.numFrames,
61-
flashFileAs3: metaData?.isActionScript3,
62-
flashFileWidth: metaData?.width,
63-
flashFileHeight: metaData?.height,
64-
flashFileBackgroundColor: metaData?.backgroundColor,
65-
flashFileFrameRate: metaData?.frameRate,
66-
});
67-
if (config.appConfigAdjustOriginalSize && metaData?.width && metaData?.height) {
68-
ipcRenderer.send('resizeWindow', {
69-
width: metaData.width,
70-
height: metaData.height,
71-
});
72-
}
73-
});
74-
container.appendChild(rPlayer);
75-
rPlayer.load(realPath);
76-
rPlayer.addEventListener('oncontextmenu', (e) => e.preventDefault());
77-
} catch (e) {
78-
return null;
32+
let realPath;
33+
if (os === 'Linux' || os === 'macOS') {
34+
realPath = filePath.indexOf('file:') === -1 ? `file:///${filePath}` : filePath;
35+
} else {
36+
realPath = filePath.replace('file:///', '');
7937
}
8038

81-
return () => {
82-
window.RufflePlayer = {};
83-
if (window?.RufflePlayer?.instance) {
84-
window.RufflePlayer.instance.destroy();
85-
window.RufflePlayer.instance = null;
86-
}
39+
window.RufflePlayer = window.RufflePlayer || {};
40+
window.RufflePlayer.config = {
41+
autoPlay,
42+
polyfills: false,
43+
preloader: false,
44+
letterbox: config.appConfigLetterbox ? 'on' : 'off',
45+
logLevel: 'error',
46+
contextMenu: !config.appConfigHideContext,
47+
base: `${realPath.indexOf('file:///') === -1 ? 'file:///' : ''}${realPath.substr(
48+
0,
49+
realPath.lastIndexOf(os === 'Windows' ? '\\' : '/'),
50+
)}`,
8751
};
52+
const ruffle = window.RufflePlayer.newest();
53+
const rPlayer = ruffle.createPlayer();
54+
rPlayer.id = 'player';
55+
rPlayer.addEventListener('loadedmetadata', async () => {
56+
const metaData = rPlayer?.metadata;
57+
await ConfigActions.setConfig({
58+
flashFileSwfVer: metaData?.swfVersion,
59+
flashFileFrame: metaData?.numFrames,
60+
flashFileAs3: metaData?.isActionScript3,
61+
flashFileWidth: metaData?.width,
62+
flashFileHeight: metaData?.height,
63+
flashFileBackgroundColor: metaData?.backgroundColor,
64+
flashFileFrameRate: metaData?.frameRate,
65+
});
66+
if (config.appConfigAdjustOriginalSize && metaData?.width && metaData?.height) {
67+
ipcRenderer.send('resizeWindow', {
68+
width: metaData.width,
69+
height: metaData.height,
70+
});
71+
}
72+
});
73+
container.appendChild(rPlayer);
74+
rPlayer.load(realPath);
75+
rPlayer.addEventListener('oncontextmenu', (e) => e.preventDefault());
8876
}, [url, filePath]);
8977

9078
return (

0 commit comments

Comments
 (0)