aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/assets/js/media.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/assets/js/media.js')
-rw-r--r--app/src/main/assets/js/media.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/app/src/main/assets/js/media.js b/app/src/main/assets/js/media.js
new file mode 100644
index 00000000..852a1e8c
--- /dev/null
+++ b/app/src/main/assets/js/media.js
@@ -0,0 +1,31 @@
+// we will media events
+if (!window.hasOwnProperty('frost_media')) {
+ console.log('Registering frost_media');
+ window.frost_media = true;
+
+ var _frostMediaClick = function(e) {
+
+ /*
+ * Commonality; check for valid target
+ */
+ var element = e.target || e.srcElement;
+ if (!element.hasAttribute("data-sigil") || !element.getAttribute("data-sigil").includes("playInlineVideo")) return;
+ console.log("Found inline video");
+ element = element.parentNode;
+ if (!element.hasAttribute("data-store")) return;
+ var dataStore;
+ try {
+ dataStore = JSON.parse(element.getAttribute("data-store"));
+ } catch (e) {
+ return;
+ }
+ if (!dataStore.src) return;
+ console.log("Inline video", dataStore.src);
+ if (typeof Frost !== 'undefined') Frost.loadVideo(dataStore.src);
+ e.stopPropagation();
+ e.preventDefault();
+ return;
+ }
+
+ document.addEventListener('click', _frostMediaClick, true);
+}