-
Notifications
You must be signed in to change notification settings - Fork 6
/
video.js
35 lines (30 loc) · 860 Bytes
/
video.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// to save the video to local storage
const saveVideo = (videoUrl) => {
chrome.storage.local.set({ videoUrl });
};
// on page open, check if there is a video url
chrome.storage.local.get(["videoUrl"], (result) => {
console.log("video url", result);
if (result.videoUrl) {
console.log("play video from storage", result);
playVideo(result);
}
});
const playVideo = (message) => {
const videoElement = document.querySelector("#recorded-video");
const url = message?.videoUrl || message?.base64;
// update the saved video url
saveVideo(url);
videoElement.src = url;
videoElement.play();
};
chrome.runtime.onMessage.addListener((message, sender) => {
switch (message.type) {
case "play-video":
console.log("play video", message);
playVideo(message);
break;
default:
console.log("default");
}
});