Browse Source

Use starting bandwidth of 500 kilobits per second for Android

pull/1160/head
Garrett Singer 8 years ago
parent
commit
f9ed2a4664
  1. 7
      src/videojs-contrib-hls.js
  2. 36
      test/videojs-contrib-hls.test.js

7
src/videojs-contrib-hls.js

@ -281,10 +281,11 @@ class HlsHandler extends Component {
}
// start playlist selection at a reasonable bandwidth for
// broadband internet
// 0.5 MB/s
// broadband internet (0.5 MB/s) or mobile (0.0625 MB/s)
if (typeof this.options_.bandwidth !== 'number') {
this.options_.bandwidth = 4194304;
// only use Android for mobile because iOS does not support MSE (and uses
// native HLS)
this.options_.bandwidth = videojs.browser.IS_ANDROID ? 500000 : 4194304;
}
// grab options passed to player.src

36
test/videojs-contrib-hls.test.js

@ -1585,6 +1585,42 @@ QUnit.test('uses default bandwidth option if non-numerical value provided', func
assert.equal(this.player.tech_.hls.bandwidth, 4194304, 'set bandwidth to default');
});
QUnit.test('uses mobile default bandwidth if browser is Android', function(assert) {
this.player.dispose();
const origIsAndroid = videojs.browser.IS_ANDROID;
videojs.browser.IS_ANDROID = false;
this.player = createPlayer();
this.player.src({
src: 'http://example.com/media.m3u8',
type: 'application/vnd.apple.mpegurl'
});
openMediaSource(this.player, this.clock);
assert.equal(this.player.tech_.hls.bandwidth,
4194304,
'set bandwidth to desktop default');
this.player.dispose();
videojs.browser.IS_ANDROID = true;
this.player = createPlayer();
this.player.src({
src: 'http://example.com/media.m3u8',
type: 'application/vnd.apple.mpegurl'
});
openMediaSource(this.player, this.clock);
assert.equal(this.player.tech_.hls.bandwidth,
500000,
'set bandwidth to mobile default');
videojs.browser.IS_ANDROID = origIsAndroid;
});
QUnit.test('does not break if the playlist has no segments', function(assert) {
this.player.src({
src: 'manifest/master.m3u8',

Loading…
Cancel
Save