1.0.13 • Published 1 year ago

videojs-watch-percentage v1.0.13

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

videojs-watch-percentage

A simple npm package to track the percentage of a video watched using Video.js.

Installation

You can install videojs-watch-percentage via npm or yarn:

npm install videojs-watch-percentage

or

yarn add videojs-watch-percentage

Usage

const videoTracker = require('videojs-watch-percentage');

const videoElement = document.getElementById('my-video');
videoTracker(videoElement);

videoElement.addEventListener('videoended', event => {
    console.log('Total Watched:', event.detail.totalWatched);
    console.log('Skipped Sections:', event.detail.skippedSections);
});

Usage React

const videoRef = useRef(null);

useEffect(() => {
    const videoElement = videoRef.current;
    videoTracker(videoElement);
    return () => {
        videoElement.removeEventListener('videoended', onVideoEnded);
    };
}, []); 

const onVideoEnded = event => {
    console.log('Total Watched:', event.detail.totalWatched);
    console.log('Skipped Sections:', event.detail.skippedSections);
};

Usage Vue

mounted() {
    const videoElement = this.$refs.videoPlayer;
    videoTracker(videoElement);
    videoElement.addEventListener('videoended', this.onVideoEnded);
},
beforeDestroy() {
    const videoElement = this.$refs.videoPlayer;
    videoElement.removeEventListener('videoended', this.onVideoEnded);
},
methods: {
    onVideoEnded(event) {
        console.log('Total Watched:', event.detail.totalWatched);
        console.log('Skipped Sections:', event.detail.skippedSections);
    }
}

License

This package is licensed under the MIT License.

1.0.13

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

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

1.0.1

1 year ago

1.0.0

1 year ago