Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New VR Plugin - Temp PR #4295

Draft
wants to merge 5 commits into
base: 2.97
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions modules/vrAppLauncher/resources/vrAppLauncher.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
(function (mw, $) {
"use strict";

mw.PluginManager.add(
"vrAppLauncher",
mw.KBaseComponent.extend({
defaultConfig: {
parent: mw.isMobileDevice()
? "topBarContainer"
: "controlsContainer",
order: 53,
displayImportance: "low",
align: "right",
smartContainer: "morePlugins",
smartContainerCloseEvent: "openVrApp",
showTooltip: true,
title: "VR",
newWindowURLFormat: "VRviewer:-json$-mode$Video360$-videoName${KalturaCdnUrl}/p/103/sp/10300/playManifest/entryId/{entryID}/tags/source/format/download/protocol/http/{fileName}.mp4"
},
isSafeEnviornment: function() {
// when should the plugin load - only when the tag of 'PLAYVR' exits in the entry.
var entry = this.getPlayer().evaluate('{mediaProxy.entry}');
var tags = entry ? entry.tags.split(', ') : [];
var index = tags.findIndex(function (tag) {
return tag.toLowerCase() === 'playvr';
});

return index > -1;
},
setup: function () {
var _this = this;

this.bind("openVrApp", function () {
_this.openVrApp();
});
},
openVrApp: function () {
var entry = this.getPlayer().evaluate('{mediaProxy.entry}');
var newWindowURL = this.getConfig("newWindowURLFormat", true);
var cdnUrl = mw.getConfig('Kaltura.CdnUrl');

newWindowURL = newWindowURL.replace("{entryID}", entry.id);
newWindowURL = newWindowURL.replace("{KalturaCdnUrl}", cdnUrl);
newWindowURL = newWindowURL.replace("{fileName}", encodeURI(entry.name)); // encode in case of spaces

var win = window.open(newWindowURL, '_self');
win.focus();
},
getComponent: function () {
if(!this.$el) {
this.$el = $( '<button />' )
.attr("title", this.getConfig("title"))
.addClass("btn icon-vr" + this.getCssClass())
.click(function() {
if (this.isDisabled) return;
this.getPlayer().triggerHelper("openVrApp");
}.bind(this));
}
return this.$el;
}
})
);
})(window.mw, window.jQuery);
30 changes: 30 additions & 0 deletions modules/vrAppLauncher/tests/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Audio Download</title>
<script
type="text/javascript"
src="../../../../../mwEmbed/mwEmbedLoader.php"
></script>
</head>
<body>
<div
id="kaltura_player_1"
style="width: 600px; height: 370px; float: left"
></div>
<script>
mw.setConfig("forceMobileHTML5", true);
kWidget.embed({
targetId: "kaltura_player_1",
wid: "_1647401",
uiconf_id: "41410881",
entry_id: "1_kuomwihj",
flashvars: {
vrAppLauncher: {
plugin: true
}
}
});
</script>
</body>
</html>
7 changes: 7 additions & 0 deletions modules/vrAppLauncher/vrAppLauncher.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"vrAppLauncher": {
"scripts": "resources/vrAppLauncher.js",
"dependencies": ["mw.KBasePlugin"],
"kalturaPluginName": "vrAppLauncher"
}
}