Skip to content

Commit

Permalink
Merge pull request #135 from vaninanton/screenshot
Browse files Browse the repository at this point in the history
Скриншоты на videowall
  • Loading branch information
vaninanton authored Jan 22, 2025
2 parents 44ec266 + e868261 commit da780b3
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 68 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="ru">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0; viewport-fit=cover" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
<meta name="theme-color" content="#0f172a" />
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes" />
Expand Down
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@owliehq/vue-addtohomescreen": "^2.0.3",
"axios": "^1.7.9",
"dayjs": "^1.11.13",
"hls.js": "^1.5.19",
"hls.js": "^1.5.20",
"ios-pwa-splash": "^1.0.0",
"moment": "^2.30.1",
"query-string": "^9.1.1",
Expand All @@ -31,7 +31,7 @@
"postcss": "^8.5.1",
"prettier": "^3.4.2",
"tailwindcss": "^3.4.17",
"vite": "^6.0.7",
"vite": "^6.0.11",
"vite-plugin-mkcert": "^1.17.6",
"vite-plugin-pwa": "^0.21.1"
},
Expand Down
132 changes: 98 additions & 34 deletions src/components/VideoWall.vue
Original file line number Diff line number Diff line change
@@ -1,39 +1,103 @@
<script setup>
import { defineAsyncComponent } from "vue";
const VideoWallItem = defineAsyncComponent(() => import("./VideoWallItem.vue"));
const videos = [
{
title: "Ледник Богдановича",
description: "Верхняя станция",
src: "https://ipcam.kz/cam6/index.m3u8",
poster: "/previews/3212b47c65ccc0cb9759f5c08632c563.jpg",
},
{
title: "Средняя станция",
description: "Средняя станция",
src: "https://ipcam.kz/cam5/index.m3u8",
poster: "/previews/ffa10e45b1d87ab0aa8796bc7969046c.jpg",
},
{
title: "Бугель",
description: "Базовая станция",
src: "https://ipcam.kz/cam2/index.m3u8",
poster: "/previews/d5361ff25a96271df9ac614d9138806a.jpg",
},
{
title: "Подъемник",
description: "Базовая станция",
src: "https://ipcam.kz/cam1/index.m3u8",
poster: "/previews/197f1dde9a2c929cca5496f225cc2d62.jpg",
},
];
</script>
<template>
<ul class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-2 mx-auto">
<ul
class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-2 mx-auto"
v-on="{ click: capture }"
>
<li class="relative" v-for="video in videos" v-bind:key="video.title">
<VideoWallItem :video="video" />
<VideoWallItem ref="videoWallItem" :video="video" />
</li>
</ul>
</template>
<script>
import VideoWallItem from "./VideoWallItem.vue";
export default {
components: {
VideoWallItem,
},
data() {
return {
videos: [
{
title: "Ледник Богдановича",
description: "Верхняя станция",
src: "https://ipcam.kz/cam6/index.m3u8",
poster: "/previews/3212b47c65ccc0cb9759f5c08632c563.jpg",
},
{
title: "Средняя станция",
description: "Средняя станция",
src: "https://ipcam.kz/cam5/index.m3u8",
poster: "/previews/ffa10e45b1d87ab0aa8796bc7969046c.jpg",
},
{
title: "Бугель",
description: "Базовая станция",
src: "https://ipcam.kz/cam2/index.m3u8",
poster: "/previews/d5361ff25a96271df9ac614d9138806a.jpg",
},
{
title: "Подъемник",
description: "Базовая станция",
src: "https://ipcam.kz/cam1/index.m3u8",
poster: "/previews/197f1dde9a2c929cca5496f225cc2d62.jpg",
},
],
};
},
methods: {
capture() {
const canvas = document.createElement("canvas");
const context = canvas.getContext("2d");
canvas.width = 2560;
canvas.height = 1440;
context.drawImage(
this.$refs.videoWallItem[0].$refs.video,
0,
0,
1280,
720,
);
context.drawImage(
this.$refs.videoWallItem[1].$refs.video,
0,
720,
1280,
720,
);
context.drawImage(
this.$refs.videoWallItem[2].$refs.video,
1280,
0,
1280,
720,
);
context.drawImage(
this.$refs.videoWallItem[3].$refs.video,
1280,
720,
1280,
720,
);
const dataURI = canvas.toDataURL("image/png");
let yourDate = new Date();
const link = document.createElement("a");
link.style.display = "none";
link.setAttribute(
"download",
"snowcam.vaninanton.ru-" + yourDate.toISOString() + ".png",
);
link.setAttribute(
"href",
dataURI.replace("image/png", "image/octet-stream"),
);
document.body.appendChild(link);
link.click();
},
},
};
</script>
22 changes: 0 additions & 22 deletions src/components/VideoWallItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
muted
allowfulscreen
playsinline
@click="getScreenshot"
></video>
</div>
</div>
Expand Down Expand Up @@ -58,27 +57,6 @@ export default {
this.loaded = true;
}, 1000);
},
getScreenshot() {
const { video } = this.$refs;
const canvas = document.createElement("canvas");
canvas.width = 1280;
canvas.height = 720;
canvas
.getContext("2d")
.drawImage(video, 0, 0, canvas.width, canvas.height);
const dataURI = canvas.toDataURL("image/png");
const link = document.createElement("a");
link.style.display = "none";
link.setAttribute("download", "image.png");
link.setAttribute(
"href",
dataURI.replace("image/png", "image/octet-stream"),
);
document.body.appendChild(link);
link.click();
},
},
mounted() {
this.playVideo();
Expand Down
2 changes: 1 addition & 1 deletion videowall.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="ru">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0; viewport-fit=cover" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
<meta name="theme-color" content="#0f172a" />
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes" />
Expand Down

0 comments on commit da780b3

Please sign in to comment.