Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

We now have language changes in the dropdown meaningfully changing su…

…bs in the streamer.
  • Loading branch information...
commit bddaccf1c94cbfb8f83a6353b6157920b0965dce 1 parent 05b9043
@aduston aduston authored
View
12 media/js/streamer/streambox.js
@@ -87,8 +87,18 @@ unisubs.streamer.StreamBox.prototype.setSubtitles = function(subtitles) {
'id': 'usub-a-' + s['subtitle_id'] },
s['text']);
});
- goog.dom.append(this.transcriptElem_, subSpans);
+ goog.dom.removeChildren(this.transcriptElem_);
+ var elems = [];
+ for (var i = 0; i < subSpans.length; i++) {
+ elems.push(subSpans[i]);
+ if (i < subSpans.length - 1) {
+ elems.push(goog.dom.createTextNode(" "));
+ }
+ }
+ goog.dom.append(this.transcriptElem_, elems);
this.makeSubsAndSubMap_(subSpans);
+ this.streamBoxSearch_.setTranscriptElemAndSubs(
+ this.transcriptElem_, this.subs_);
};
unisubs.streamer.StreamBox.prototype.enterDocument = function() {
View
6 media/js/streamer/streamerdecorator.js
@@ -50,6 +50,12 @@ unisubs.streamer.StreamerDecorator.makeStreamer_ = function(videoPlayer) {
streamBox,
unisubs.streamer.StreamSub.SUB_CLICKED,
subClicked);
+ goog.events.listen(
+ controller,
+ unisubs.widget.PlayController.LANGUAGE_CHANGED,
+ function(e) {
+ streamBox.setSubtitles(e.target.getSubtitlesJSON());
+ });
unisubs.Rpc.call(
'show_widget', args,
goog.bind(controller.initializeState, controller));
View
14 media/js/widget/playcontroller.js
@@ -25,7 +25,7 @@ goog.provide('unisubs.widget.PlayController');
unisubs.widget.PlayController = function(
videoID, videoSource, videoPlayer, videoTab, dropDown, opt_subtitleState)
{
- goog.Disposable.call(this);
+ goog.events.EventTarget.call(this);
this.videoID_ = videoID;
this.videoSource_ = videoSource;
this.videoPlayer_ = videoPlayer;
@@ -52,7 +52,9 @@ unisubs.widget.PlayController = function(
this.nudgeShown_ = false;
this.trackedURLs_ = new goog.structs.Set();
};
-goog.inherits(unisubs.widget.PlayController, goog.Disposable);
+goog.inherits(unisubs.widget.PlayController, goog.events.EventTarget);
+
+unisubs.widget.PlayController.LANGUAGE_CHANGED = 'languagechanged';
unisubs.widget.PlayController.prototype.setSubtitleController =
function(subController)
@@ -97,6 +99,7 @@ unisubs.widget.PlayController.prototype.setUpSubs_ =
this.nudgeShown_ = false;
this.disposeComponents_();
this.subtitleState_ = subtitleState;
+ this.subtitlesJSON_ = subtitleState.SUBTITLES;
var captionSet = new unisubs.subtitle.EditableCaptionSet(
subtitleState.SUBTITLES);
this.subMap_ = captionSet.makeMap();
@@ -120,6 +123,10 @@ unisubs.widget.PlayController.prototype.setUpSubs_ =
this.trackPlay_();
};
+unisubs.widget.PlayController.prototype.getSubtitlesJSON = function() {
+ return this.subtitlesJSON_;
+};
+
unisubs.widget.PlayController.prototype.getSubMap = function() {
return this.subMap_;
};
@@ -154,6 +161,7 @@ unisubs.widget.PlayController.prototype.languageSelected = function(videoLanguag
that.videoTab_.showContent(
that.dropDown_.hasSubtitles(), subState);
that.dropDown_.setCurrentSubtitleState(subState);
+ that.dispatchEvent(unisubs.widget.PlayController.LANGUAGE_CHANGED);
});
};
@@ -196,4 +204,4 @@ unisubs.widget.PlayController.prototype.disposeComponents_ = function() {
unisubs.widget.PlayController.prototype.disposeInternal = function() {
unisubs.widget.PlayController.superClass_.disposeInternal.call(this);
this.disposeComponents_();
-};
+};
View
3  media/js/widget/widgetcontroller.js
@@ -23,12 +23,14 @@ goog.provide('unisubs.widget.WidgetController');
*
*/
unisubs.widget.WidgetController = function(videoURL, videoPlayer, videoTab) {
+ goog.events.EventTarget.call(this);
// TODO: when all VideoSource implementations support getVideoURL,
// remove videoURL from the parameters for this constructor.
this.videoURL_ = videoURL;
this.videoPlayer_ = videoPlayer;
this.videoTab_ = videoTab;
};
+goog.inherits(unisubs.widget.WidgetController, goog.events.EventTarget);
/**
* Widget calls this when show_widget rpc call returns.
@@ -88,6 +90,7 @@ unisubs.widget.WidgetController.prototype.initializeStateImpl_ = function(result
this.playController_ = new unisubs.widget.PlayController(
videoID, this.videoPlayer_.getVideoSource(), this.videoPlayer_,
this.videoTab_, popupMenu, subtitleState);
+ this.playController_.setParentEventTarget(this);
var videoPlayer = this.videoPlayer_;
var captionDisplayStrategy = this.captionDisplayStrategy_ ||
View
1  settings.py
@@ -219,7 +219,6 @@ def rel(*x):
'js/startdialog/tolanguage.js',
'js/startdialog/tolanguages.js',
'js/startdialog/dialog.js',
- 'js/streamer/streamercontroller.js',
'js/streamer/streambox.js',
'js/streamer/streamboxsearch.js',
'js/streamer/streamsub.js',
Please sign in to comment.
Something went wrong with that request. Please try again.