MOBILE-4705 mod_resource: Use VideoJS if needed in embedded media
parent
070fbc5cd1
commit
a95e65ead0
|
@ -35,7 +35,7 @@
|
|||
</ng-container>
|
||||
|
||||
<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>
|
||||
|
||||
<ng-container *ngIf="mode === 'external'">
|
||||
|
|
|
@ -114,9 +114,7 @@ export class MediaElementController extends ElementController {
|
|||
return;
|
||||
}
|
||||
|
||||
const player = await this.searchJSPlayer();
|
||||
|
||||
if (!player) {
|
||||
// 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;
|
||||
|
@ -126,11 +124,13 @@ export class MediaElementController extends ElementController {
|
|||
this.jsPlayer.resolve(player);
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
const player = await this.searchJSPlayer();
|
||||
|
||||
if (player && !this.jsPlayer.isSettled()) {
|
||||
this.jsPlayerListener?.off();
|
||||
this.jsPlayer.resolve(player);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Start listening playback events.
|
||||
|
|
|
@ -27,6 +27,7 @@ import mimeToExt from '@/assets/mimetoext.json';
|
|||
import { CoreFileEntry, CoreFileHelper } from '@services/file-helper';
|
||||
import { CoreUrl } from '@singletons/url';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreUtils } from '@singletons/utils';
|
||||
|
||||
interface MimeTypeInfo {
|
||||
type: string;
|
||||
|
@ -193,8 +194,10 @@ export class CoreMimetypeUtilsProvider {
|
|||
return `<img src="${path}">`;
|
||||
case 'audio':
|
||||
case 'video':
|
||||
// Add videoJS class and ID because the media could use the VideoJS player.
|
||||
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}">`,
|
||||
`</${embedType}>`,
|
||||
].join('');
|
||||
|
|
Loading…
Reference in New Issue