added optional callback after subtitles have been loaded

This commit is contained in:
sanj 2010-07-18 02:02:20 +05:30
parent 44547e8dd7
commit 68fdb8a9b6

View File

@ -65,7 +65,7 @@
} }
} }
} }
opts.subtitlesLoaded(subtitles);
var currentSubtitle = -1; var currentSubtitle = -1;
var ival = setInterval(function() { var ival = setInterval(function() {
@ -80,7 +80,7 @@
} }
if(subtitle > 0) { if(subtitle > 0) {
if(subtitle != currentSubtitle) { if(subtitle != currentSubtitle) {
opts.showSubtitle(subtitles[subtitle].t, subtitleElement); opts.showSubtitle(subtitles[subtitle], subtitleElement);
// subtitleElement.html(subtitles[subtitle].t); // subtitleElement.html(subtitles[subtitle].t);
currentSubtitle=subtitle; currentSubtitle=subtitle;
} else if(subtitles[subtitle].o < currentTime) { } else if(subtitles[subtitle].o < currentTime) {
@ -91,10 +91,12 @@
}, opts.interval); }, opts.interval);
} }
function showSubtitle(txt, elem) { //default function to show subtitle
elem.html(txt); function showSubtitle(sub, elem) {
elem.html(sub.t);
} }
//default function to hide subtitle
function hideSubtitle(elem) { function hideSubtitle(elem) {
elem.html(''); elem.html('');
} }
@ -106,7 +108,8 @@
'id': that.attr('data-video'), 'id': that.attr('data-video'),
'url': that.attr('data-srt'), 'url': that.attr('data-srt'),
'showSubtitle': showSubtitle, 'showSubtitle': showSubtitle,
'hideSubtitle': hideSubtitle 'hideSubtitle': hideSubtitle,
'subtitlesLoaded': $.noop
}, o); }, o);
this.each(function() { this.each(function() {
var subtitleElement = $(this); var subtitleElement = $(this);