├── .babelrc ├── .eslintrc ├── .gitignore ├── .idea └── vcs.xml ├── .npmignore ├── .npmrc ├── DEV_ONLY └── App.js ├── LICENSE ├── README.md ├── dist ├── vidz.js ├── vidz.js.map └── vidz.min.js ├── package.json ├── src ├── index.js └── utils.js ├── test ├── index.js ├── setup-browser-environment.js └── utils.js ├── webpack.config.dev.js ├── webpack.config.js ├── webpack.config.minified.js └── yarn.lock /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": ["add-module-exports"], 3 | "presets": [["env", { "loose": true }], "react", "stage-2"] 4 | } 5 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["rapid7/browser"], 3 | "parser": "babel-eslint", 4 | "rules": {} 5 | } 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | node_modules/ 3 | lib/ -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | DEV_ONLY/ 3 | node_modules/ 4 | src/ 5 | test/ 6 | dist/ 7 | .babelrc 8 | .eslintrc 9 | .gitignore 10 | .npmignore 11 | webpack.config.js 12 | webpack.config.minified.js 13 | webpack.config.dev.js -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | scripts-prepend-node-path=true -------------------------------------------------------------------------------- /DEV_ONLY/App.js: -------------------------------------------------------------------------------- 1 | import $ from 'jquery'; 2 | import React, { 3 | Component 4 | } from 'react'; 5 | import { 6 | render 7 | } from 'react-dom'; 8 | 9 | import vidz from '../src'; 10 | 11 | const delayVolumeDown = (instance, shouldDecrease = false, hasRun = false) => { 12 | return new Promise((resolve) => { 13 | setTimeout(() => { 14 | const currentVolume = instance.getVolume(); 15 | 16 | if (hasRun && currentVolume === 1) { 17 | resolve() 18 | } else if (!shouldDecrease) { 19 | instance.setVolume(currentVolume + 0.1); 20 | 21 | resolve(delayVolumeDown(instance, false, true)); 22 | } else { 23 | instance.setVolume(currentVolume - 0.1); 24 | 25 | resolve(delayVolumeDown(instance, currentVolume >= 0.1, true)); 26 | } 27 | }, 250); 28 | }); 29 | }; 30 | 31 | class App extends Component { 32 | vidzInstance = null; 33 | 34 | componentDidMount() { 35 | let interval = null; 36 | 37 | const $div = $(this.refs.videoContainer); 38 | 39 | this.vidzInstance = vidz($div, { 40 | mp4: 'http://www.html5rocks.com/en/tutorials/video/basics/devstories.mp4', 41 | muted: true, 42 | onTimeUpdate() { 43 | console.log(this.currentTime); 44 | console.log(this.duration); 45 | }, 46 | poster: 'https://placeholdit.imgix.net/~text?txtsize=33&txt=350%C3%97150&w=350&h=150', 47 | swf: 'test.swf', 48 | webm: 'http://www.html5rocks.com/en/tutorials/video/basics/devstories.webm' 49 | }); 50 | 51 | this.forceUpdate(); 52 | } 53 | 54 | state = { 55 | isPlaying: false 56 | }; 57 | 58 | onClickPlayPause = () => { 59 | const { 60 | isPlaying 61 | } = this.state; 62 | 63 | if (isPlaying) { 64 | this.vidzInstance.pause(); 65 | } else { 66 | this.vidzInstance.play(); 67 | } 68 | 69 | this.setState({ 70 | isPlaying: !isPlaying 71 | }); 72 | }; 73 | 74 | render() { 75 | return ( 76 |
77 | App 78 | 79 |
83 | 84 |
87 | Toggle play / pause 88 |
89 |
90 | ); 91 | } 92 | } 93 | 94 | const div = document.createElement('div'); 95 | 96 | div.id = 'app-container'; 97 | 98 | render(( 99 | 100 | ), div); 101 | 102 | document.body.appendChild(div); 103 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Plant The Idea 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | vidz 2 | =========== 3 | 4 | Tiny library to provide a no-muss, no-fuss HTML5 video element 5 | 6 | #### Purpose 7 | 8 | To introduce a simple, straightforward method to dynamically add well-formatted HTML5 video to the DOM. `vidz` has no dependencies, and is based off of the native DOM elements and selectors, however if you are using jQuery it will also work with elements in jQuery objects. 9 | 10 | #### Installation 11 | 12 | ``` 13 | $ npm i vidz --save 14 | ``` 15 | 16 | #### Usage 17 | 18 | ```javascript 19 | // ES2015 20 | import vidz from 'vidz'; 21 | 22 | // CommonJS 23 | const vidz = require('vidz').default; 24 | 25 | // script 26 | const vidz = window.vidz; 27 | 28 | const vidzInstance = vidz('#video-container', { 29 | mp4: './videos/test.mp4', 30 | ogg: './videos/test.ogg' 31 | }); 32 | ``` 33 | 34 | This will instantiate a new `vidz` instance, appending a generated `