1.1.7 • Published 1 year ago

video-react-hooks v1.1.7

Weekly downloads
-
License
-
Repository
github
Last release
1 year ago

Purpose

Video-react-hooks represents video events in the form of React hooks. By encapsulating the video event logic in hooks. These hooks can then be easily used across the application in components that are affected by the video events. This approach not only simplifies the code but also makes it more readable and maintainable.

Instalation

npm install --save video-react-hooks

Usage Example

Each hook built on the concept of React hooks, and each hook is based on a specific video event. These hooks are executed when the corresponding event occurs during video playback. Under the hood video-react-hooks also used React hooks.

Check Live Example

import { useReadyEffect, usePlayingEffect, usePauseEffect } from 'video-react-hooks';

export const VideoComponent = () => {

  useReadyEffect(() => {
    //executed when video is ready
  }, []);

  usePlayingEffect(() => {
    //executed when video is playing
  }, []);

  usePauseEffect(() => {
    //executed when video is paused
  }, []);

  return (
    <div className="App">
       <video controls>
        <source
          src="src"
          type="video/mp4"
        />
        Your browser does not support the video tag.
      </video>
    </div>
  );
}

API Details

useReadyEffect - executed when video is ready

import { useReadyEffect } from 'video-react-hooks';

useReadyEffect(() => {
  //code here
}, []);

usePlayingEffect - executed when video is playing

import { usePlayingEffect } from 'video-react-hooks';

usePlayingEffect(() => {
  //code here
}, []);

usePauseEffect - executed when video is paused

import { usePauseEffect } from 'video-react-hooks';

usePauseEffect(() => {
  //code here
}, []);

useWaitingEffect - executed when video is waiting

import { useWaitingEffect } from 'video-react-hooks';

useWaitingEffect(() => {
  //code here
}, []);

useSeekingEffect - executed when video is seeking

import { useSeekingEffect } from 'video-react-hooks';

useSeekingEffect(() => {
  //code here
}, []);

useSeekedEffect - executed when video is seeked

import { useSeekedEffect } from 'video-react-hooks';

useSeekedEffect(() => {
  //code here
}, []);

useTimeUpdateEffect - executed when video is timeupdate event executed this hooks executed once per frame

import { useTimeUpdateEffect } from 'video-react-hooks';

useTimeUpdateEffect(() => {
  //code here
}, []);

useEndEffect - executed when video is ended executed for hls(vod) or mp4 video

import { useEndEffect } from 'video-react-hooks';

useEndEffect(() => {
  //code here
}, []);

useErrorEffect - executed when video error event occur

import { useErrorEffect } from 'video-react-hooks';

useErrorEffect((e) => {
  //code here
}, []);

useVolumeChangeEffect - executed when video volume change

import { useVolumeChangeEffect } from 'video-react-hooks';

useVolumeChangeEffect((e) => {
  //code here
}, []);
Available Hooks
useRateChangeEffect
useStalledEffect
useSuspendEffect
useAbortEffect

Types

EventTypeHookDescription
eTErrorEffectuseErrorEffectValue of error
eTVolumeEffectuseVolumeChangeEffectValue of volume change

Testing

Video TypesHLS(LIVE)HLS(VOD)MP4
Supported:white_check_mark::white_check_mark::white_check_mark:
1.1.7

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

0.11.0

1 year ago

0.10.16

1 year ago

0.10.15

1 year ago

0.10.14

1 year ago

0.10.13

1 year ago

0.10.12

1 year ago

0.10.11

1 year ago

0.10.10

1 year ago

0.10.9

1 year ago

0.10.8

1 year ago

0.10.7

1 year ago

0.10.6

1 year ago

0.10.5

1 year ago

0.10.4

1 year ago

0.10.3

1 year ago

0.10.2

1 year ago

0.10.1

1 year ago

0.10.0

1 year ago

0.9.0

1 year ago

0.8.0

1 year ago

0.7.0

1 year ago

0.5.0

1 year ago

0.4.0

1 year ago

0.3.0

1 year ago

0.2.0

1 year ago

0.1.0

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago