diff --git a/src/addons/mod/scorm/pages/player/player.html b/src/addons/mod/scorm/pages/player/player.html index 85093fb51..8040d010c 100644 --- a/src/addons/mod/scorm/pages/player/player.html +++ b/src/addons/mod/scorm/pages/player/player.html @@ -21,8 +21,8 @@ - +

{{ errorMessage | translate }}

diff --git a/src/addons/mod/scorm/pages/player/player.ts b/src/addons/mod/scorm/pages/player/player.ts index aaa42569a..f98f6547e 100644 --- a/src/addons/mod/scorm/pages/player/player.ts +++ b/src/addons/mod/scorm/pages/player/player.ts @@ -426,6 +426,11 @@ export class AddonModScormPlayerPage implements OnInit, OnDestroy { // eslint-disable-next-line @typescript-eslint/no-explicit-any ( window).API = this.dataModel; } else { + // Changing SCO. First unload the existing SCO to make sure the callback to send the data has been called. + this.src = ''; + + await CoreUtils.nextTick(); + // Load the SCO in the existing model. this.dataModel.loadSco(sco.id); } @@ -436,7 +441,7 @@ export class AddonModScormPlayerPage implements OnInit, OnDestroy { this.calculateNavigationItems(sco.id); // Load the SCO source. - this.loadScoSrc(sco); + this.src = await AddonModScorm.getScoSrc(this.scorm, sco); if (sco.scormtype == 'asset') { // Mark the asset as completed. @@ -446,25 +451,6 @@ export class AddonModScormPlayerPage implements OnInit, OnDestroy { this.logEvent(sco.id); } - /** - * Load SCO src. - * - * @param sco SCO to load. - * @returns Promise resolved when done. - */ - protected async loadScoSrc(sco: AddonModScormScoWithData): Promise { - const src = await AddonModScorm.getScoSrc(this.scorm, sco); - - if (src == this.src) { - // Re-loading same page. Set it to empty and then re-set the src in the next digest so it detects it has changed. - this.src = ''; - - await CoreUtils.nextTick(); - } - - this.src = src; - } - /** * Given an SCO, mark it as completed. * diff --git a/src/core/components/iframe/iframe.ts b/src/core/components/iframe/iframe.ts index bcccf96ac..ebfaa4126 100644 --- a/src/core/components/iframe/iframe.ts +++ b/src/core/components/iframe/iframe.ts @@ -160,10 +160,10 @@ export class CoreIframeComponent implements OnChanges, OnDestroy { return; } - let url = changes.src.currentValue; + let url = this.src; - if (!CoreUrlUtils.isLocalFileUrl(url)) { - url = CoreUrlUtils.getYoutubeEmbedUrl(changes.src.currentValue) || changes.src.currentValue; + if (url && !CoreUrlUtils.isLocalFileUrl(url)) { + url = CoreUrlUtils.getYoutubeEmbedUrl(url) || url; this.displayHelp = CoreIframeUtils.shouldDisplayHelpForUrl(url); const currentSite = CoreSites.getCurrentSite(); @@ -181,7 +181,7 @@ export class CoreIframeComponent implements OnChanges, OnDestroy { await CoreIframeUtils.fixIframeCookies(url); } - this.safeUrl = DomSanitizer.bypassSecurityTrustResourceUrl(CoreFile.convertFileSrc(url)); + this.safeUrl = DomSanitizer.bypassSecurityTrustResourceUrl(url ? CoreFile.convertFileSrc(url) : ''); // Now that the URL has been set, initialize the iframe. Wait for the iframe to the added to the DOM. setTimeout(() => {