Skip to content

Commit

Permalink
v1.0.0-alpha.1
Browse files Browse the repository at this point in the history
  • Loading branch information
cycjimmy committed Sep 20, 2017
1 parent dfc4c2f commit a1efdd5
Show file tree
Hide file tree
Showing 16 changed files with 1,490 additions and 491 deletions.
9 changes: 9 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
}
]
],
"env": {
"test": {
"presets": [
[
"env"
]
]
}
},
"plugins": [
"syntax-dynamic-import"
],
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,4 @@ npm-debug.log
yarn-error.log

# project
temp
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
src
test
58 changes: 21 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,52 +53,36 @@ $ ffmpeg -i input.mp4 -f mpegts
### How To Use
```javascript
import * as JSMpeg from 'jsmpeg-player';
```

```javascript
# OR
let JSMpeg = require('jsmpeg-player');
```

```javascript
let
// Html Element for videoWrapper.
videoWrapper = document.getElementById('videoWrapper')
, videoUrl = '../static/media/test_video.ts'
;

new JSMpeg.VideoElement(videoWrapper, videoUrl, {
// the poster of video(Recommended to set it manually)
poster: '../static/images/screenshot_test.jpg',

// Aspect ratio converted to percentage.
// E.g: '16:9' => '56.25%'
// default: '56.25%'
aspectPercent: '56.25%',

// picture node (no playButton)
// default: false
picMode: true,

// The player sets the hook when playing/pause/stop
hookInPlay: () => {},
hookInPause: () => {},
hookInStop: () => {},

// other options are the same as JSMpeg.Player
// https://github.com/phoboslab/jsmpeg
})
new JSMpeg.VideoElement(videoWrapper, videoUrl, [, options])
```
* `videoWrapper`: [string|element] the wrapper of video. Height and width of wrapper must be initialized
* `videoUrl`: [string] a url to an MPEG .ts file
* The `options` supports:
* `poster`: [string] URL to an image to use as the poster to show before the video plays.(Recommended to set it manually)
* `autoplay`: [boolean] whether to start playing immediately. Default `false`.
* `loop`: [boolean] whether to loop the video (static files only). Default `false`.**[overwrite]**
* `aspectPercent`: [string] Aspect ratio converted to percentage. E.g: '16:9' => `'56.25%'`. Default `'56.25%'`.
* `picMode`: [boolean] picture node (no playButton). Default `false`.
* `chunkSize` the chunk size in bytes to load at a time. Default `1024*1024` (1mb).
* `hookInPlay`: [function] The hook function when the video play.
* `hookInPause`: [function] The hook function when the video pause.
* `hookInStop`: [function] The hook function when the video stop.

More options can view the [jsmpeg options](https://github.com/phoboslab/jsmpeg#usage)

### Use in browser
```html
<script src="../dist/JSMpeg.min.js"></script>
<div id="videoWrapper"></div>
<script src="dist/JSMpeg.min.js"></script>
<script>
var
videoWrapper = document.getElementById('testVideo')
, videoUrl = '../static/media/test_video.ts'
;
new JSMpeg.VideoElement(videoWrapper, videoUrl, {});
var videoUrl = '../static/media/test_video.ts';
new JSMpeg.VideoElement('#videoWrapper', videoUrl);
</script>
```

###
Loading

0 comments on commit a1efdd5

Please sign in to comment.