From 4bc9ca69ae34e3fb336291c50481c5aca35c1c4d Mon Sep 17 00:00:00 2001 From: vyleung Date: Fri, 3 Jun 2022 05:35:51 -0700 Subject: [PATCH] RELEASE: v.2.0.3 - fixed: playing a video then activating the plugin shows incorrect icon (addresses #8) --- package-lock.json | 4 ++-- package.json | 2 +- src/index.js | 36 +++++++++++++++++++++++++++++++----- 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 288be5e..030e430 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "logseq-helium-plugin", - "version": "2.0.1", + "version": "2.0.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "logseq-helium-plugin", - "version": "2.0.1", + "version": "2.0.3", "license": "MIT", "dependencies": { "@logseq/libs": "^0.0.6", diff --git a/package.json b/package.json index 3aac611..81b5290 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "logseq-helium-plugin", - "version": "2.0.1", + "version": "2.0.3", "description": "Float videos for an improved note-taking experience", "main": "dist/index.html", "targets": { diff --git a/src/index.js b/src/index.js index d0a5bf0..434f4a5 100644 --- a/src/index.js +++ b/src/index.js @@ -265,10 +265,6 @@ function startFloat(e) {
  • - - - -
  • @@ -318,9 +314,39 @@ function startFloat(e) { display: flex; } `) + + // show appropriate play/pause icon based on whether the video is paused or not + setDriftlessTimeout(() => { + // youtube videos + if (video_id.includes("youtube-player")) { + current_video = parent.window.YT.get(video_id); + + // if the video is paused or cued + if ((current_video.getPlayerState() == 2)|| (current_video.getPlayerState() == 5)) { + showPlayButton(); + } + // if the video is playing + else if (current_video.getPlayerState() == 1) { + showPauseButton(); + play = true; + } + } + // local videos + else if (video_id.includes("helium-localVideo")) { + current_video = parent.document.getElementById(`${video_id}`); + + if (current_video.paused) { + showPlayButton(); + } + else { + showPauseButton(); + play = true; + } + } + }, 10); } } - }); + }); float = false; play = false;