src/app/modules/player-helper/components/content-player/content-player.component.ts
AfterViewInit
OnChanges
OnInit
OnDestroy
selector | app-content-player |
styleUrls | ./content-player.component.scss |
templateUrl | ./content-player.component.html |
Properties |
|
Methods |
Inputs |
Outputs |
constructor(router: Router, layoutService: LayoutService, navigationHelperService: NavigationHelperService, playerService: PublicPlayerService, resourceService: ResourceService, contentManagerService: ContentManagerService, utilService: UtilService)
|
||||||||||||||||||||||||
Parameters :
|
contentData | |
Type : any
|
|
contentProgressEvents$ | |
Type : Subject<any>
|
|
isContentDeleted | |
Type : Subject<any>
|
|
isContentPresent | |
Type : boolean
|
|
Default value : true
|
|
layoutConfiguration | |
Type : any
|
|
objectRollUp | |
Type : literal type
|
|
Default value : {}
|
|
playerConfig | |
Type : PlayerConfig
|
|
playerOption | |
Type : any
|
|
assessmentEvents | |
Type : EventEmitter
|
|
deletedContent | |
Type : EventEmitter
|
|
playerOnDestroyEvent | |
Type : EventEmitter
|
|
questionScoreReviewEvents | |
Type : EventEmitter
|
|
questionScoreSubmitEvents | |
Type : EventEmitter
|
|
sceneChangeEvent | |
Type : EventEmitter
|
|
checkContentDownloading | ||||
checkContentDownloading(event)
|
||||
Parameters :
Returns :
void
|
checkFullScreenView |
checkFullScreenView()
|
Returns :
void
|
deleteContent | ||||
deleteContent(event)
|
||||
Parameters :
Returns :
void
|
generateScoreSubmitEvent | ||||||
generateScoreSubmitEvent(event: any)
|
||||||
Parameters :
Returns :
void
|
initLayout |
initLayout()
|
Returns :
void
|
ngAfterViewInit |
ngAfterViewInit()
|
loadPlayer method will be called
Returns :
void
|
ngOnChanges |
ngOnChanges()
|
Returns :
void
|
ngOnDestroy |
ngOnDestroy()
|
Returns :
void
|
ngOnInit |
ngOnInit()
|
Returns :
void
|
onAssessmentEvents | ||||
onAssessmentEvents(event)
|
||||
Parameters :
Returns :
void
|
onQuestionScoreReviewEvents | ||||
onQuestionScoreReviewEvents(event)
|
||||
Parameters :
Returns :
void
|
onQuestionScoreSubmitEvents | ||||
onQuestionScoreSubmitEvents(event)
|
||||
Parameters :
Returns :
void
|
buildNumber |
Type : string
|
CONSTANT |
Type : object
|
Default value : {
ACCESSEVENT: 'renderer:question:submitscore',
ACCESSREVIEWEVENT: 'renderer:question:reviewAssessment'
}
|
contentDeleted |
Default value : false
|
contentIframe |
Type : ElementRef
|
Decorators :
@ViewChild('contentIframe')
|
contentRatingModal |
Default value : false
|
isCdnWorking |
Type : string
|
isConnected |
Type : any
|
isDesktopApp |
Type : Boolean
|
Default value : false
|
isFullScreenView |
isLoading |
Type : Boolean
|
Default value : false
|
Public layoutService |
Type : LayoutService
|
modal |
Decorators :
@ViewChild('modal')
|
Dom element reference of contentRatingModal |
Public navigationHelperService |
Type : NavigationHelperService
|
Public playerService |
Type : PublicPlayerService
|
previewCdnUrl |
Type : string
|
Public resourceService |
Type : ResourceService
|
Public router |
Type : Router
|
Public unsubscribe$ |
Default value : new Subject<void>()
|
Public utilService |
Type : UtilService
|
youTubeContentStatus |
Type : any
|
import { Component, AfterViewInit, ViewChild, ElementRef, Input, Output, EventEmitter, OnChanges, OnInit, OnDestroy } from '@angular/core';
import * as _ from 'lodash-es';
import { PlayerConfig, LayoutService, NavigationHelperService, ResourceService, UtilService } from '@sunbird/shared';
import { Router } from '@angular/router';
import { PublicPlayerService } from '@sunbird/public';
import { ContentManagerService } from '../../../public/module/offline/services';
const OFFLINE_ARTIFACT_MIME_TYPES = ['application/epub', 'video/webm', 'video/mp4', 'application/pdf'];
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
@Component({
selector: 'app-content-player',
templateUrl: './content-player.component.html',
styleUrls: ['./content-player.component.scss']
})
export class ContentPlayerComponent implements AfterViewInit, OnChanges, OnInit, OnDestroy {
@Input() playerConfig: PlayerConfig;
@Output() assessmentEvents = new EventEmitter<any>();
@Output() questionScoreSubmitEvents = new EventEmitter<any>();
@Output() questionScoreReviewEvents = new EventEmitter<any>();
@ViewChild('contentIframe') contentIframe: ElementRef;
@Output() playerOnDestroyEvent = new EventEmitter<any>();
@Output() sceneChangeEvent = new EventEmitter<any>();
@Input() contentProgressEvents$: Subject<any>;
@Output() deletedContent = new EventEmitter();
buildNumber: string;
@Input() playerOption: any;
contentRatingModal = false;
previewCdnUrl: string;
isCdnWorking: string;
@Input() isContentDeleted: Subject<any>;
contentDeleted = false;
@Input() isContentPresent = true;
@Input() objectRollUp: {} = {};
isConnected: any;
youTubeContentStatus: any;
public unsubscribe$ = new Subject<void>();
CONSTANT = {
ACCESSEVENT: 'renderer:question:submitscore',
ACCESSREVIEWEVENT: 'renderer:question:reviewAssessment'
};
/**
* Dom element reference of contentRatingModal
*/
@ViewChild('modal') modal;
@Input() contentData;
@Input() layoutConfiguration;
isFullScreenView;
isLoading: Boolean = false; // To restrict player loading multiple times
isDesktopApp: Boolean = false;
constructor(public router: Router, public layoutService: LayoutService, public navigationHelperService: NavigationHelperService,
public playerService: PublicPlayerService, public resourceService: ResourceService, private contentManagerService: ContentManagerService,
public utilService: UtilService) {
this.buildNumber = (<HTMLInputElement>document.getElementById('buildNumber'))
? (<HTMLInputElement>document.getElementById('buildNumber')).value : '1.0';
this.previewCdnUrl = (<HTMLInputElement>document.getElementById('previewCdnUrl'))
? (<HTMLInputElement>document.getElementById('previewCdnUrl')).value : undefined;
this.isCdnWorking = (<HTMLInputElement>document.getElementById('cdnWorking'))
? (<HTMLInputElement>document.getElementById('cdnWorking')).value : 'no';
}
/**
* loadPlayer method will be called
*/
ngAfterViewInit() {}
ngOnChanges() {
if (this.isDesktopApp && this.isContentDeleted) {
this.isContentDeleted.subscribe(data => {
this.contentDeleted = data.value && !this.router.url.includes('browse');
});
}
this.contentRatingModal = false;
if (!_.isEmpty(this.playerConfig)) {
this.objectRollUp = _.get(this.playerConfig, 'context.objectRollup') || {};
}
}
ngOnInit() {
this.isDesktopApp = this.utilService.isDesktopApp;
this.checkFullScreenView();
if (this.contentProgressEvents$) {
this.contentProgressEvents$.subscribe(data => {
this.contentProgressEvents$.next(data);
});
}
this.initLayout();
if (this.isDesktopApp) {
this.contentManagerService.deletedContent.pipe(takeUntil(this.unsubscribe$)).subscribe((data) => {
this.deleteContent(data);
});
}
}
deleteContent(event) {
if (!this.router.url.includes('mydownloads')) {
this.contentDeleted = true;
this.deletedContent.emit(event);
}
}
checkContentDownloading(event) {
if (this.isDesktopApp && !_.get(this.contentData, 'desktopAppMetadata.isAvailable')) {
this.contentDeleted = false;
const contentDetails = {
contentId: event.identifier,
contentData: event
};
this.contentData = event;
this.playerConfig = this.playerService.getConfig(contentDetails);
}
}
checkFullScreenView() {
this.navigationHelperService.contentFullScreenEvent.pipe(takeUntil(this.unsubscribe$)).subscribe(isFullScreen => {
this.isFullScreenView = isFullScreen;
});
}
initLayout() {
this.layoutConfiguration = this.layoutService.initlayoutConfig();
this.layoutService.switchableLayout().
pipe(takeUntil(this.unsubscribe$)).subscribe(layoutConfig => {
if (layoutConfig != null) {
this.layoutConfiguration = layoutConfig.layout;
}
});
}
generateScoreSubmitEvent(event: any) {
if (_.toLower(event.data) === (_.toLower(this.CONSTANT.ACCESSEVENT))) {
this.questionScoreSubmitEvents.emit(event);
}
if (event.data.toLowerCase() === (this.CONSTANT.ACCESSREVIEWEVENT).toLowerCase()) {
this.questionScoreReviewEvents.emit(event);
}
}
onAssessmentEvents(event) {
this.assessmentEvents.emit(event);
}
onQuestionScoreSubmitEvents(event) {
this.questionScoreSubmitEvents.emit(event);
}
onQuestionScoreReviewEvents(event) {
this.questionScoreReviewEvents.emit(event);
}
ngOnDestroy() {
this.unsubscribe$.next();
this.unsubscribe$.complete();
}
}
<div class="content-video">
<section class="" id="player-area-height">
<div class="aspectratio sbt-shadow-radius" data-ratio="16:9" id="help-video-aspect-ratio" #aspectRatio [ngClass]="{'player-fullscreen': isFullScreenView}">
<app-player class="content-player" [playerOption]="playerOption" [playerConfig]="playerConfig"
[contentProgressEvents$]="contentProgressEvents$" (assessmentEvents)="onAssessmentEvents($event)"
(questionScoreSubmitEvents)="onQuestionScoreSubmitEvents($event)" (questionScoreReviewEvents)="onQuestionScoreReviewEvents($event)"[isContentDeleted]="contentDeleted" ></app-player>
<app-content-actions [assessmentEvents]="assessmentEvents" *ngIf="isFullScreenView" class="player-fullscreen-action-items" [isFullScreen]="true" [contentData]="contentData" [objectRollUp]="objectRollUp">
</app-content-actions>
</div>
<app-content-actions [assessmentEvents]="assessmentEvents" *ngIf="contentData && !isFullScreenView" [isFullScreen]="false" (contentDownloaded)="checkContentDownloading($event)" [contentData]="contentData" [objectRollUp]="objectRollUp">
</app-content-actions>
</section>
</div>
./content-player.component.scss
@use "@project-sunbird/sb-styles/assets/mixins/mixins" as *;
@use 'components/video' as *;
.no-content-player{
background: var(--black);
color: var(--white);
width: 100%;
height: 100%;
&__text{
max-width: calculateRem(300px);
}
}