npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ngx-cvbsp-player

v1.12.9

Published

Player to read content, plugin can be created easily and added (see config).

Downloads

19

Readme

NgxCvbspPlayer

Player to read content, plugin can be created easily and added (see config).

A persistence layer can be added to the module (see config)

installation

npm i ngx-cvbsp-player

WARNING : you must do this two things for the html editor to work :

  • in Angular.json, you must set buildOptimizer to false for prod mode "buildOptimizer": false,

  • in tsconfig.json, you must set enableIvy to false for prod mode

"angularCompilerOptions": {
  ...
    "enableIvy": false
}

config

in your app module :

const configNgxPlayer = {
  debug: true,
  componentsToRegistered: [
    { className: 'NewPluginComponent', typeOf: NewPluginComponent} as ComponentRegistration
  ], 
  persistor : service as IPersistor
} as PlayerConfig;
...
imports: [
    ...
    NgxCvbspPlayerModule.forRoot(configNgxPlayer)
    ...
],
entryComponents: [ 
    ...
    NewPluginComponent
    ...
]

in lazy loaded module :

imports: [
    NgxCvbspPlayerModule
]

use

in your html file

.testclass {
    background-color: yellow
}

<ngx-cvbsp-player (closeEvent)="close()" [block]="block" [class]="'testclass'"></ngx-cvbsp-player>

in your ts file

export class CvbspPlayerPage implements OnInit {
  block: Block;
  constructor(
    public player: NgxCvbspPlayerService,
    public persistor: NgxCvbspPersistorService) {
    this.block = {
      _id: 'test',
      classType: 'block1',
      resume: false,
      blocksOrContents : [
        { _id: '1-1', classType: 'Content', data: { htmlContent : '<p>content 1 of block 1</p>'}, component: 'RichTextComponent' } as Content,
        {
          _id: 'block2',
          classType: 'Block',
          blocksOrContents : [
            {
              _id: 'block3',
              classType: 'Block',
              blocksOrContents : [
                { _id: '1-3', classType: 'Content', data: { htmlContent : '<p>content 1 of block 3</p>'}, component: 'RichTextComponent' } as Content,
                { _id: '2-3', classType: 'Content', data: { htmlContent : '<p>content 2 of block 3</p>'}, component: 'RichTextComponent' } as Content,
                { _id: '3-3', classType: 'Content', data: { htmlContent : '<p>content 3 of block 3</p>'}, component: 'RichTextComponent' } as Content
              ]
            } as Block,
            { _id: '1-2', classType: 'Content', data: { htmlContent : '<p>content 1 of block 2</p>'}, component: 'RichTextComponent' } as Content,
            { _id: '2-2', classType: 'Content', data: { htmlContent : '<p>content 2 of block 2</p>'}, component: 'RichTextComponent' } as Content,
            { _id: '3-2', classType: 'Content', data: { htmlContent : '<p>content 3 of block 2</p>'}, component: 'RichTextComponent' } as Content
          ]
        } as Block,
        { _id: '2-1', classType: 'Content', data: { htmlContent : '<p>content 3 of block 1</p>'}, component: 'RichTextComponent' } as Content,
        { _id: '3-1', classType: 'Content', data: { htmlContent : '<p>content 4 of block 1</p>'}, component: 'RichTextComponent' } as Content
      ]
    } as Block;
  }

  ngOnInit() {
      // get the block from a server for example or from scorm api or anything else
  }

  close() {
    // leave the page
  }

}

create plugin

you can create plugin in your app by just creating a component, this component must implement the ContentComponent interface that you will find in the lib. here is an exemple :

export class NewPluginComponent implements OnInit, ContentComponent {
  @Input() data: any;
  @Input() tracking: Tracking;
  @Output() nextEvent: EventEmitter<Tracking> = new EventEmitter<Tracking>();
  constructor(public sanitizer: DomSanitizer) { }

  ngOnInit() {

  }

  next() {
    // TO DO update tracking before 
    this.nextEvent.next(this.tracking);
  }

}

then you add the component in the config of the player IMPORTANT the component MUST be added to the entryComponents of your module !

create persistor

you can create persistor to be able to store and retrieve the tracking related to the session of a user. this persistor MUST implement the IPersistor interface. here is a very simple example of a persistor to store the data in localStorage. It is also the default persistor if nothing is set up.

export class LocalPersistorService implements IPersistor {
  storage: Storage;

  constructor() {
    this.storage = window.localStorage;
  }

  open(): void {
    console.log('ngx-cvbsp-player opened');
  }

  read(blockId: string, resume: boolean): Observable<Tracking> {
    if (!resume) {
      return of(null);
    }
    return of(JSON.parse(this.storage.getItem('ngx-cvbsp-player-' + blockId)));
  }

  save(tracking: Tracking) {
    this.storage.setItem('ngx-cvbsp-player-' + tracking.blockId , JSON.stringify(tracking) );
  }

  close(): void {
    console.log('ngx-cvbsp-player closed');
  }
}

safe html parser

add javascript in your html with the following tag {{ }} to access variable use the scope '$' accessor the scope accessor is different on each block/content as it has to be set at block level exemple for a scope with a firstname property :

<span> coucou , {{ $.firstname }} , comment vas tu ? </span>

export doc and pdf viewer

in order for the export doc component to work for viewing pdf, the following must be install in the assets of the project : https://github.com/teambition/pdfviewer.git

follow instruction to build and put the output of the build in the following location : /assets/plugins/pdf-viewer