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

react-video-upload-preview

v1.0.1

Published

Preview an uploaded video file client side (without any server interaction). You can also select an arbitrary time to set the preview at or show the beginning or end of the video.

Downloads

17

Readme

Video Upload React Preview

Preview an uploaded video file client side (without any server interaction). You can also select an arbitrary time to set the preview at or show the beginning or end of the video.

Installation

Install from NPM

npm i react-video-upload-preview

OR

Install from Github: In your project's src directory, you can run:

git clone https://github.com/alvst/react-uploaded-video-preview.git

Usage

import FileThumbnail from "react-uploaded-video-preview";
...
<FileThumbnail
    file={file}
    // Optional:
    startTime={3000}
    canvasSize={900}
    startTimeFail={2}
    finalFail={"end"}
    DefaultFailedOrientation={"Horizontal"}
    altText={"Custom Alt Text for screen readers"}
    CustomFailedFileImageHorizontal={CustomFailedHorizontal}
    CustomFailedFileImageVertical={CustomFailedVertical}
    />

Properties

| Prop Name | Type | Default | Description | | --- | --- | --- | --- | | file (Required) | object | | A single file (not link) | | canvasSize | int | 200 | The width of the thumbnail. | | startTime | int | 0 | The ability to set an arbitrary time for the preview timestamp to show | | startTimeFail | int | | If the startTime specified is not available, because the file is too short, this is a secondary fall back. | | finalFail | string | Beginning | If startTime and startTimeFail both are not available (because the file is too short), finalFail is the final fallback. You can specify beginning (default) or 'e'/'end' for end and video.duration. | | defaultFailedOrientation | string | Horizontal | If the file cannot display (due to incompatable file type or a Javascript error) and if no custom files are selected, a default Video Preview Not Available file is included that will be displayed. One horizontal, one vertical file are included. Specifying Horizontal or Vertical will use the appropriate file. | | CustomFailedFileImageHorizontal | object | | A custom Horizontal file that will be displayed if the video file cannot be displayed| | CustomFailedFileImageVertical | object | | A custom Vertical file that will be displayed if the video file cannot be displayed |

*Note: due to webpage memory constraints, you may want to limit the amount of times this is run on a single page. a maximum of 4 times is my recommendation as after it often reloads the page. Please file a pull request if you know how to fix this.

Known Problems:

Only Safari is able to display .mov/.MOV file previews. If a .mov file is uploaded in a non-safari browser, a failed image file will shown. Using either CustomFailedFileImageHorizontal or CustomFailedFileImageVertical you can display your own custom file.

Attempting to display too many files can result in the page crashing (and the uploaded files being removed) depending on the browser and the users computer's RAM constraints. I recommend limiting the amount of files displayed to limit storage usage. You may also want to provide an option to not display the files. If you know how to fix this, please file a pull request.

Limitations:

This does not work for linking videos. For linking videos, check out other Github repositories like.

Examples:

For an example see here.

Contribution:

Want to contribute? Please file an issue or pull request.

Inspiration & Credits:

This project was inspired by the React Video Thumbnail Project as well as this Stack Overflow answer.