Skip to content

🎥 Make videos programmatically with React

canvas approach

Patric Salvisberg33d62bd9cd1e
diff --git a/packages/bundler/src/index-html.ts b/packages/bundler/src/index-html.ts
index 81f9c7b168..979656071f 100644
--- a/packages/bundler/src/index-html.ts
+++ b/packages/bundler/src/index-html.ts
@@ -74,10 +74,10 @@ export const indexHtml = ({
<link rel="preconnect" href="https://fonts.gstatic.com" />
${
includeFavicon
- ? ` <link rel="icon" type="image/png" href="/remotion.png" />\n`
+ ? ` <link id="favicon" rel="icon" type="image/png" href="/remotion.png" />\n`
: ''
}
- <title>${title}</title>
+ <title>${title} </title>
</head>
<body>
<script>window.remotion_numberOfAudioTags = ${numberOfAudioTags};</script>
diff --git a/packages/cli/src/editor/components/Notifications/ServerDisconnected.tsx b/packages/cli/src/editor/components/Notifications/ServerDisconnected.tsx
index c448f2f4e7..fd16b8bf20 100644
--- a/packages/cli/src/editor/components/Notifications/ServerDisconnected.tsx
+++ b/packages/cli/src/editor/components/Notifications/ServerDisconnected.tsx
@@ -1,4 +1,5 @@
import React, {useContext} from 'react';
+import favicon1 from '../../../../web/favicon1.png';
import {StudioServerConnectionCtx} from '../../helpers/client-id';
const container: React.CSSProperties = {
@@ -48,6 +49,24 @@ export const ServerDisconnected: React.FC = () => {
return null;
}
+ console.log('imported favicon1: ', favicon1);
+ const fav = document.getElementById('favicon') as HTMLLinkElement;
+ const canvas = document.createElement('canvas');
+ const context = canvas.getContext('2d');
+ const img = document.createElement('img');
+ img.src = favicon1;
+ img.onload = () => {
+ context?.drawImage(img, 0, 0);
+ };
+
+ console.log('image: ', img);
+ if (fav) {
+ fav.href = canvas.toDataURL('image/png');
+ }
+
+ console.log('fav', fav);
+ // fav?.setAttribute('href', favicon1);
+
return (
<div style={container} className="css-reset">
<div style={message}>
diff --git a/packages/cli/web/favicon1.png b/packages/cli/web/favicon1.png
new file mode 100644
index 0000000000..d6dfeae4f4
Binary files /dev/null and b/packages/cli/web/favicon1.png differ