16.0.0 • Published 9 months ago

ngx-lite-vid v16.0.0

Weekly downloads
-
License
-
Repository
-
Last release
9 months ago

ngx-lite-video

ngx-lite-video is an Angular package that provides lazy loading capabilities for embedded iframes from popular video sharing platforms like YouTube and Vimeo. The package is designed to optimize the loading of embedded videos, improving page load times and reducing data usage.

The package is built specifically for Angular, utilizing Angular's onpush change detection strategy for efficient rendering and updating of video components. It also includes features such as customizable lazy loading thresholds and options for controlling video playback and display.

This package requires a minimum of Angular version 13 and rxjs version 7.2 to function properly.

Try it yourself by measuring the performance on Demo page

Key Features

  • Lazy loads embedded iframes for YouTube and Vimeo videos
  • Built specifically for Angular
  • Uses Angular OnPush change detection for optimized performance
  • Customizable options including video quality, start time, and more
  • Provides a seamless user experience by loading videos only when needed

Install

npm install ngx-lite-video --save

Once installed, import the module that you wish to use in your desired module

@NgModule({
  //...
  imports: [
    //...
    NgxLiteVimeoModule, // Vimeo lite module
    NgxLiteYoutubeModule, // YouTube lite module
  ],
})
export class YourModule {}

Usage

To use ngx-lite-video, add the 'ngx-lite-youtube'/'ngx-lite-vimeo' component to your template and configure its properties as needed:

<!-- YouTube Component -->
<ngx-lite-youtube videoId="Ys7xdebd66Y"></ngx-lite-youtube>

<!-- Vimeo Component -->
<ngx-lite-vimeo videoId="786570322"></ngx-lite-vimeo>

Custom styles

To override styling create a class in global style.scss file & provide it to styleClass attribute

For more detailed examples see Demo page

API

YouTube Attributes

PropertyTypeDefaultDescription
videoIdstringundefinedVideo ID to be viewed
videoTitlestringundefinedTitle to be displayed in lazy mode
hasControlsbooleanfalseShows/hides video controls in iframe
loopbooleanfalseEnables video looping
allowFullScreenbooleantrueEnables/disables fullscreen button in iframe
startnumberundefinedSets starting video time (in seconds)
endnumberundefinedSets ending video time (in seconds)
styleClassstringundefinedExternal styling class
thumbQuality'sd', 'medium', 'high', 'max''high'Lazy image quality

Vimeo Attributes

PropertyTypeDefaultDescription
videoIdstringundefinedVideo ID to be viewed
thumbQuality'sd', 'medium', 'high', 'max''high'Lazy image quality
showTitlebooleanfalseEnables/disables showing title in lazy mode
hasControlsbooleanfalseShows/hides video controls in iframe
loopbooleanfalseEnables video looping
isBackgroundbooleanfalseEnables vimeo background mode, please refer to https://developer.vimeo.com/player/sdk/embed
styleClassstringundefinedExternal styling class

Contributing

Contributions are welcome. You can start by creating new Issue with proposal or bug report.

License

ngx-lite-video is an open source package released under the MIT license. See the LICENSE file for more information.