New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

stencil-video-timeline

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stencil-video-timeline

A StencilJS component for creating a video timeline.

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

Stencil Video Timeline

A customizable video timeline component built with Stencil.js, designed to be framework-agnostic and easy to integrate into React, Vue, Angular, or any web application.

Table of Contents

  • Installation
  • Getting Started
  • Using in Vanilla JS/HTML
  • Using with React
  • Using with Vue
  • Using with Angular
  • Properties
  • Methods
  • Events
  • Styling
  • Contributing
  • License

Installation

Install the package via npm:

npm install stencil-video-timeline

Getting Started

Using in Vanilla JS/HTML

To use the component in a plain HTML/JavaScript project:

1. Include the component’s loader in your HTML:
<!-- index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <title>Stencil Video Timeline Example</title>
  <script src="node_modules/stencil-video-timeline/dist/stencil-video-timeline/stencil-video-timeline.esm.js" type="module"></script>
  <script src="node_modules/stencil-video-timeline/dist/stencil-video-timeline/stencil-video-timeline.js" nomodule defer></script>
</head>
<body>
  <stencil-video-timeline></stencil-video-timeline>

  <script>
    // Optional: Initialize the component
    stencilVideoTimeline.defineCustomElements(window);
  </script>
</body>
</html>
2. Use the component in your HTML:
<stencil-video-timeline
  canvas-height="50"
  play-time="1609459200000"
  speed="1000"
  for-ward-value="5000"
  start-time-threshold="1609455600000"
  end-time-threshold="1609462800000"
  is-play-click="false"
></stencil-video-timeline>

Using with React

1. Install the React wrapper:
npm install stencil-video-timeline-react
2. Import and use the component:
// App.jsx
import React from 'react';
import { defineCustomElements } from 'stencil-video-timeline/loader';
import { StencilVideoTimeline } from 'stencil-video-timeline-react';

defineCustomElements(window);

function App() {
  return (
    <div>
      <StencilVideoTimeline
        canvasHeight={50}
        playTime="1609459200000"
        speed={1000}
        forWardValue={5000}
        startTimeThreshold="1609455600000"
        endTimeThreshold="1609462800000"
        isPlayClick={false}
      />
    </div>
  );
}

export default App;

Using with Vue

1. Install the Vue wrapper:
npm install stencil-video-timeline-vue
2. Register the component:
// main.js
import Vue from 'vue';
import App from './App.vue';
import { applyPolyfills, defineCustomElements } from 'stencil-video-timeline/loader';

Vue.config.productionTip = false;

applyPolyfills().then(() => {
  defineCustomElements(window);
});

new Vue({
  render: (h) => h(App),
}).$mount('#app');
3. Use the component in your Vue template:
<!-- App.vue -->
<template>
  <div>
    <stencil-video-timeline
      :canvas-height="50"
      :play-time="1609459200000"
      :speed="1000"
      :for-ward-value="5000"
      :start-time-threshold="1609455600000"
      :end-time-threshold="1609462800000"
      :is-play-click="false"
    ></stencil-video-timeline>
  </div>
</template>

<script>
export default {
  name: 'App',
};
</script>

Using with Angular

1. Install the Angular wrapper:
npm install stencil-video-timeline-angular
2. Add the custom elements schema to your app module:
// app.module.ts
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';

@NgModule({
  declarations: [AppComponent],
  imports: [BrowserModule],
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  bootstrap: [AppComponent],
})
export class AppModule {}
3. Initialize the component loader:
// main.ts
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { defineCustomElements } from 'stencil-video-timeline/loader';

import { AppModule } from './app/app.module';

defineCustomElements(window);

platformBrowserDynamic()
  .bootstrapModule(AppModule)
  .catch((err) => console.error(err));
4. Use the component in your Angular template:
<!-- app.component.html -->
<stencil-video-timeline
  [canvasHeight]="50"
  [playTime]="1609459200000"
  [speed]="1000"
  [forWardValue]="5000"
  [startTimeThreshold]="1609455600000"
  [endTimeThreshold]="1609462800000"
  [isPlayClick]="false"
></stencil-video-timeline>

Properties

PropertyAttributeTypeDefaultDescription
canvasHeightcanvas-heightnumber50The height of the canvas element.
playTimeplay-timenumber | string | DateDate.now()The current playback time in milliseconds.
speedspeednumber1000The playback speed in milliseconds.
forWardValuefor-ward-valuenumber5000Time to skip forward or backward in milliseconds.
startTimeThresholdstart-time-thresholdnumber | string | DateDate.now() - 12 * 3600 * 1000The start time threshold in milliseconds.
endTimeThresholdend-time-thresholdnumber | string | DateDate.now() + 12 * 3600 * 1000The end time threshold in milliseconds.
isPlayClickis-play-clickbooleanfalseWhether the play button has been clicked.
videoCells-Array[]Array of video cell objects representing clips.
borderColorborder-colorstring'#fff'The color of the canvas border.
bgColorbg-colorstring'#fff'The background color of the canvas.
bottomLineColorbottom-line-colorstring'rgba(0,0,0,1)'The color of the bottom line on the timeline.
verticalBarColorvertical-bar-colorstring'rgba(0,0,0,1)'The color of the vertical bars on the timeline.
playBarColorplay-bar-colorstring'#448aff'The color of the play bar.

Methods

The component exposes several methods for controlling playback and timeline behavior.

  • onPlayClick() — Starts playback.

    await stencilVideoTimeline.onPlayClick();
    
  • onPauseClick() — Pauses playback.

    await stencilVideoTimeline.onPauseClick();
    
  • forward() — Skips forward by the specified amount in forWardValue.

    await stencilVideoTimeline.forward();
    
  • backward() — Skips backward by the specified amount in forWardValue.

    await stencilVideoTimeline.backward();
    

Events

The component emits several events you can listen to:

Event NameDescription
playClickEmitted when the play button is clicked.
onMouseUpEmitted when the mouse button is released.
onMouseDownEmitted when the mouse button is pressed down.
onKeyUpEmitted when a key is released.
onKeyDownEmitted when a key is pressed down.

Listening to Events

  • In JavaScript:

    const timeline = document.querySelector('stencil-video-timeline');
    timeline.addEventListener('playClick', (event) => {
      console.log('Play clicked:', event.detail);
    });
    
  • In React:

    <StencilVideoTimeline
      onPlayClick={(event) => {
        console.log('Play clicked:', event.detail);
      }}
    />
    
  • In Vue:

    <stencil-video-timeline @playClick="handlePlayClick"></stencil-video-timeline>
    
    <script>
    export default {
      methods: {
        handlePlayClick(event) {
          console.log('Play clicked:', event.detail);
        },
      },
    };
    </script>
    
  • In Angular:

    <stencil-video-timeline (playClick)="handlePlayClick($event)"></stencil-video-timeline>
    
    // app.component.ts
    export class AppComponent {
      handlePlayClick(event: CustomEvent) {
        console.log('Play clicked:', event.detail);
      }
    }
    

Styling

You can style the component using properties or by targeting CSS variables:

CSS VariableDescription
--timeline-border-colorThe border color of the timeline
--timeline-bg-colorThe background color
--timeline-play-bar-colorThe color of the play bar
--timeline-vertical-bar-colorThe color of vertical bars
--timeline-bottom-line-colorThe color of the bottom line

Example

stencil-video-timeline {
  --timeline-border-color: #ccc;
  --timeline-bg-color: #f9f9f9;
  --timeline-play-bar-color: #ff0000;
}

Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

License

This project is licensed under the MIT License.

Keywords

FAQs

Package last updated on 09 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc