From 8257341d137963b1d7e342b5d39f8cf047db3831 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Mon, 3 Sep 2018 08:44:36 +0200 Subject: [PATCH] MOBILE-2567 ios: Fix download of streamed media --- src/core/course/providers/helper.ts | 4 ++++ src/providers/file-helper.ts | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/core/course/providers/helper.ts b/src/core/course/providers/helper.ts index b9797a732..eb3f239b5 100644 --- a/src/core/course/providers/helper.ts +++ b/src/core/course/providers/helper.ts @@ -539,6 +539,10 @@ export class CoreCourseHelperProvider { return this.downloadModuleWithMainFileIfNeeded(module, courseId, component, componentId, files, siteId) .then((result) => { if (result.path.indexOf('http') === 0) { + /* In iOS, if we use the same URL in embedded browser and background download then the download only + downloads a few bytes (cached ones). Add a hash to the URL so both URLs are different. */ + result.path = result.path + '#moodlemobile-embedded'; + return this.utils.openOnlineFile(result.path).catch((error) => { // Error opening the file, some apps don't allow opening online files. if (!this.fileProvider.isAvailable()) { diff --git a/src/providers/file-helper.ts b/src/providers/file-helper.ts index 4bd5d3f37..79c76d1fc 100644 --- a/src/providers/file-helper.ts +++ b/src/providers/file-helper.ts @@ -56,6 +56,10 @@ export class CoreFileHelperProvider { } if (url.indexOf('http') === 0) { + /* In iOS, if we use the same URL in embedded browser and background download then the download only + downloads a few bytes (cached ones). Add a hash to the URL so both URLs are different. */ + url = url + '#moodlemobile-embedded'; + return this.utils.openOnlineFile(url).catch((error) => { // Error opening the file, some apps don't allow opening online files. if (!this.fileProvider.isAvailable()) {