summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2021-01-25 09:55:33 +0300
committerAndrew Dolgov <[email protected]>2021-01-25 09:55:33 +0300
commitf55946e525ba80aeb3f089260fbb5e51d82057ae (patch)
treef1a36c2034a7a229d0d750b452233eb85de1f46e
initial
-rw-r--r--init.js17
-rw-r--r--init.php23
2 files changed, 40 insertions, 0 deletions
diff --git a/init.js b/init.js
new file mode 100644
index 0000000..4a31399
--- /dev/null
+++ b/init.js
@@ -0,0 +1,17 @@
+require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) {
+ ready(function () {
+ Event.observe(window, "focus", function() {
+ $$("video").forEach((vid) => {
+ if (vid.getAttribute("autoplay") == 1 && vid.paused)
+ vid.play();
+ })
+ });
+
+ Event.observe(window, "blur", function() {
+ $$("video").forEach((vid) => {
+ if (vid.getAttribute("autoplay") == 1 && !vid.paused)
+ vid.pause();
+ })
+ });
+ });
+});
diff --git a/init.php b/init.php
new file mode 100644
index 0000000..9183799
--- /dev/null
+++ b/init.php
@@ -0,0 +1,23 @@
+<?php
+class Af_Zz_Pause_Bg extends Plugin {
+ private $host;
+
+ function about() {
+ return array(1.0,
+ "Pause HTML5 videos when in background",
+ "fox");
+ }
+
+ function init($host) {
+ $this->host = $host;
+ }
+
+ function get_js() {
+ return file_get_contents(__DIR__ . "/init.js");
+ }
+
+ function api_version() {
+ return 2;
+ }
+
+}