added showSubtitle and hideSubtitle as optional callbacks to opts

This commit is contained in:
sanj 2010-06-05 04:21:48 +05:30
parent e038b5440d
commit 44547e8dd7

View File

@ -80,21 +80,33 @@
}
if(subtitle > 0) {
if(subtitle != currentSubtitle) {
subtitleElement.html(subtitles[subtitle].t);
opts.showSubtitle(subtitles[subtitle].t, subtitleElement);
// subtitleElement.html(subtitles[subtitle].t);
currentSubtitle=subtitle;
} else if(subtitles[subtitle].o < currentTime) {
subtitleElement.html('');
opts.hideSubtitle(subtitleElement);
// subtitleElement.html('');
}
}
}, opts.interval);
}
function showSubtitle(txt, elem) {
elem.html(txt);
}
function hideSubtitle(elem) {
elem.html('');
}
jQuery.fn.srt = function(o) {
var that = this;
var opts = $.extend({
'interval': 100,
'id': that.attr('data-video'),
'url': that.attr('data-srt')
'url': that.attr('data-srt'),
'showSubtitle': showSubtitle,
'hideSubtitle': hideSubtitle
}, o);
this.each(function() {
var subtitleElement = $(this);