mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-26 03:58:36 +00:00
Add SVGA animation preview support
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>SVGA Preview</title>
|
||||
<style>
|
||||
html, body {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
overflow: hidden;
|
||||
color: #fff;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="canvas"></canvas>
|
||||
<script src="https://unpkg.com/svga/dist/index.min.js"></script>
|
||||
<script src="svga2html.js"></script>
|
||||
</body>
|
||||
</html>
|
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* SvgaViewer: Provides SVGA animation preview with the following features.
|
||||
*
|
||||
* Requirements:
|
||||
* - Requires the following HTML structure:
|
||||
* <canvas id="canvas">
|
||||
* </canvas>
|
||||
* - SVGA file path is obtained via chrome.webview.hostObjects.external.GetPath()
|
||||
*
|
||||
* Features:
|
||||
* - Loads and plays SVGA animation files
|
||||
* - Uses SVGA.js library for parsing and playback
|
||||
* - Automatically starts playback after loading
|
||||
* - Handles asynchronous loading and mounting of SVGA files
|
||||
*/
|
||||
class SvgaViewer {
|
||||
constructor() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Play SVGA file.
|
||||
* @async
|
||||
*/
|
||||
async play() {
|
||||
const path = await chrome.webview.hostObjects.external.GetPath();
|
||||
const parser = new SVGA.Parser();
|
||||
|
||||
// Because the path is a local file, we need to convert it to a URL format
|
||||
parser.load('https://' + path).then(svga => {
|
||||
const player = new SVGA.Player(document.getElementById('canvas'));
|
||||
player.mount(svga).then(() => {
|
||||
player.start();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Create the SVGA viewer and play
|
||||
new SvgaViewer().play();
|
Reference in New Issue
Block a user