mirror of
https://github.com/shaka-project/shaka-player.git
synced 2026-06-14 15:56:38 +03:00
85e8990e0e
Some tests are generated with old tools that produce random errors in decoding, so it is best to disable it for now. Due https://github.com/shaka-project/shaka-player/issues/2746
125 lines
3.7 KiB
JavaScript
125 lines
3.7 KiB
JavaScript
/*! @license
|
|
* Shaka Player
|
|
* Copyright 2016 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
describe('DashParser', () => {
|
|
const Util = shaka.test.Util;
|
|
|
|
/** @type {!jasmine.Spy} */
|
|
let onErrorSpy;
|
|
|
|
/** @type {!HTMLVideoElement} */
|
|
let video;
|
|
/** @type {shaka.Player} */
|
|
let player;
|
|
/** @type {!shaka.util.EventManager} */
|
|
let eventManager;
|
|
|
|
let compiledShaka;
|
|
|
|
/** @type {!shaka.test.Waiter} */
|
|
let waiter;
|
|
|
|
beforeAll(async () => {
|
|
video = shaka.test.UiUtils.createVideoElement();
|
|
document.body.appendChild(video);
|
|
compiledShaka =
|
|
await shaka.test.Loader.loadShaka(getClientArg('uncompiled'));
|
|
});
|
|
|
|
beforeEach(async () => {
|
|
await shaka.test.TestScheme.createManifests(compiledShaka, '_compiled');
|
|
player = new compiledShaka.Player();
|
|
await player.attach(video);
|
|
|
|
// Disable stall detection, which can interfere with playback tests.
|
|
player.configure('streaming.stallEnabled', false);
|
|
|
|
// Grab event manager from the uncompiled library:
|
|
eventManager = new shaka.util.EventManager();
|
|
waiter = new shaka.test.Waiter(eventManager);
|
|
waiter.setPlayer(player);
|
|
|
|
onErrorSpy = jasmine.createSpy('onError');
|
|
onErrorSpy.and.callFake((event) => fail(event.detail));
|
|
eventManager.listen(player, 'error', Util.spyFunc(onErrorSpy));
|
|
});
|
|
|
|
afterEach(async () => {
|
|
eventManager.release();
|
|
await player.destroy();
|
|
});
|
|
|
|
afterAll(() => {
|
|
document.body.removeChild(video);
|
|
});
|
|
|
|
it('supports AES-128 streaming', async () => {
|
|
await player.load('/base/test/test/assets/dash-aes-128/dash.mpd');
|
|
await video.play();
|
|
expect(player.isLive()).toBe(false);
|
|
|
|
// Wait for the video to start playback. If it takes longer than 10
|
|
// seconds, fail the test.
|
|
await waiter.waitForMovementOrFailOnTimeout(video, 10);
|
|
|
|
// Play for 5 seconds, but stop early if the video ends. If it takes
|
|
// longer than 30 seconds, fail the test.
|
|
await waiter.waitUntilPlayheadReachesOrFailOnTimeout(video, 5, 30);
|
|
|
|
await player.unload();
|
|
});
|
|
|
|
it('supports ClearKey with raw single key', async () => {
|
|
if (!checkClearKeySupport()) {
|
|
pending('ClearKey is not supported');
|
|
}
|
|
|
|
player.configure({
|
|
drm: {
|
|
clearKeys: {
|
|
// cspell: disable-next-line
|
|
'nrQFDeRLSAKTLifXUIPiZg': 'FmY0xnWCPCNaSpRG-tUuTQ',
|
|
},
|
|
},
|
|
});
|
|
await player.load('/base/test/test/assets/dash-clearkey/dash.mpd');
|
|
await video.play();
|
|
expect(player.isLive()).toBe(false);
|
|
|
|
// Wait for the video to start playback. If it takes longer than 10
|
|
// seconds, fail the test.
|
|
await waiter.waitForMovementOrFailOnTimeout(video, 10);
|
|
|
|
// Play for 8 seconds, but stop early if the video ends. If it takes
|
|
// longer than 30 seconds, fail the test.
|
|
await waiter.waitUntilPlayheadReachesOrFailOnTimeout(video, 8, 30);
|
|
|
|
await player.unload();
|
|
});
|
|
|
|
it('support multi type variants', async () => {
|
|
const DeviceType = shaka.device.IDevice.DeviceType;
|
|
if (deviceDetected.getDeviceType() === DeviceType.TV &&
|
|
deviceDetected.getDeviceName() === 'Tizen') {
|
|
pending('Disabled on Tizen.');
|
|
}
|
|
const BrowserEngine = shaka.device.IDevice.BrowserEngine;
|
|
if (deviceDetected.getBrowserEngine() === BrowserEngine.WEBKIT) {
|
|
pending('Disabled on Safari.');
|
|
}
|
|
if (!await Util.isTypeSupported('video/webm; codecs="vp9"')) {
|
|
pending('Codec VP9 is not supported by the platform.');
|
|
}
|
|
await player.load('/base/test/test/assets/dash-multitype-variant/dash.mpd');
|
|
await video.play();
|
|
expect(player.isLive()).toBe(false);
|
|
|
|
await waiter.timeoutAfter(30).waitForEnd(video);
|
|
|
|
await player.unload();
|
|
});
|
|
});
|