Merge pull request #18715 from edx/revert-ammar/EDUCATOR-2606-thumbnail-issue-with-hls

Revert "fix poster display issue with hls"
This commit is contained in:
Noraiz Anwar
2018-08-02 20:38:11 +05:00
committed by GitHub
4 changed files with 5 additions and 83 deletions

View File

@@ -20,40 +20,23 @@
function Player(el, config) {
var self = this;
this.config = config;
// do common initialization independent of player type
this.init(el, config);
_.bindAll(this, 'playVideo', 'onReady');
// If we have only HLS sources and browser doesn't support HLS then show error message.
if (config.HLSOnlySources && !config.canPlayHLS) {
this.showErrorMessage(null, '.video-hls-error');
return;
}
this.config.state.el.on('initialize', _.once(function() {
console.log('[HLS Video]: HLS Player initialized');
self.showPlayButton();
}));
// Safari has native support to play HLS videos
if (config.browserIsSafari) {
this.videoEl.attr('src', config.videoSources[0]);
} else {
this.hls = new HLS({autoStartLoad: false});
this.hls = new HLS();
this.hls.loadSource(config.videoSources[0]);
this.hls.attachMedia(this.video);
this.showLoadingOnce = _.once(function() {
HTML5Video.Player.prototype.updatePlayerLoadingState.apply(self, ['show']);
});
this.hideLoadingOnce = _.once(function() {
HTML5Video.Player.prototype.updatePlayerLoadingState.apply(self, ['hide']);
});
this.hls.on(HLS.Events.ERROR, this.onError.bind(this));
this.hls.on(HLS.Events.MANIFEST_PARSED, function(event, data) {
@@ -66,7 +49,6 @@
};
})
);
self.config.onReadyHLS();
});
this.hls.on(HLS.Events.LEVEL_SWITCHED, function(event, data) {
var level = self.hls.levels[data.level];
@@ -77,7 +59,6 @@
resolution: level.width + 'x' + level.height
}
);
self.hideLoadingOnce();
});
}
}
@@ -85,16 +66,6 @@
Player.prototype = Object.create(HTML5Video.Player.prototype);
Player.prototype.constructor = Player;
Player.prototype.playVideo = function() {
this.hls.startLoad();
this.video.play();
this.showLoadingOnce();
};
Player.prototype.onReady = function() {
this.config.events.onReady(null);
};
/**
* Handler for HLS video errors. This only takes care of fatal erros, non-fatal errors
* are automatically handled by hls.js

View File

@@ -95,38 +95,6 @@ function(_) {
this.videoEl.on('error', this.onError.bind(this));
}
Player.prototype.showPlayButton = function() {
this.videoOverlayEl.removeClass('is-hidden');
};
Player.prototype.hidePlayButton = function() {
this.videoOverlayEl.addClass('is-hidden');
};
Player.prototype.showLoading = function() {
this.el
.removeClass('is-initialized')
.find('.spinner')
.removeAttr('tabindex')
.attr({'aria-hidden': 'false'});
};
Player.prototype.hideLoading = function() {
this.el
.addClass('is-initialized')
.find('.spinner')
.attr({'aria-hidden': 'false', 'tabindex': -1});
};
Player.prototype.updatePlayerLoadingState = function(state) {
if (state === 'show') {
this.hidePlayButton();
this.showLoading();
} else if (state === 'hide') {
this.hideLoading();
}
};
Player.prototype.callStateChangeCallback = function() {
if ($.isFunction(this.config.events.onStateChange)) {
this.config.events.onStateChange({
@@ -243,15 +211,11 @@ function(_) {
this.videoEl.remove();
};
Player.prototype.onReady = function() {
this.config.events.onReady(null);
this.showPlayButton();
};
Player.prototype.onLoadedMetadata = function() {
this.playerState = HTML5Video.PlayerState.PAUSED;
if ($.isFunction(this.config.events.onReady)) {
this.onReady();
this.config.events.onReady(null);
this.videoOverlayEl.removeClass('is-hidden');
}
};
@@ -270,7 +234,7 @@ function(_) {
Player.prototype.onPause = function() {
this.playerState = HTML5Video.PlayerState.PAUSED;
this.callStateChangeCallback();
this.showPlayButton();
this.videoOverlayEl.removeClass('is-hidden');
};
Player.prototype.onEnded = function() {

View File

@@ -179,8 +179,6 @@ function(HTML5Video, HTML5HLSVideo, Resizer, HLS, _, Time) {
state.videoPlayer.player = new HTML5HLSVideo.Player(
state.el,
_.extend({}, commonPlayerConfig, {
state: state,
onReadyHLS: onReadyHLS,
videoSources: state.HLSVideoSources,
canPlayHLS: state.canPlayHLS,
HLSOnlySources: state.HLSOnlySources
@@ -561,10 +559,6 @@ function(HTML5Video, HTML5HLSVideo, Resizer, HLS, _, Time) {
this.el.trigger('qualitychange', arguments);
}
function onReadyHLS() {
dfd.resolve();
}
function onReady() {
var _this = this,
availablePlaybackRates, baseSpeedSubs,

View File

@@ -1142,7 +1142,7 @@ class HLSVideoTest(VideoBaseTest):
self.navigate_to_video()
self.video.click_player_button('play')
self.assertIn(self.video.state, ['buffering', 'playing'])
self.assertEqual(self.video.state, 'playing')
self.video.click_player_button('pause')
self.assertEqual(self.video.state, 'pause')
@@ -1231,7 +1231,6 @@ class HLSVideoTest(VideoBaseTest):
Given the course has a Video component with "HLS" video only
And I have defined a transcript for the video
Then I see the correct text in the captions for transcript
Then I play, pause and seek to 0:00
Then I click on a caption line
And video position should be updated accordingly
Then I change video position
@@ -1244,12 +1243,6 @@ class HLSVideoTest(VideoBaseTest):
self.assertIn("Hi, edX welcomes you0.", self.video.captions_text)
# This is required to load the video
self.video.click_player_button('play')
# Below 2 steps are required to test the caption line click scenario
self.video.click_player_button('pause')
self.video.seek('0:00')
for line_no in range(5):
self.video.click_transcript_line(line_no=line_no)
self.video.wait_for_position('0:0{}'.format(line_no))