1.0.3 • Published 1 year ago

vids-plus-ads v1.0.3

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

VidsPlusAds

React video component library with in-built support for running video ads

Integrate ads in your videos without hassle

  • Easy configuration with simple props
  • (New v1) Supports all VideoJS methods
  • Written in TS for type filling and parametr diagnosis
  • Set how often you want the ad to run
  • Set whether you want the ad to preroll
  • Ads automatically adjust to your displayed video component dimensions regardless of ratio/size differences
  • Skip Ad feature when ad is running
  • Can use as simple video player if no ad source was passed

Installation

npm install vids-plus-ads

Usage

Import package

import VidsPlusAds from 'vids-plus-ads'

Set required parameters

// set ad frequency in ms (time between ads)
const adFrequency = 10000
// set video source
const videoSource =
  'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4'
// set ad source
const adSource =
  'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerMeltdowns.mp4'

Pass props and call component

<VidsPlusAds {...{ adFrequency, videoSource, adSource }} />

Component Props

* requried

NameTypeDescription
videoSource*stringLocal path or URL source for main video content
adSourcestringLocal path or URL source for video ad
adFrequencynumberThe time in milliseconds between ad runs
prerollbooleanPreroll ad upon video playback if true
autoplaybooleanAutoplay video on load
thumbnailstringvideo thumbnail image source
heightnumberheight of player in px
widthnumberwidth of player in px
fluidbooleanauto adjust player size
controlsbooleanshow video controls
onPlayfunctioncallback when player starts/resumes
onLoadedMetaDatafunctioncallback when video metadata is loaded
onPausefunctioncallback when player is paused
overlayChildReact.Nodeelement to be displayed on top of video

Component Methods

ref | useRef() Obj | Can be used to programmatically trigger player methods/actions

const ref = useRef()
// ...

<VidsPlusAds {...props} ref={ref} />

Core Methods

All Video Player methods supported by VideoJS are accessible on any VidsPlusAds intance through the 'core' prop on ref.current.

examples:

  • ref.current.core.play() plays video
  • ref.current.core.pause() pauses video
  • ref.current.core.duration() returns video duration in seconds
  • ref.current.core.currentTime() returns current video time in seconds
  • ref.current.core.currentTime(seconds) sets current video time in seconds
  • ref.current.core.paused() returns true if video is paused
  • ref.current.core.ended() returns true if video has ended

Extended Methods

Convenience methods with added functionality. Accessed directly with ref.current

  • ref.current.togglePlay() toggles play/pause

Migration

version 1.0.0+ added support for all VideoJS methods.

To migrate from version 0 to 1 install the new version and covert any core method calls on ref.current to ref.current.core instead.

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.3.9

1 year ago

1.0.3

1 year ago

0.3.10

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.3.6

1 year ago

0.3.5

1 year ago

0.1.7

1 year ago

0.3.8

1 year ago

0.3.7

1 year ago

0.3.2

1 year ago

0.1.4

1 year ago

0.3.1

1 year ago

0.1.3

1 year ago

0.3.4

1 year ago

0.1.6

1 year ago

0.3.3

1 year ago

0.1.5

1 year ago

0.1.2

1 year ago

0.1.0

1 year ago