2a09d1a4
liuqimichale
添加宜春 天水 宣化
|
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
|
import document from 'global/document';
import window from 'global/window';
import QUnit from 'qunit';
import sinon from 'sinon';
import videojs from 'video.js';
import FlashMediaSource from '../src/flash-media-source';
import HtmlMediaSource from '../src/html-media-source';
// we disable this because browserify needs to include these files
// but the exports are not important
/* eslint-disable no-unused-vars */
import {MediaSource, URL} from '../src/videojs-contrib-media-sources.js';
/* eslint-disable no-unused-vars */
QUnit.module('createObjectURL', {
beforeEach() {
this.fixture = document.getElementById('qunit-fixture');
this.video = document.createElement('video');
this.fixture.appendChild(this.video);
this.player = videojs(this.video);
// Mock the environment's timers because certain things - particularly
// player readiness - are asynchronous in video.js 5.
this.clock = sinon.useFakeTimers();
this.oldMediaSource = window.MediaSource || window.WebKitMediaSource;
// force MediaSource support
if (!window.MediaSource) {
window.MediaSource = function() {
let result = new window.Blob();
result.addEventListener = function() {};
result.addSourceBuffer = function() {};
return result;
};
}
},
afterEach() {
// The clock _must_ be restored before disposing the player; otherwise,
// certain timeout listeners that happen inside video.js may throw errors.
this.clock.restore();
this.player.dispose();
window.MediaSource = window.WebKitMediaSource = this.oldMediaSource;
}
});
QUnit.test('delegates to the native implementation', function() {
QUnit.ok(!(/blob:vjs-media-source\//).test(
videojs.URL.createObjectURL(
new window.Blob())
),
'created a native blob URL'
);
});
QUnit.test('uses the native MediaSource when available', function() {
QUnit.ok(!(/blob:vjs-media-source\//).test(
videojs.URL.createObjectURL(
new HtmlMediaSource())
),
'created a native blob URL'
);
});
QUnit.test('emulates a URL for the shim', function() {
QUnit.ok((/blob:vjs-media-source\//).test(
videojs.URL.createObjectURL(
new FlashMediaSource())
),
'created an emulated blob URL'
);
});
QUnit.test('stores the associated blob URL on the media source', function() {
let blob = new window.Blob();
let url = videojs.URL.createObjectURL(blob);
QUnit.equal(blob.url_, url, 'captured the generated URL');
});
|