-
Notifications
You must be signed in to change notification settings - Fork 414
/
playback.test.js
145 lines (110 loc) · 3.29 KB
/
playback.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import QUnit from 'qunit';
import videojs from 'video.js';
/* eslint-disable no-unused-vars */
import '../src/videojs-http-streaming';
let when = function(element, type, cb, condition) {
element.on(type, function func() {
if (condition()) {
element.off(type, func);
cb();
}
});
};
let playFor = function(player, time, cb) {
let targetTime = player.currentTime() + time;
when(player, 'timeupdate', cb, () => player.currentTime() >= targetTime);
};
QUnit.module('Playback', {
before() {
this.fixture = document.createElement('div');
document.body.appendChild(this.fixture);
},
beforeEach(assert) {
let done = assert.async();
let video = document.createElement('video');
video.width = 600;
video.height = 300;
this.fixture.appendChild(video);
this.player = videojs(video, { muted: true });
this.player.ready(done);
},
afterEach() {
this.player.dispose();
}
});
QUnit.test('Advanced Bip Bop', function(assert) {
let done = assert.async();
assert.expect(2);
let player = this.player;
player.autoplay(true);
playFor(player, 2, function() {
assert.ok(true, 'played for at least two seconds');
assert.equal(player.error(), null, 'has no player errors');
done();
});
player.src({
src: 'http://d2zihajmogu5jn.cloudfront.net/bipbop-advanced/bipbop_16x9_variant.m3u8',
type: 'application/x-mpegURL'
});
});
QUnit.skip('playlist with fmp4 and ts segments', function(assert) {
let done = assert.async();
assert.expect(2);
let player = this.player;
player.autoplay(true);
playFor(player, 6, function() {
assert.ok(true, 'played for at least six seconds to hit the change in container format');
assert.equal(player.error(), null, 'has no player errors');
done();
});
player.src({
src: 'https://d2zihajmogu5jn.cloudfront.net/ts-fmp4/index.m3u8',
type: 'application/x-mpegURL'
});
});
QUnit.test('Advanced Bip Bop preload=none', function(assert) {
let done = assert.async();
assert.expect(2);
let player = this.player;
player.autoplay(true);
player.preload('none');
playFor(player, 2, function() {
assert.ok(true, 'played for at least two seconds');
assert.equal(player.error(), null, 'has no player errors');
done();
});
player.src({
src: 'http://d2zihajmogu5jn.cloudfront.net/bipbop-advanced/bipbop_16x9_variant.m3u8',
type: 'application/x-mpegURL'
});
});
QUnit.test('Big Buck Bunny', function(assert) {
let done = assert.async();
assert.expect(2);
let player = this.player;
player.autoplay(true);
playFor(player, 2, function() {
assert.ok(true, 'played for at least two seconds');
assert.equal(player.error(), null, 'has no player errors');
done();
});
player.src({
src: 'https://dash.akamaized.net/akamai/bbb_30fps/bbb_30fps.mpd',
type: 'application/dash+xml'
});
});
QUnit.test('Live DASH', function(assert) {
let done = assert.async();
assert.expect(2);
let player = this.player;
player.autoplay(true);
playFor(player, 2, function() {
assert.ok(true, 'played for at least two seconds');
assert.equal(player.error(), null, 'has no player errors');
done();
});
player.src({
src: 'https://vm2.dashif.org/livesim/mup_30/testpic_2s/Manifest.mpd',
type: 'application/dash+xml'
});
});