Skip to content

Commit

Permalink
fix: ensure content loops (#259)
Browse files Browse the repository at this point in the history
  • Loading branch information
mister-ben authored and forbesjo committed Oct 15, 2018
1 parent b8c4d4b commit 26300df
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/videojs-http-streaming.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,14 @@ class HlsHandler extends Component {
this.masterPlaylistController_.smoothQualityChange_();
}
});

// Handle seeking when looping - middleware doesn't handle this seek event from the tech
this.on(this.tech_, 'seeking', function() {
if (this.tech_.seeking() && this.tech_.currentTime() === 0 && this.tech_.player_.loop()) {
this.setCurrentTime(0);
}
});

this.on(this.tech_, 'error', function() {
if (this.masterPlaylistController_) {
this.masterPlaylistController_.pauseLoading();
Expand Down
23 changes: 23 additions & 0 deletions test/playback.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,26 @@ QUnit.test('Live DASH', function(assert) {
type: 'application/dash+xml'
});
});

QUnit.test('loops', function(assert) {
assert.timeout(5000);

let done = assert.async();
let player = this.player;

player.loop(true);
player.src({
src: 'http://d2zihajmogu5jn.cloudfront.net/bipbop-advanced/bipbop_16x9_variant.m3u8',
type: 'application/x-mpegURL'
});
player.one('playing', function() {
player.vhs.mediaSource.one('sourceended', () => {
player.vhs.mediaSource.on('sourceopen', () => {
assert.ok(true, 'sourceopen triggered after ending stream');
done();
});
});
player.currentTime(player.duration());
});
player.play();
});

0 comments on commit 26300df

Please sign in to comment.