src/app/modules/player-helper/components/contentplayer-page/contentplayer-page.component.ts
OnInit
OnDestroy
OnChanges
selector | app-contentplayer-page |
styleUrls | ./contentplayer-page.component.scss |
templateUrl | ./contentplayer-page.component.html |
Properties |
Methods |
Inputs |
Outputs |
constructor(activatedRoute: ActivatedRoute, configService: ConfigService, router: Router, navigationHelperService: NavigationHelperService, toasterService: ToasterService, resourceService: ResourceService, utilService: UtilService, telemetryService: TelemetryService, layoutService: LayoutService, playerService: PublicPlayerService)
|
|||||||||||||||||||||||||||||||||
Parameters :
|
collectionData | |
Type : any
|
|
contentDetails | |
Type : any
|
|
contentProgressEvents$ | |
Type : Subject<any>
|
|
dialCode | |
Type : string
|
|
isContentPresent | |
Type : boolean
|
|
Default value : true
|
|
objectRollUp | |
Type : any
|
|
playerConfig | |
Type : any
|
|
tocPage | |
Type : boolean
|
|
Default value : false
|
|
assessmentEvents | |
Type : EventEmitter
|
|
contentDownloaded | |
Type : EventEmitter
|
|
deletedContent | |
Type : EventEmitter
|
|
questionScoreReviewEvents | |
Type : EventEmitter
|
|
questionScoreSubmitEvents | |
Type : EventEmitter
|
|
checkContentDeleted | ||||
checkContentDeleted(event)
|
||||
Parameters :
Returns :
void
|
checkContentDownloading | ||||
checkContentDownloading(event)
|
||||
Parameters :
Returns :
void
|
getContent |
getContent()
|
Returns :
void
|
getContentConfigDetails | ||||||
getContentConfigDetails(contentId, options)
|
||||||
Parameters :
Returns :
void
|
getContentIdFromRoute |
getContentIdFromRoute()
|
Returns :
void
|
goBack |
goBack()
|
Returns :
void
|
initLayout |
initLayout()
|
Returns :
void
|
logTelemetry | ||||
logTelemetry(id)
|
||||
Parameters :
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
|
setPageExitTelemtry |
setPageExitTelemtry()
|
Returns :
void
|
setTelemetryData |
setTelemetryData()
|
Returns :
void
|
contentId |
Type : string
|
contentType |
Type : string
|
isCollapsed |
Default value : false
|
isConnected |
isContentDeleted |
Type : Subject<any>
|
Default value : new Subject()
|
isDesktopApp |
Default value : false
|
layoutConfiguration |
Public layoutService |
Type : LayoutService
|
playerOption |
Type : any
|
Public resourceService |
Type : ResourceService
|
Public router |
Type : Router
|
telemetryImpression |
Type : IImpressionEventInput
|
Public toasterService |
Type : ToasterService
|
unsubscribe$ |
Default value : new Subject<void>()
|
import { Component, OnInit, OnDestroy, OnChanges, Input, EventEmitter, Output } from '@angular/core';
import { ActivatedRoute, Router, NavigationStart } from '@angular/router';
import {
ConfigService, NavigationHelperService, ToasterService, ResourceService,
UtilService, LayoutService
} from '@sunbird/shared';
import { Subject } from 'rxjs';
import { takeUntil, filter } from 'rxjs/operators';
import * as _ from 'lodash-es';
import { IImpressionEventInput, TelemetryService } from '@sunbird/telemetry';
import { PublicPlayerService } from '@sunbird/public';
@Component({
selector: 'app-contentplayer-page',
templateUrl: './contentplayer-page.component.html',
styleUrls: ['./contentplayer-page.component.scss']
})
export class ContentPlayerPageComponent implements OnInit, OnDestroy, OnChanges {
@Input() contentDetails;
@Input() collectionData;
@Input() playerConfig;
@Input() tocPage = false;
@Input() dialCode: string;
@Input() isContentPresent = true;
@Input() objectRollUp;
@Input() contentProgressEvents$: Subject<any>;
@Output() assessmentEvents = new EventEmitter<any>();
@Output() questionScoreSubmitEvents = new EventEmitter<any>();
@Output() questionScoreReviewEvents = new EventEmitter<any>();
@Output() contentDownloaded = new EventEmitter();
@Output() deletedContent = new EventEmitter();
isCollapsed = false;
unsubscribe$ = new Subject<void>();
contentId: string;
telemetryImpression: IImpressionEventInput;
contentType: string;
isConnected;
isContentDeleted: Subject<any> = new Subject();
playerOption: any;
layoutConfiguration;
isDesktopApp = false;
constructor(private activatedRoute: ActivatedRoute,
private configService: ConfigService,
public router: Router,
private navigationHelperService: NavigationHelperService,
public toasterService: ToasterService,
public resourceService: ResourceService,
private utilService: UtilService,
private telemetryService: TelemetryService,
public layoutService: LayoutService,
private playerService: PublicPlayerService
) { }
ngOnInit() {
this.isDesktopApp = this.utilService.isDesktopApp;
this.initLayout();
this.utilService.emitHideHeaderTabsEvent(true);
this.contentType = this.activatedRoute.snapshot.queryParams.contentType;
this.getContentIdFromRoute();
this.router.events
.pipe(filter((event) => event instanceof NavigationStart), takeUntil(this.unsubscribe$))
.subscribe(x => { if (!this.tocPage) { this.setPageExitTelemtry(); } });
this.playerOption = {
showContentRating: true
};
this.activatedRoute.params.subscribe((params) => {
if (_.get(this.activatedRoute, 'snapshot.queryParams.l1Parent') && !this.tocPage) {
this.objectRollUp = {
l1: _.get(this.activatedRoute, 'snapshot.queryParams.l1Parent')
};
}
});
if (this.contentProgressEvents$) {
this.contentProgressEvents$.subscribe(data => this.contentProgressEvents$.next(data));
}
}
initLayout() {
this.layoutConfiguration = this.layoutService.initlayoutConfig();
this.layoutService.switchableLayout().
pipe(takeUntil(this.unsubscribe$)).subscribe(layoutConfig => {
if (layoutConfig != null) {
this.layoutConfiguration = layoutConfig.layout;
}
});
}
ngOnChanges() {
if (this.contentDetails && this.tocPage) {
this.contentId = this.contentDetails.identifier;
this.getContent();
}
}
getContentIdFromRoute() {
this.activatedRoute.params.pipe(
takeUntil(this.unsubscribe$))
.subscribe(params => {
if (params.contentId) {
this.contentId = params.contentId;
this.getContent();
}
});
}
getContent() {
const options: any = { dialCode: this.dialCode };
if (this.isDesktopApp) {
const params = { params: this.configService.appConfig.PublicPlayer.contentApiQueryParams };
this.playerService.getContent(this.contentId, params)
.pipe(takeUntil(this.unsubscribe$))
.subscribe(response => {
this.contentDetails = _.get(response, 'result.content') || _.get(response, 'result.questionSet');
const status = !_.has(this.contentDetails, 'desktopAppMetadata.isAvailable') ? false :
!_.get(this.contentDetails, 'desktopAppMetadata.isAvailable');
this.isContentDeleted.next({value: status});
this.getContentConfigDetails(this.contentId, options);
this.setTelemetryData();
}, error => {
this.contentDetails = {};
this.isContentDeleted.next({value: true});
this.setTelemetryData();
});
}
}
getContentConfigDetails(contentId, options) {
const contentDetails = {
contentId: contentId,
contentData: this.contentDetails
};
this.playerConfig.context.objectRollup = this.objectRollUp;
}
checkContentDeleted(event) {
if (this.isDesktopApp && event) {
this.isContentDeleted.next({ value: true });
this.deletedContent.emit(this.contentDetails);
}
}
checkContentDownloading(event) {
this.isContentDeleted.next({ value: false });
this.contentDownloaded.emit(event);
}
goBack() {
this.logTelemetry('close-content-player');
this.navigationHelperService.goBack();
}
logTelemetry(id) {
const interactData = {
context: {
env: _.get(this.activatedRoute.snapshot.data.telemetry, 'env') || 'content',
cdata: []
},
edata: {
id: id,
type: 'click',
pageid: _.get(this.activatedRoute.snapshot.data.telemetry, 'pageid') || 'play-content',
}
};
this.telemetryService.interact(interactData);
}
setTelemetryData() {
let telemetryCdata;
if (this.dialCode) {
telemetryCdata = [{ 'type': 'DialCode', 'id': this.dialCode }];
}
this.telemetryImpression = {
context: {
env: this.activatedRoute.snapshot.data.telemetry.env,
cdata: telemetryCdata || []
},
edata: {
type: this.activatedRoute.snapshot.data.telemetry.type,
pageid: this.activatedRoute.snapshot.data.telemetry.pageid,
uri: this.router.url,
}
};
if (!this.tocPage) {
this.telemetryImpression.edata['subtype'] = this.activatedRoute.snapshot.data.telemetry.subtype;
this.telemetryImpression.edata['duration'] = this.navigationHelperService.getPageLoadTime();
}
if (this.contentDetails) {
this.telemetryImpression.object = {
id: this.contentDetails['identifier'],
type: this.contentType,
ver: `${this.contentDetails['pkgVersion']}` || '1.0',
rollup: this.objectRollUp
};
}
}
setPageExitTelemtry() {
if (this.contentDetails) {
this.telemetryImpression.object = {
id: this.contentDetails['identifier'],
type: this.contentDetails['contentType'],
ver: `${this.contentDetails['pkgVersion']}` || '1.0',
};
}
this.telemetryImpression.edata.subtype = 'pageexit';
this.telemetryImpression = Object.assign({}, this.telemetryImpression);
}
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();
this.utilService.emitHideHeaderTabsEvent(false);
}
}
<div *ngIf="tocPage" class="toc-content text-left" [appTelemetryImpression]="telemetryImpression">
<!-- <app-player class="content-player" [playerOption] ="playerOption" [playerConfig]="playerConfig"></app-player> -->
<app-content-player [playerConfig]="playerConfig" [contentData]="contentDetails" [isContentPresent]="true"
[isContentDeleted]="isContentDeleted" [contentProgressEvents$]="contentProgressEvents$"
(assessmentEvents)="onAssessmentEvents($event)"
(questionScoreSubmitEvents)="onQuestionScoreSubmitEvents($event)"
(questionScoreReviewEvents)="onQuestionScoreReviewEvents($event)" (deletedContent)="goBack()">
</app-content-player>
<div class="mt-8">
<app-credits-and-licence *ngIf="contentDetails" [contentData]="contentDetails"></app-credits-and-licence>
<mat-accordion *ngIf="collectionData" class="sb-mat-accordion mb-16">
<mat-expansion-panel>
<mat-expansion-panel-header>
<mat-panel-title class="sb-mat-accordion__title">
{{resourceService?.frmelmnts?.lbl?.collectionRelevantFor}}
</mat-panel-title>
</mat-expansion-panel-header>
<div class="sb-mat-accordion__content">
<div class="training-relevant__class mb-4 sb-color-gray-400 fnormal"
*ngIf="collectionData?.se_boards">
<span>{{resourceService?.frmelmnts?.lbl?.board | transposeTerms: 'frmelmnts.lbl.board' : resourceService?.selectedLang}}: </span><span>{{
collectionData.se_boards}}</span>
</div>
<div class="training-relevant__medium mb-4 sb-color-gray-400 fnormal"
*ngIf="collectionData?.se_mediums">
<span>{{resourceService?.frmelmnts?.lbl?.medium | transposeTerms: 'frmelmnts.lbl.medium' : resourceService?.selectedLang}}: </span><span>{{
collectionData?.se_mediums?.join(', ')}}</span>
</div>
<div class="training-relevant__subject mb-4 sb-color-gray-400 fnormal"
*ngIf="collectionData?.se_gradeLevels">
<span>{{resourceService?.frmelmnts?.lbl?.class | transposeTerms: 'frmelmnts.lbl.class' : resourceService?.selectedLang}}: </span><span>{{
collectionData.se_gradeLevels}}</span>
</div>
<div class="training-relevant__medium mb-4 sb-color-gray-400 fnormal"
*ngIf="collectionData?.audience">
<span>{{resourceService?.frmelmnts?.lbl?.userType}}: </span><span>{{
collectionData?.audience?.join(', ')}}</span>
</div>
</div>
</mat-expansion-panel>
</mat-accordion>
</div>
</div>
./contentplayer-page.component.scss
@use "@project-sunbird/sb-styles/assets/mixins/mixins" as *;
.sb-single-resource {
width: 100%;
height: 100%;
max-width: calculateRem(896px);
margin: 0 auto;
@include respond-above(lg) {
max-width: calculateRem(960px);
}
@include respond-above(xl) {
max-width: calculateRem(1024px);
}
@include respond-above(xxxl) {
max-width: calculateRem(1088px);
}
}
::ng-deep {
.toc-content {
width: 100%;
height: 100%;
app-credits-and-licence {
sb-accordion {
.sbaccordion__panel {
box-shadow: none;
}
}
}
}
}