File

src/app/modules/player-helper/components/content-player/content-player.component.ts

Implements

AfterViewInit OnChanges OnInit OnDestroy

Metadata

Index

Properties
Methods
Inputs
Outputs

Constructor

constructor(router: Router, layoutService: LayoutService, navigationHelperService: NavigationHelperService, playerService: PublicPlayerService, resourceService: ResourceService, contentManagerService: ContentManagerService, utilService: UtilService)
Parameters :
Name Type Optional
router Router No
layoutService LayoutService No
navigationHelperService NavigationHelperService No
playerService PublicPlayerService No
resourceService ResourceService No
contentManagerService ContentManagerService No
utilService UtilService No

Inputs

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

Outputs

assessmentEvents
Type : EventEmitter
deletedContent
Type : EventEmitter
playerOnDestroyEvent
Type : EventEmitter
questionScoreReviewEvents
Type : EventEmitter
questionScoreSubmitEvents
Type : EventEmitter
sceneChangeEvent
Type : EventEmitter

Methods

checkContentDownloading
checkContentDownloading(event)
Parameters :
Name Optional
event No
Returns : void
checkFullScreenView
checkFullScreenView()
Returns : void
deleteContent
deleteContent(event)
Parameters :
Name Optional
event No
Returns : void
generateScoreSubmitEvent
generateScoreSubmitEvent(event: any)
Parameters :
Name Type Optional
event any No
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 :
Name Optional
event No
Returns : void
onQuestionScoreReviewEvents
onQuestionScoreReviewEvents(event)
Parameters :
Name Optional
event No
Returns : void
onQuestionScoreSubmitEvents
onQuestionScoreSubmitEvents(event)
Parameters :
Name Optional
event No
Returns : void

Properties

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);   
    }
}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""