Flare-k

Connect with Mongo Atlas

1 +import "@babel/polyfill";
1 import dotenv from "dotenv"; 2 import dotenv from "dotenv";
2 import express from "express"; 3 import express from "express";
3 import morgan from "morgan"; 4 import morgan from "morgan";
......
1 +/* eslint-disable no-console */
2 +import getBlobDuration from "get-blob-duration";
3 +
1 const videoContainer = document.getElementById("jsVideoPlayer"); 4 const videoContainer = document.getElementById("jsVideoPlayer");
2 const videoPlayer = document.querySelector("#jsVideoPlayer video"); 5 const videoPlayer = document.querySelector("#jsVideoPlayer video");
3 const playBtn = document.getElementById("jsPlayButton"); 6 const playBtn = document.getElementById("jsPlayButton");
...@@ -89,8 +92,12 @@ const formatDate = (seconds) => { ...@@ -89,8 +92,12 @@ const formatDate = (seconds) => {
89 function getCurrentTime() { 92 function getCurrentTime() {
90 currentTime.innerHTML = formatDate(Math.floor(videoPlayer.currentTime)); 93 currentTime.innerHTML = formatDate(Math.floor(videoPlayer.currentTime));
91 } 94 }
92 -function setTotalTime() { 95 +
93 - const totalTimeString = formatDate(videoPlayer.duration); 96 +async function setTotalTime() {
97 + const blob = await fetch(videoPlayer.src).then((response) => response.blob());
98 + const duration = await getBlobDuration(blob);
99 + console.log(duration);
100 + const totalTimeString = formatDate(duration);
94 totalTime.innerHTML = totalTimeString; 101 totalTime.innerHTML = totalTimeString;
95 setInterval(getCurrentTime, 1000); 102 setInterval(getCurrentTime, 1000);
96 } 103 }
......
...@@ -4,7 +4,7 @@ import dotenv from "dotenv"; ...@@ -4,7 +4,7 @@ import dotenv from "dotenv";
4 4
5 dotenv.config(); 5 dotenv.config();
6 6
7 -mongoose.connect(process.env.MONGO_URL, { 7 +mongoose.connect(process.env.MONGO_URL_PROD, {
8 useNewUrlParser: true, 8 useNewUrlParser: true,
9 useFindAndModify: false, 9 useFindAndModify: false,
10 }); 10 });
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
16 "author": "Kang Yeon Wook", 16 "author": "Kang Yeon Wook",
17 "license": "ISC", 17 "license": "ISC",
18 "dependencies": { 18 "dependencies": {
19 + "@babel/cli": "^7.10.3",
19 "@babel/core": "^7.9.6", 20 "@babel/core": "^7.9.6",
20 "@babel/node": "^7.8.7", 21 "@babel/node": "^7.8.7",
21 "@babel/polyfill": "^7.10.1", 22 "@babel/polyfill": "^7.10.1",
...@@ -32,6 +33,7 @@ ...@@ -32,6 +33,7 @@
32 "express": "^4.17.1", 33 "express": "^4.17.1",
33 "express-session": "^1.17.1", 34 "express-session": "^1.17.1",
34 "extract-text-webpack-plugin": "^4.0.0-beta.0", 35 "extract-text-webpack-plugin": "^4.0.0-beta.0",
36 + "get-blob-duration": "^1.1.1",
35 "helmet": "^3.22.0", 37 "helmet": "^3.22.0",
36 "mongoose": "^5.9.15", 38 "mongoose": "^5.9.15",
37 "morgan": "^1.10.0", 39 "morgan": "^1.10.0",
......
This diff is collapsed. Click to expand it.