MOBILE-4420 scorm: Unload current SCO before loading next one
parent
cbfc866af4
commit
1f05729cb0
|
@ -21,8 +21,8 @@
|
|||
</ion-header>
|
||||
<ion-content>
|
||||
<core-loading [hideUntil]="loaded">
|
||||
<core-iframe *ngIf="loaded && src" [src]="src" [iframeWidth]="scormWidth" [iframeHeight]="scormHeight"
|
||||
[showFullscreenOnToolbar]="true" [autoFullscreenOnRotate]="true">
|
||||
<core-iframe *ngIf="loaded" [src]="src" [iframeWidth]="scormWidth" [iframeHeight]="scormHeight" [showFullscreenOnToolbar]="true"
|
||||
[autoFullscreenOnRotate]="true">
|
||||
</core-iframe>
|
||||
|
||||
<p *ngIf="!src && errorMessage">{{ errorMessage | translate }}</p>
|
||||
|
|
|
@ -426,6 +426,11 @@ export class AddonModScormPlayerPage implements OnInit, OnDestroy {
|
|||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
(<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<void> {
|
||||
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.
|
||||
*
|
||||
|
|
|
@ -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(() => {
|
||||
|
|
Loading…
Reference in New Issue