Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/streaming/MediaManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ function MediaManager() {
}

altPlayer.play();
logger.info('Alternative content playback started');
logger.info(`Alternative content playback started for player ${playerId}`);

isSwitching = false;
}
Expand Down
55 changes: 51 additions & 4 deletions test/unit/test/streaming/streaming.MediaManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ describe('MediaManager', function () {
let debugMock;

beforeEach(function () {
// Setup mocks
videoModelMock = new VideoModelMock();
playbackControllerMock = new PlaybackControllerMock();
debugMock = new DebugMock();

// Configure MediaManager
mediaManager.setConfig({
videoModel: videoModelMock,
playbackController: playbackControllerMock,
Expand Down Expand Up @@ -44,15 +42,64 @@ describe('MediaManager', function () {
});
});

describe('prebufferAlternativeContent', function () {
it('should start prebuffering alternative content and log the action', function () {
const testUrl = 'http://test.mpd';
const testPlayerId = 'testPlayer';

mediaManager.prebufferAlternativeContent(testPlayerId, testUrl);

expect(debugMock.log.info).to.equal(`Starting prebuffering for player ${testPlayerId}`);
});
});

describe('switchToAlternativeContent', function () {
beforeEach(function () {
const mockVideoElement = videoModelMock.getElement();
mediaManager.setAlternativeVideoElement(mockVideoElement);
});

it('should switch to alternative content without prebuffered content', function () {
const testUrl = 'http://test.mpd';
const testPlayerId = 'testPlayer';

mediaManager.switchToAlternativeContent(testPlayerId, testUrl);

expect(debugMock.log.info).to.equal(`Alternative content playback started for player ${testPlayerId}`);
});

it('should switch to alternative content with prebuffered content', function () {
const testUrl = 'http://test.mpd';
const testPlayerId = 'testPlayer';

mediaManager.prebufferAlternativeContent(testPlayerId, testUrl);
expect(debugMock.log.info).to.equal(`Starting prebuffering for player ${testPlayerId}`);

mediaManager.switchToAlternativeContent(testPlayerId, testUrl);
expect(debugMock.log.info).to.equal(`Alternative content playback started for player ${testPlayerId}`);
});

it('should switch to alternative content and seek to a given time', function () {
const testUrl = 'http://test.mpd';
const testPlayerId = 'testPlayer';
const testTime = 15;

mediaManager.switchToAlternativeContent(testPlayerId, testUrl, testTime);

expect(debugMock.log.debug).to.equal(`Seeking alternative content to time: ${testTime}`);
expect(debugMock.log.info).to.equal(`Alternative content playback started for player ${testPlayerId}`);
});
});

describe('getAlternativePlayer', function () {
beforeEach(function () {
const mockVideoElement = videoModelMock.getElement();
mediaManager.setAlternativeVideoElement(mockVideoElement);
});

it('should return undefined when no alternative player is set', function () {
it('should return null when no alternative player is set', function () {
const result = mediaManager.getAlternativePlayer();
expect(result).to.be.undefined;
expect(result).to.be.null;
});

it('should return the alternative player when it is set', function () {
Expand Down