Skip to content

Commit

Permalink
changed manifests and info page
Browse files Browse the repository at this point in the history
  • Loading branch information
guancio committed Oct 13, 2013
1 parent ff979d7 commit 17c8702
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 35 deletions.
2 changes: 1 addition & 1 deletion hostedapp/manifest_git.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Subtitle Videoplayer Hosted",
"version": "1.4.0",
"version": "1.5.0",
"manifest_version": 2,
"icons": {
"16": "camera.png",
Expand Down
28 changes: 19 additions & 9 deletions src/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,16 +202,26 @@ MediaElementPlayer.prototype.buildsubdelay = function(player, controls, layers,
$.extend(MediaElementPlayer.prototype, {
buildinfo: function(player, controls, layers, media) {
var
t = this,
info = $(
t = this;
var infoText =
'<div class="me-window" style="color:#fff;margin: auto;position: absolute;top: 0; left: 0; bottom: 0; right: 0;width:650px;display: table; height: auto;background: url(background.png);background: rgba(50,50,50,0.7);border: solid 1px transparent;padding: 10px;overflow: hidden;-webkit-border-radius: 0;-moz-border-radius: 0;border-radius: 0;font-size: 16px;visibility: hidden;"><img src="icon.png" style="width:80px;height: auto;"/>'+
'<h2>Subtitle Videoplayer v1.4.0</h2>' +
'A small Chrome video player that supports external subtitles. Plase visit our project <a href="https://github.com/guancio/ChromeOsSubtitle">home page</a>.<br><br>'+
'This software is possible thanks to several open source projects:<ul>'+
'<li>The main madia player component is a fork of <a id="link_mediaelement" href="http://mediaelementjs.com/">MediaelEment.js</a>, developed by John Dyer</li>'+
'<li>Zip files are opened using <a href="http://gildas-lormeau.github.io/zip.js/" target="_blank">zip.js</a></li>' +
'<li>Subtitles service powered by <a href="http://www.OpenSubtitles.org" target="_blank">www.OpenSubtitles.org</a>. More uploaded subs means more subs available. Please opload <a href="http://www.opensubtitles.org/upload" target="_blank">here</a> jour subs.<br/><a href="http://www.OpenSubtitles.org" target="_blank"><img src="opensubtitle.gif"/></a></li>'+
'</ul>[Click the box to close the info window]</div>'
'<h2>Subtitle Videoplayer v1.5.0</h2>' +
'A small Chrome video player that supports external subtitles. Plase visit our project <a href="https://github.com/guancio/ChromeOsSubtitle">home page</a>.<br><br>';
if (!packaged_app) {
infoText = infoText +
'Plase install the <a href="https://chrome.google.com/webstore/detail/subtitle-videoplayer/naikohapihpbhficdpbddmgbhiccijca?hl=en-GB" target="_blank">packaged app</a> version of this application, that also integrate with opensubtitles.org<br><br>';
}

infoText = infoText +
'This software is possible thanks to several open source projects:<ul>'+
'<li>The main madia player component is a fork of <a id="link_mediaelement" href="http://mediaelementjs.com/">MediaelEment.js</a>, developed by John Dyer</li>'+
'<li>Zip files are opened using <a href="http://gildas-lormeau.github.io/zip.js/" target="_blank">zip.js</a></li>';
if (packaged_app) {
infoText = infoText + '<li>Subtitles service powered by <a href="http://www.OpenSubtitles.org" target="_blank">www.OpenSubtitles.org</a>. More uploaded subs means more subs available. Please opload <a href="http://www.opensubtitles.org/upload" target="_blank">here</a> jour subs.<br/><a href="http://www.OpenSubtitles.org" target="_blank"><img src="opensubtitle.gif"/></a></li>';
}
infoText = infoText + '</ul>[Click the box to close the info window]</div>'

var info = $(infoText
).appendTo(controls[0].parentElement);

info.find("a").click(function (e) {
Expand Down
67 changes: 53 additions & 14 deletions src/js/opensubtitle.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,36 @@ var openSubsLang = [
player.setTrack(lang);
});

$('<div><div class="opensubtitleBanner" style="width: 100%;color: white; background: rgba(20, 20, 20, 0.8); text-align:center; font-size: 16px; padding-top:20px; padding-bottom:20px; z-index:999; position:absolute; cursor: pointer;visibility:hidden;">Click here to download subtitles from OpenSubtitles.org</div></div>')
.appendTo(layers);
player.opensubtitleBanner = $('.opensubtitleBanner');


function info(text) {
$('#label_opensubtitle')[0].textContent=text;
};
function infoBanner(text) {
player.opensubtitleBanner[0].textContent=text;
};
function infoBoth(text) {
info(text);
infoBanner(text);
};

function openSubtitle(content, sub) {
info("5/6 Opening...");
infoBoth("5/6 Opening...");
var blob = b64toBlob(content, "text/plain");
zip.createReader(new zip.BlobReader(blob),function(reader) {
reader.gunzip(new zip.BlobWriter(), function(data){
info(sub.SubFileName);
infoBanner(sub.SubFileName + ' downloaded');
t.subtitleBannerTimer = setTimeout(function() {
player.opensubtitleBanner.css('visibility','hidden');
clearTimeout(t.subtitleBannerTimer);
delete t.subtitleBannerTimer;
t.subtitleBannerTimer = null;
}, 2000);


if (t.opensubtitleService.lastSubtitles.length > 1) {
$('#select_opensubtitle').css('visibility','inherit');
Expand Down Expand Up @@ -156,13 +175,13 @@ var openSubsLang = [
}

function downloadSubtitle(sub) {
info("4/6 Downloading...");
infoBoth("4/6 Downloading...");
service.DownloadSubtitles({
params: [t.opensubtitleService.token, [
sub.IDSubtitleFile
]],
onException:function(errorObj){
info("Download failed...");
infoBoth("Download failed...");
},
onComplete:function(responseObj){
var content = responseObj.result.data[0].data;
Expand All @@ -175,7 +194,7 @@ var openSubsLang = [
var lang = "eng";
lang = $('#select_opensubtitle_lang')[0].value;
// var lang = "ell";
info("3/6 Searching...");
infoBoth("3/6 Searching...");
service.SearchSubtitles({
params: [t.opensubtitleService.token, [
{query: t.openedFile.name,
Expand All @@ -185,7 +204,7 @@ var openSubsLang = [
sublanguageid: lang}
], {limit:100}],
onException:function(errorObj){
info("Search failed");
infoBoth("Search failed");
},
onComplete:function(responseObj){
// Check that at leat a subtitle has been found
Expand Down Expand Up @@ -219,18 +238,18 @@ var openSubsLang = [
};

function movieHash() {
info("2/6 Hashing...");
infoBoth("2/6 Hashing...");
OpenSubtitlesHash(t.openedFile, function(hash){
searchSubtitle(hash);
});
};

function logIn() {
info("1/6 Authenticating...");
infoBoth("1/6 Authenticating...");
service.LogIn({
params: ["", "", "", "ChromeSubtitleVideoplayer"],
onException:function(errorObj){
info("Authentiation failed");
infoBoth("Authentiation failed");
},
onComplete:function(responseObj){
t.opensubtitleService.token = responseObj.result.token;
Expand All @@ -239,20 +258,46 @@ var openSubsLang = [
});
};

player.opensubtitleBanner.click(function(e) {
e.preventDefault();
e.stopPropagation();
logIn();
return false;
});

$('#opensubtitle_button').click(function (e) {
$('#label_opensubtitle').css('visibility','inherit');
$('#select_opensubtitle').css('visibility','hidden');
t.subtitleBannerTimer = setTimeout(function() {
clearTimeout(t.subtitleBannerTimer);
delete t.subtitleBannerTimer;
t.subtitleBannerTimer = null;
}, 10000);

logIn();
});

// on load a new video
media.addEventListener('loadeddata',function() {
t.captionsButton
.find('input[value=opensubtitle]')
.prop('disabled',true);
info("No subtitle");
infoBanner("Click here to download subtitles from OpenSubtitles.org");
$('#label_opensubtitle').css('visibility','inherit');
$('#select_opensubtitle').css('visibility','hidden');
t.opensubtitleService.lastSubtitles = [];
var defaultValue = selectDefault.value;
$('#select_opensubtitle_lang').val(defaultValue);

player.opensubtitleBanner.css('visibility','inherit');

t.subtitleBannerTimer = setTimeout(function() {
player.opensubtitleBanner.css('visibility','hidden');
clearTimeout(t.subtitleBannerTimer);
delete t.subtitleBannerTimer;
t.subtitleBannerTimer = null;
}, 10000);
});


Expand Down Expand Up @@ -280,12 +325,6 @@ var openSubsLang = [
});
});

// on load a new video
media.addEventListener('loadeddata',function() {
var defaultValue = selectDefault.value;
$('#select_opensubtitle_lang').val(defaultValue);
});

}
});
})(mejs.$);
Expand Down
10 changes: 0 additions & 10 deletions src/js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,6 @@
'[Click outside the box to close the settings]</div>'
).appendTo(controls[0].parentElement);

// var settingsList = $('#settings_list')[0];
// $('<li/>')
// .appendTo(settingsList)
// .append($('<label style="width:250px; float:left;">Default subtitle font size</label>'))
// .append($('<input style="width:100px"/>'));
// $('<li/>')
// .appendTo(settingsList)
// .append($('<label style="width:250px; float:left;">Default opensubtitle.org language</label>'))
// .append($('<select style="width:100px"><option>English</option></select>'));

function hide(e) {
settingsPanel.css('visibility','hidden');
if (player.media.paused)
Expand Down
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Subtitle Videoplayer",
"version": "1.4.0",
"version": "1.5.0",
"manifest_version": 2,
"minimum_chrome_version": "28",
"icons": {
Expand Down

0 comments on commit 17c8702

Please sign in to comment.