aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/assets/js/media.js
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-10-24 23:29:55 -0400
committerGitHub <noreply@github.com>2017-10-24 23:29:55 -0400
commitc2ca9066c6fd760bd6ef5d2f8f0530a89bfa7b66 (patch)
treea54665bb873b650b8f6f03b76cd59456ef79e296 /app/src/main/assets/js/media.js
parent64dbf74b7a44a25f41ed7ff2ebfa11db0bc91769 (diff)
downloadfrost-c2ca9066c6fd760bd6ef5d2f8f0530a89bfa7b66.tar.gz
frost-c2ca9066c6fd760bd6ef5d2f8f0530a89bfa7b66.tar.bz2
frost-c2ca9066c6fd760bd6ef5d2f8f0530a89bfa7b66.zip
WIP: Feature/pip video 2 (#405)
* Add dependency * Test new video view * Add initial video bindings * Implement drag to dismiss * Begin initial integration * Fix typo * Fix up url formatter * Update changelog * Create first fully integrated video build * Update translations * Update translations 2
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);
+}