fix subtitle selection in player menu

This commit is contained in:
j 2016-03-05 16:10:24 +05:30
parent 07ec93179c
commit ab21bdbe25
2 changed files with 13 additions and 10 deletions

View file

@ -2110,7 +2110,7 @@ Ox.VideoPlayer = function(options, self) {
self.options.enableDownload
? [{}, {id: 'download', title: Ox._('Download')}]
: []
)
)
})
.addClass('OxControls OxSettings')
.bindEvent({
@ -2128,6 +2128,7 @@ Ox.VideoPlayer = function(options, self) {
} else if (data.group == 'subtitlesTrack') {
self.options.subtitlesTrack = data.id == 'None'
? '' : data.id;
self.options.enableSubtitles = !!self.options.subtitlesTrack;
setSubtitlesTrack();
} else if (data.group == 'timeline') {
type = self.options.timelineTypes[
@ -2343,23 +2344,20 @@ Ox.VideoPlayer = function(options, self) {
}
function setSubtitlesTrack() {
var enableSubtitles = self.options.enableSubtitles && !!self.options.subtitlesTrack,
toggleSubtitles = enableSubtitles != self.options.enableSubtitles;
var enableSubtitles = self.options.enableSubtitles && !!self.options.subtitlesTrack;
self.options.enableSubtitles = enableSubtitles;
setSubtitle();
self.$timeline && self.$timeline.options({
subtitles: getSubtitles()
});
if (toggleSubtitles) {
self.options.enableSubtitles = enableSubtitles;
that.triggerEvent('subtitles', {
subtitles: self.options.enableSubtitles
});
}
if (enableSubtitles) {
if (enableSubtitles && !!self.options.subtitlesTrack) {
that.triggerEvent('subtitlestrack', {
track: self.options.subtitlesTrack
});
} else {
that.triggerEvent('subtitles', {
subtitles: self.options.enableSubtitles
});
}
}

View file

@ -292,6 +292,11 @@ Ox.VideoPlayerPanel = function(options, self) {
that.triggerEvent('subtitles', data);
},
subtitlestrack: function(data) {
var enableSubtitles = !!data.track;
if (enableSubtitles != self.options.enableSubtitles) {
self.options.enableSubtitles = enableSubtitles;
that.triggerEvent('subtitles', {subtitles: enableSubtitles});
}
self.options.subtitlesTrack = data.track;
self.$timeline.options({subtitles: getSubtitles()});
},