Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(player): fullscreen button now displayed where possible #860

Merged
merged 3 commits into from
Oct 24, 2020
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
1 change: 1 addition & 0 deletions examples/config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"disableFullscreen": false,
"fetchingDisabled": 0,
"uuid": "8de62c47-f335-42f6-909d-2d8f4b7fb7f5",
"siteType": "local",
Expand Down
1 change: 1 addition & 0 deletions src/H5PEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,7 @@ export default class H5PEditor {
libraryUrl: this.urlGenerator.coreFile('js'),
pluginCacheBuster: '', // TODO make dynamic
url: this.config.baseUrl,
fullscreenDisabled: this.config.disableFullscreen ? 1 : 0,
user: {
mail: '',
name: ''
Expand Down
19 changes: 16 additions & 3 deletions src/H5PPlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,25 @@ export default class H5PPlayer {
const libraries = await this.getMetadataRecursive(dependencies);
const assets = this.aggregateAssetsRecursive(dependencies, libraries);

const mainLibrarySupportsFullscreen = !metadata.mainLibrary
? false
: libraries[
LibraryName.toUberName(
metadata.preloadedDependencies.find(
(dep) => dep.machineName === metadata.mainLibrary
)
)
].fullscreen === 1;

const model: IPlayerModel = {
contentId,
downloadPath: this.getDownloadPath(contentId),
integration: this.generateIntegration(
contentId,
parameters,
metadata,
assets
assets,
mainLibrarySupportsFullscreen
),
scripts: this.listCoreScripts()
.concat(this.globalCustomScripts)
Expand Down Expand Up @@ -236,7 +247,8 @@ export default class H5PPlayer {
contentId: ContentId,
parameters: ContentParameters,
metadata: IContentMetadata,
assets: IAssets
assets: IAssets,
supportsFullscreen: boolean
): IIntegration {
// see https://h5p.org/creating-your-own-h5p-plugin
log.info(`generating integration for ${contentId}`);
Expand All @@ -251,7 +263,7 @@ export default class H5PPlayer {
frame: false,
icon: false
},
fullScreen: '0',
fullScreen: supportsFullscreen ? '1' : '0',
jsonContent: JSON.stringify(parameters),
library: ContentMetadata.toUbername(metadata),
contentUrl: this.config.contentFilesUrlPlayerOverride?.replace(
Expand Down Expand Up @@ -283,6 +295,7 @@ export default class H5PPlayer {
saveFreq: false,
url: this.config.baseUrl,
hubIsEnabled: true,
fullscreenDisabled: this.config.disableFullscreen ? 1 : 0,
...this.integrationObjectDefaults
};
}
Expand Down
3 changes: 3 additions & 0 deletions src/implementation/H5PConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default class H5PConfig implements IH5PConfig {
minor: 24
};
public coreUrl: string = '/core';
public disableFullscreen: boolean = false;
public downloadUrl: string = '/download';
public editorAddons?: {
[machineName: string]: string[];
Expand Down Expand Up @@ -76,6 +77,7 @@ export default class H5PConfig implements IH5PConfig {
await this.loadSettingFromStorage('contentWhitelist');
await this.loadSettingFromStorage('editorAddons');
await this.loadSettingFromStorage('enableLrsContentTypes');
await this.loadSettingFromStorage('disableFullscreen');
await this.loadSettingFromStorage('fetchingDisabled');
await this.loadSettingFromStorage('hubContentTypesEndpoint');
await this.loadSettingFromStorage('hubRegistrationEndpoint');
Expand All @@ -100,6 +102,7 @@ export default class H5PConfig implements IH5PConfig {
await this.saveSettingToStorage('contentWhitelist');
await this.saveSettingToStorage('editorAddons');
await this.saveSettingToStorage('enableLrsContentTypes');
await this.saveSettingToStorage('disableFullscreen');
await this.saveSettingToStorage('fetchingDisabled');
await this.saveSettingToStorage('hubContentTypesEndpoint');
await this.saveSettingToStorage('hubRegistrationEndpoint');
Expand Down
4 changes: 4 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1323,6 +1323,10 @@ export interface IH5PConfig {
* Path to the H5P core files directory.
*/
coreUrl: string;
/**
* If true, the fullscreen button will not be shown to the user.
*/
disableFullscreen: boolean;
/**
* Path to the downloadable H5P packages.
*/
Expand Down
6 changes: 4 additions & 2 deletions test/H5PPlayer.renderHtmlPage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ describe('Rendering the HTML page', () => {
"postUserStatistics": false,
"saveFreq": false,
"url": "/h5p",
"hubIsEnabled": true
"hubIsEnabled": true,
"fullscreenDisabled": 0
};
</script>
</head>
Expand Down Expand Up @@ -414,7 +415,8 @@ describe('Rendering the HTML page', () => {
"postUserStatistics": false,
"saveFreq": false,
"url": "/h5p",
"hubIsEnabled": true
"hubIsEnabled": true,
"fullscreenDisabled": 0
};
</script>
</head>
Expand Down