Merge pull request #2943 from dpalou/MOBILE-3844

MOBILE-3844 media: Hide download option in audio and video
main
Pau Ferrer Ocaña 2021-09-13 13:22:27 +02:00 committed by GitHub
commit a143fbc61b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 4 deletions

View File

@ -32,7 +32,7 @@
<ion-item *ngIf="shouldEmbed"> <ion-item *ngIf="shouldEmbed">
<ion-label> <ion-label>
<img *ngIf="isImage" [alt]="name" [src]="url"> <img *ngIf="isImage" [alt]="name" [src]="url">
<video *ngIf="isVideo" [title]="name" controls> <video *ngIf="isVideo" [title]="name" controls controlsList="nodownload">
<source [src]="url" [type]="mimetype"> <source [src]="url" [type]="mimetype">
</video> </video>
<audio *ngIf="isAudio" [title]="name" controls> <audio *ngIf="isAudio" [title]="name" controls>

View File

@ -678,6 +678,18 @@ export class CoreFormatTextDirective implements OnChanges {
this.addMediaAdaptClass(element); this.addMediaAdaptClass(element);
this.addExternalContent(element); this.addExternalContent(element);
// Hide download button if not hidden already.
let controlsList = element.getAttribute('controlsList') || '';
if (!controlsList.includes('nodownload')) {
if (!controlsList.trim()) {
controlsList = 'nodownload';
} else {
controlsList = controlsList.split(' ').concat('nodownload').join(' ');
}
element.setAttribute('controlsList', controlsList);
}
const sources = Array.from(element.querySelectorAll('source')); const sources = Array.from(element.querySelectorAll('source'));
const tracks = Array.from(element.querySelectorAll('track')); const tracks = Array.from(element.querySelectorAll('track'));

View File

@ -15,7 +15,9 @@
<video *ngIf="!isAudio" [hidden]="hasCaptured" class="core-webcam-stream" autoplay #streamVideo></video> <video *ngIf="!isAudio" [hidden]="hasCaptured" class="core-webcam-stream" autoplay #streamVideo></video>
<!-- For video recording, use 2 videos and show/hide them because a CSS rule caused problems with the controls. --> <!-- For video recording, use 2 videos and show/hide them because a CSS rule caused problems with the controls. -->
<video *ngIf="isVideo" [hidden]="!hasCaptured" class="core-webcam-video-captured" controls #previewVideo></video> <video *ngIf="isVideo" [hidden]="!hasCaptured" class="core-webcam-video-captured" controls #previewVideo
controlsList="nodownload">
</video>
<!-- Canvas to treat the image and an img to show the result. --> <!-- Canvas to treat the image and an img to show the result. -->
<canvas *ngIf="isImage" class="core-webcam-image-canvas" #imgCanvas></canvas> <canvas *ngIf="isImage" class="core-webcam-image-canvas" #imgCanvas></canvas>
@ -35,7 +37,7 @@
</ion-button> </ion-button>
<!-- Audio player to listen to the result. --> <!-- Audio player to listen to the result. -->
<audio [hidden]="!hasCaptured" class="core-audio-captured" controls #previewAudio></audio> <audio [hidden]="!hasCaptured" class="core-audio-captured" controls #previewAudio controlsList="nodownload"></audio>
</div> </div>
</div> </div>
</core-loading> </core-loading>

View File

@ -191,7 +191,7 @@ export class CoreMimetypeUtilsProvider {
case 'audio': case 'audio':
case 'video': case 'video':
return [ return [
`<${embedType} controls title="${filename}" src="${path}">`, `<${embedType} controls title="${filename}" src="${path}" controlsList="nodownload">`,
`<source src="${path}" type="${mimeType}">`, `<source src="${path}" type="${mimeType}">`,
`</${embedType}>`, `</${embedType}>`,
].join(''); ].join('');