Skip to content

Commit 26300df

Browse files
mister-benforbesjo
authored andcommitted
fix: ensure content loops (#259)
1 parent b8c4d4b commit 26300df

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

src/videojs-http-streaming.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,14 @@ class HlsHandler extends Component {
320320
this.masterPlaylistController_.smoothQualityChange_();
321321
}
322322
});
323+
324+
// Handle seeking when looping - middleware doesn't handle this seek event from the tech
325+
this.on(this.tech_, 'seeking', function() {
326+
if (this.tech_.seeking() && this.tech_.currentTime() === 0 && this.tech_.player_.loop()) {
327+
this.setCurrentTime(0);
328+
}
329+
});
330+
323331
this.on(this.tech_, 'error', function() {
324332
if (this.masterPlaylistController_) {
325333
this.masterPlaylistController_.pauseLoading();

test/playback.test.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,3 +165,26 @@ QUnit.test('Live DASH', function(assert) {
165165
type: 'application/dash+xml'
166166
});
167167
});
168+
169+
QUnit.test('loops', function(assert) {
170+
assert.timeout(5000);
171+
172+
let done = assert.async();
173+
let player = this.player;
174+
175+
player.loop(true);
176+
player.src({
177+
src: 'http://d2zihajmogu5jn.cloudfront.net/bipbop-advanced/bipbop_16x9_variant.m3u8',
178+
type: 'application/x-mpegURL'
179+
});
180+
player.one('playing', function() {
181+
player.vhs.mediaSource.one('sourceended', () => {
182+
player.vhs.mediaSource.on('sourceopen', () => {
183+
assert.ok(true, 'sourceopen triggered after ending stream');
184+
done();
185+
});
186+
});
187+
player.currentTime(player.duration());
188+
});
189+
player.play();
190+
});

0 commit comments

Comments
 (0)