Skip to content

Commit

Permalink
Fix resolution menu restoration
Browse files Browse the repository at this point in the history
If the resolution menu sees audio-only content, it should be hidden.
But it should come back as soon as the audio-video content is seen.

This came up during work on #997 and #382

Change-Id: I3297847c905c867bcdd14cf7e525a408890a273a
  • Loading branch information
joeyparrish committed Apr 30, 2019
1 parent 831dfa6 commit 56a48ec
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 5 deletions.
23 changes: 20 additions & 3 deletions test/test/util/test_scheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,20 @@ shaka.test.TestScheme.DATA = {
// 'sintel_short_periods' : Generated by createManifests().
// 'sintel_multi_lingual_multi_res' : Generated by createManifests().

'sintel_audio_only': {
audio: {
initSegmentUri: '/base/test/test/assets/sintel-audio-init.mp4',
mdhdOffset: 0x1b6,
segmentUri: '/base/test/test/assets/sintel-audio-segment.mp4',
tfdtOffset: 0x3c,
segmentDuration: 10.005,
presentationTimeOffset: 0,
mimeType: 'audio/mp4',
codecs: 'mp4a.40.2',
},
duration: 30,
},

'sintel_no_text': {
video: {
initSegmentUri: '/base/test/test/assets/sintel-video-init.mp4',
Expand Down Expand Up @@ -463,9 +477,12 @@ shaka.test.TestScheme.createManifests = function(shaka, suffix) {
let gen = new windowShaka.test.ManifestGenerator(shaka)
.setPresentationDuration(data.duration)
.addPeriod(/* startTime= */ 0)
.addVariant(0)
.addVideo(1);
addStreamInfo(gen, data, ContentType.VIDEO, name);
.addVariant(0);

if (data[ContentType.VIDEO]) {
gen.addVideo(1);
addStreamInfo(gen, data, ContentType.VIDEO, name);
}
if (data[ContentType.AUDIO]) {
gen.addAudio(2);
addStreamInfo(gen, data, ContentType.AUDIO, name);
Expand Down
16 changes: 15 additions & 1 deletion test/ui/ui_integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,6 @@ describe('UI', () => {

updateResolutionButtonsAndMap();


oldResolutionTrack = findTrackWithHeight(tracks, oldResolution);
});

Expand Down Expand Up @@ -435,6 +434,21 @@ describe('UI', () => {
expect(isChosen).not.toBe(null);
});

it('restores the resolutions menu after audio-only playback', async () => {
/** @type {HTMLElement} */
const resolutionButton = getElementByClassName(
'shaka-resolution-button', videoContainer);

// Load an audio-only clip. The menu should be hidden.
await player.load('test:sintel_audio_only_compiled');
expect(player.isAudioOnly()).toBe(true);
expect(resolutionButton.classList.contains('shaka-hidden')).toBe(true);

// Load an audio-video clip. The menu should be visible again.
await player.load('test:sintel_multi_lingual_multi_res_compiled');
expect(player.isAudioOnly()).toBe(false);
expect(resolutionButton.classList.contains('shaka-hidden')).toBe(false);
});

/**
* @return {Element}
Expand Down
7 changes: 6 additions & 1 deletion ui/resolution_selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,17 @@ shaka.ui.ResolutionSelection = class extends shaka.ui.Element {
/** @private */
updateResolutionSelection_() {
let tracks = this.player.getVariantTracks();
// Hide resolution menu and button for audio-only content.

// Hide resolution menu and button for audio-only content and src= content
// without resolution information.
if (tracks.length && !tracks[0].height) {
shaka.ui.Utils.setDisplay(this.resolutionMenu_, false);
shaka.ui.Utils.setDisplay(this.resolutionButton_, false);
return;
}
// Otherwise, restore it.
shaka.ui.Utils.setDisplay(this.resolutionButton_, true);

tracks.sort(function(t1, t2) {
return t1.height - t2.height;
});
Expand Down

0 comments on commit 56a48ec

Please sign in to comment.