Merge pull request #4286 from dpalou/MOBILE-4705
MOBILE-4705 mod_resource: Use VideoJS if needed in embedded mediamain
commit
7ed6583ebd
|
@ -35,7 +35,7 @@
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<div *ngIf="mode === 'embedded'" class="ion-padding">
|
<div *ngIf="mode === 'embedded'" class="ion-padding">
|
||||||
<core-format-text [text]="contentText" [filter]="false" />
|
<core-format-text [text]="contentText" contextLevel="module" [contextInstanceId]="module.id" [courseId]="courseId" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ng-container *ngIf="mode === 'external'">
|
<ng-container *ngIf="mode === 'external'">
|
||||||
|
|
|
@ -114,22 +114,22 @@ export class MediaElementController extends ElementController {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Start listening to events because the player could be created while we're searching for it, causing a race condition.
|
||||||
|
this.jsPlayerListener = CoreEvents.on(VIDEO_JS_PLAYER_CREATED, ({ element, player }) => {
|
||||||
|
if (element !== media) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.jsPlayerListener?.off();
|
||||||
|
this.jsPlayer.resolve(player);
|
||||||
|
});
|
||||||
|
|
||||||
const player = await this.searchJSPlayer();
|
const player = await this.searchJSPlayer();
|
||||||
|
|
||||||
if (!player) {
|
if (player && !this.jsPlayer.isSettled()) {
|
||||||
this.jsPlayerListener = CoreEvents.on(VIDEO_JS_PLAYER_CREATED, ({ element, player }) => {
|
this.jsPlayerListener?.off();
|
||||||
if (element !== media) {
|
this.jsPlayer.resolve(player);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.jsPlayerListener?.off();
|
|
||||||
this.jsPlayer.resolve(player);
|
|
||||||
});
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.jsPlayer.resolve(player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -27,6 +27,7 @@ import mimeToExt from '@/assets/mimetoext.json';
|
||||||
import { CoreFileEntry, CoreFileHelper } from '@services/file-helper';
|
import { CoreFileEntry, CoreFileHelper } from '@services/file-helper';
|
||||||
import { CoreUrl } from '@singletons/url';
|
import { CoreUrl } from '@singletons/url';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
|
import { CoreUtils } from '@singletons/utils';
|
||||||
|
|
||||||
interface MimeTypeInfo {
|
interface MimeTypeInfo {
|
||||||
type: string;
|
type: string;
|
||||||
|
@ -193,8 +194,10 @@ export class CoreMimetypeUtilsProvider {
|
||||||
return `<img src="${path}">`;
|
return `<img src="${path}">`;
|
||||||
case 'audio':
|
case 'audio':
|
||||||
case 'video':
|
case 'video':
|
||||||
|
// Add videoJS class and ID because the media could use the VideoJS player.
|
||||||
return [
|
return [
|
||||||
`<${embedType} controls title="${filename}" src="${path}" controlsList="nodownload">`,
|
`<${embedType} controls title="${filename}" src="${path}" controlsList="nodownload" class="video-js" ` +
|
||||||
|
`id="id_videojs_moodleapp_${CoreUtils.getUniqueId('CoreMimetypeUtils-embedded-media')}">`,
|
||||||
`<source src="${path}" type="${mimeType}">`,
|
`<source src="${path}" type="${mimeType}">`,
|
||||||
`</${embedType}>`,
|
`</${embedType}>`,
|
||||||
].join('');
|
].join('');
|
||||||
|
|
Loading…
Reference in New Issue