Skip to content

Commit

Permalink
Add One-Click install of JW Player to backend web setup.
Browse files Browse the repository at this point in the history
LongTail Video has given consent for MythTV to provide a One-Click
install button for users to install JW Player.  JW Player's
adaptiveProvider.swf provides HTTP Live Streaming support in
flash-capable browsers.

'3rd Party Software' -> 'JW Player' on the web setup menu.

The 'Install JW Player' button will download and install a .zip
package containing JW Player and the adaptiveProvider.swf.
The .zip contents are installed under ~/.mythtv/3rdParty/JW_Player/

LongTail Video has also given permission for MythTV to redistribute
the player, so the .zip is downloaded from MythTV directly, not
from LongTail Video.
  • Loading branch information
cpinkham committed Jan 22, 2012
1 parent 867d96a commit d41ef68
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 0 deletions.
49 changes: 49 additions & 0 deletions mythtv/html/3rdParty/jwplayer.qsp
@@ -0,0 +1,49 @@
<h3>JW Player&trade; by LongTail Video</h3>
<a href='http://www.longtailvideo.com/players/'>JW Player&trade;</a>
is a Flash &amp; HTML5 Video Player for FLV, H.264, MP3 and YouTube Videos.<br>
<a href='http://www.mythtv.org'>MythTV</a> uses JW Player via MythWeb and
the mythbackend webserver to allow HTTP Live Streaming playback of
recordings and videos.<br>
<br>
<h3>Installation Process</h3>
The 'Install JW Player' button will download and install a ZIP archive containing JW Player<br>
and the JW Player adaptiveProvider.swf plugin to support HTTP Live Streaming playback.<br>
<!--
You do not have to install the ZIP file on your MythWeb server, MythWeb will access<br>
these files via the mythbackend webserver.<br>
-->
<br>
<h3>Licensing</h3>
The player is licensed under a
<a href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons License</a>.<br>
A JW Player license is required if you are using this product for one of the following reasons:<br>
<li>You are a business / corporation, etc.</li>
<li>You are running ads on your site</li>
<li>You want to remove the JW Watermark in the video player</li>
<br>
If you are unsure whether you need to purchase a license, please <a href="http://www.longtailvideo.com/support/contact-us">contact LongTail Video</a>.<br>

<%
var content = new Content();

var hash = content.GetHash("3rdParty", "JW_Player/player.swf");

if (hash == "")
{
%>
<h3>JW Player&trade; is <b>not</b> installed.</h3>
<input type=button value='Install JW Player' onClick='installPackage("jwplayer.zip"); loadContent("/3rdParty/jwplayer.qsp");'><br>
<%
}
else
{
%>
<h3>JW Player&trade; is installed.</h3>
<input type=button value='Re-Install JW Player' onClick='installPackage("jwplayer.zip"); loadContent("/3rdParty/jwplayer.qsp");'><br>
<%
}
%>

<!--
<input type=button value='Test JW Player installation' onClick='alert("Testing JW Player");'><br>
-->
24 changes: 24 additions & 0 deletions mythtv/html/js/util.qjs
Expand Up @@ -44,6 +44,30 @@ function putSetting(hostname, key, value) {
return result;
}

function installPackage(packageName) {
var result = 0;

setStatusMessage("<i18n>Installing</i18n> " + packageName);

$.ajaxSetup({ async: false });
$.post("/Config/InstallPackage",
{ package: packageName },
function(data) {
if (data.Result == "true") {
result = 1;
}
});
$.ajaxSetup({ async: true });

if (result) {
setStatusMessage("<i18n>Package installed</i18n>");
} else {
setErrorMessage("<i18n>Unable to install package.</i18n>");
}

return result;
}

function loadDiv(divName, contentURL, jsURL) {
divName = "#" + divName;

Expand Down
5 changes: 5 additions & 0 deletions mythtv/html/menu.qsp
Expand Up @@ -78,6 +78,11 @@
</li>
</ul>
</li>
<li><a href='#'><i18n>3rd Party Software</i18n></a>
<ul class="acitem collapsible">
<li><a class='menuitem' href='#' onClick="javascript:loadContent('/3rdParty/jwplayer.qsp')"><i18n>JW Player&trade;</i18n></a></li>
</ul>
</li>
</ul>
<br>
<center><a class='menuitem' href='http://www.mythtv.org'>www.mythtv.org</a></center>
Expand Down
1 change: 1 addition & 0 deletions mythtv/libs/libmythbase/storagegroup.cpp
Expand Up @@ -69,6 +69,7 @@ void StorageGroup::StaticInit(void)
m_builtinGroups["Themes"] = GetConfDir() + "/themes";
m_builtinGroups["Temp"] = GetConfDir() + "/tmp";
m_builtinGroups["Streaming"] = GetConfDir() + "/tmp/hls";
m_builtinGroups["3rdParty"] = GetConfDir() + "/3rdParty";

QMap<QString, QString>::iterator it = m_builtinGroups.begin();
for (; it != m_builtinGroups.end(); ++it)
Expand Down
29 changes: 29 additions & 0 deletions mythtv/programs/mythbackend/httpconfig.cpp
Expand Up @@ -12,6 +12,8 @@
#include "mythdb.h"
#include "mythdirs.h"
#include "storagegroup.h"
#include "mythdownloadmanager.h"
#include "mythcoreutil.h"

HttpConfig::HttpConfig() : HttpServerExtension("HttpConfig", QString())
{
Expand Down Expand Up @@ -147,6 +149,33 @@ bool HttpConfig::ProcessRequest(HTTPRequest *request)
request->FormatFileResponse(fn);
return true;
}
else if ((request->m_sMethod == "InstallPackage") &&
(request->m_mapParams.contains("package")))
{
QString package = QUrl::fromPercentEncoding(request->m_mapParams["package"].toUtf8());
QString url = QString("http://www.mythtv.org/ftp/3rdParty/%1").arg(package);
StorageGroup tmpGroup("Temp", gCoreContext->GetHostName());
QString tmpFile = tmpGroup.GetFirstDir(true) + "package.zip";
StorageGroup destGroup("3rdParty", gCoreContext->GetHostName());
QString outDir = destGroup.GetFirstDir();

QString result = "false";
if ((GetMythDownloadManager()->download(url, tmpFile)) &&
(extractZIP(tmpFile, outDir)))
{
result = "true";
}

QTextStream os(&request->m_response);
os << StringListToJSON("Result", QStringList(result));

request->m_eResponseType = ResponseTypeOther;
request->m_sResponseTypeText = "application/json";
request->m_mapRespHeaders[ "Cache-Control" ] =
"no-cache=\"Ext\", max-age = 0";

return true;
}
else if ((request->m_sMethod == "FileBrowser") &&
(request->m_mapParams.contains("dir")))
{
Expand Down

0 comments on commit d41ef68

Please sign in to comment.