Skip to content

Commit

Permalink
feat(player): Added new config element to start media at a certain se…
Browse files Browse the repository at this point in the history
…cond; included documentation of it
  • Loading branch information
Rafael Miranda committed Jan 21, 2019
1 parent 86155cf commit 2d98ac2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
6 changes: 4 additions & 2 deletions README.md
Expand Up @@ -12,13 +12,13 @@ This awesome player mimics the HTML5 video/audio methods/events/properties, and

It also has the ability to play VMAP, VAST and VPAID Ads in an effortless way!

## Why OpenPlayer?
## Advantages of using OpenPlayerJS

* **Supports IE11+ (Win8) and all modern browsers**: its CSS and code is compatible with all modern browsers. IE11+ on Win7 requires an MP4/MP3 fallback to work correctly.
* **Lightweight library**: Less than `20kb` when gzipped.
* **Monetize video and audio content** with video advertising using VAST, VPAID or VMAP Ads, supported by the amazing [Interactive Media Ads SDK](https://developers.google.com/interactive-media-ads/) (IMA SDK) library.
* **Accessibility is a priority for OpenPlayerJS**: You can even create specific styling for high contrast mode, and support visually impaired people and improve accessibility. See https://developer.paciellogroup.com/blog/2010/01/high-contrast-proof-css-sprites/ for more details.
* **Always up-to-date**: Relying on services like Greenkeeper, OpenPlayer uses the latest and greatest versions of the packages to ensure it is always updated; also, IMA SDK, [hls.js](https://github.com/video-dev/hls.js/) and [dash.js](https://github.com/Dash-Industry-Forum/dash.js/) use **even-green paths** from their recommended CDN sources to they will be always providing the latest upgrades for OpenPlayer.
* **Always up-to-date**: Relying on services like Greenkeeper, OpenPlayer uses the latest and greatest versions of the packages to ensure it is always updated; also, IMA SDK, [hls.js](https://github.com/video-dev/hls.js/) and [dash.js](https://github.com/Dash-Industry-Forum/dash.js/) use **even-green paths** from their recommended CDN sources to they will be always providing the latest upgrades for OpenPlayerJS.
* **Smart `autoplay`**: Special algorithm to detect browser's autoplay capabilities.
* **Responsive**: Always adapts to the screen size (and resize) by default, for both video/audio tags; a new **`fill`** mode is also included to scale and crop media relative to its parent container.
* Support for **local and remote captions** for **both video and audio**, even without including the `crossorigin` attribute.
Expand Down Expand Up @@ -92,6 +92,8 @@ var player = new OpenPlayer('[player ID]', [valid VAST/VPAID URL|List of VAST/VP
step,
// Initial volume of media in decimal numbers (by default, `1`)
startVolume,
// Initial play time of media in seconds (by default, `0`)
startTime,
ads: {
// Custom path/URL to IMA SDK
url,
Expand Down
10 changes: 8 additions & 2 deletions dist/openplayer.js
Expand Up @@ -345,7 +345,7 @@ exports.offset = offset;
/* 6 */
/***/ (function(module, exports) {

var core = module.exports = { version: '2.6.2' };
var core = module.exports = { version: '2.5.7' };
if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef


Expand Down Expand Up @@ -1071,7 +1071,7 @@ var store = global[SHARED] || (global[SHARED] = {});
})('versions', []).push({
version: core.version,
mode: __webpack_require__(25) ? 'pure' : 'global',
copyright: 2019 Denis Pushkarev (zloirock.ru)'
copyright: 2018 Denis Pushkarev (zloirock.ru)'
});


Expand Down Expand Up @@ -1371,6 +1371,7 @@ var Player = function () {
volumeControl: 'Volume Control',
volumeSlider: 'Volume Slider'
},
startTime: 0,
startVolume: 1,
step: 0
};
Expand All @@ -1382,6 +1383,11 @@ var Player = function () {
this.autoplay = this.element.autoplay || false;
this.options = deepmerge(this.defaultOptions, options || {});
this.element.volume = this.options.startVolume;

if (this.options.startTime > 0) {
this.element.currentTime = this.options.startTime;
}

this.volume = this.element.volume;
this.element.autoplay = false;
}
Expand Down
2 changes: 1 addition & 1 deletion dist/openplayer.min.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/js/player.ts
Expand Up @@ -263,6 +263,7 @@ class Player {
volumeControl: 'Volume Control',
volumeSlider: 'Volume Slider',
},
startTime: 0,
startVolume: 1,
step: 0,
};
Expand All @@ -285,6 +286,9 @@ class Player {
this.autoplay = this.element.autoplay || false;
this.options = deepmerge(this.defaultOptions, options || {});
this.element.volume = this.options.startVolume;
if (this.options.startTime > 0) {
this.element.currentTime = this.options.startTime;
}
this.volume = this.element.volume;
this.element.autoplay = false;
}
Expand Down

0 comments on commit 2d98ac2

Please sign in to comment.