Skip to content

Commit e4b7c5c

Browse files
committed
start paused option
1 parent aa3063a commit e4b7c5c

File tree

6 files changed

+28
-7
lines changed

6 files changed

+28
-7
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ Property | Type | Default | Required | Description
133133
show | `String`,`Array` | none | no | The video or video fallback array to show.
134134
showPlaylist | `Array` | none | no | An array of video URL strings, or of video fallback arrays.
135135
play | `Number` | none | no | Similar to `show` but used to play a video at a given index in the `showPlaylist` array.
136+
paused | `Boolean` | false | no | Set the playlist to a paused state on initial load.
136137
poster | `String` | none | no | A fallback image to use, when all else fails.
137138
mute | `Boolean` | true | no | Should the videos be played muted?
138139
loop | `Boolean` | true | no | Should videos / playlists loop or begin again when finished?

dist/react-drive-in-browser.js

+16-2
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,7 @@ var ReactDriveIn = (function (React) { 'use strict';
508508
_this.loop = true;
509509
_this.loopPlaylistItems = false;
510510
_this.slideshow = false;
511+
_this.startPaused = false;
511512

512513
_this.playlistLength = 0;
513514
_this.currentItem = 0;
@@ -870,7 +871,11 @@ var ReactDriveIn = (function (React) { 'use strict';
870871

871872
var onCanPlay = function onCanPlay() {
872873
_this2.emit("media.canplay");
873-
mediaEl.play();
874+
875+
if (!_this2.startPaused) {
876+
mediaEl.play();
877+
}
878+
874879
if (_this2._seeking) {
875880
_this2._seeking = false;
876881
}
@@ -917,6 +922,10 @@ var ReactDriveIn = (function (React) { 'use strict';
917922

918923
_this3._slideshowTimer = new Timer(ended, _this3.slideshowItemDuration * 1000);
919924

925+
if (_this3.startPaused) {
926+
_this3._slideshowTimer.pause();
927+
}
928+
920929
_this3._slideshowTimer.on("pause", onPause);
921930
}
922931
};
@@ -1086,6 +1095,8 @@ var ReactDriveIn = (function (React) { 'use strict';
10861095

10871096
this.slideshow = options.slideshow;
10881097

1098+
this.startPaused = options.startPaused;
1099+
10891100
this.parentEl = this._setParent(options.el);
10901101

10911102
var mediaEl = this._createMediaEl();
@@ -1259,6 +1270,7 @@ var ReactDriveIn = (function (React) { 'use strict';
12591270
className: props.className,
12601271
mute: props.mute,
12611272
loop: props.loop,
1273+
playing: !props.paused,
12621274
loopPaylistItems: props.loopPlaylistItems,
12631275
slideshow: props.slideshow,
12641276
volume: props.volume,
@@ -1329,7 +1341,8 @@ var ReactDriveIn = (function (React) { 'use strict';
13291341

13301342
this.DI.init({
13311343
el: this.getMedia(),
1332-
slideshow: this.props.slideshow
1344+
slideshow: this.props.slideshow,
1345+
startPaused: this.props.paused
13331346
});
13341347

13351348
var options = {
@@ -1429,6 +1442,7 @@ var ReactDriveIn = (function (React) { 'use strict';
14291442
showPlaylist: React.PropTypes.oneOfType([React.PropTypes.array]),
14301443
poster: React.PropTypes.string,
14311444
mute: React.PropTypes.bool,
1445+
paused: React.PropTypes.bool,
14321446
loop: React.PropTypes.bool,
14331447
loopPlaylistItems: React.PropTypes.bool,
14341448
playbackRate: React.PropTypes.number,

dist/react-drive-in.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ var ReactDriveIn = (function (_React$Component) {
6868
className: props.className,
6969
mute: props.mute,
7070
loop: props.loop,
71+
playing: !props.paused,
7172
loopPaylistItems: props.loopPlaylistItems,
7273
slideshow: props.slideshow,
7374
volume: props.volume,
@@ -146,7 +147,8 @@ var ReactDriveIn = (function (_React$Component) {
146147
loop: this.props.loop,
147148
loopPlaylistItems: this.props.loopPlaylistItems,
148149
poster: this.props.poster,
149-
isTouch: this.props.isTouch
150+
isTouch: this.props.isTouch,
151+
startPaused: this.props.paused
150152
};
151153

152154
if (this.props.showPlaylist) {
@@ -238,6 +240,7 @@ ReactDriveIn.propTypes = {
238240
showPlaylist: React.PropTypes.oneOfType([React.PropTypes.array]),
239241
poster: React.PropTypes.string,
240242
mute: React.PropTypes.bool,
243+
paused: React.PropTypes.bool,
241244
loop: React.PropTypes.bool,
242245
loopPlaylistItems: React.PropTypes.bool,
243246
playbackRate: React.PropTypes.number,

example/index.html

+1
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ <h2>Currently Playing: <span id="currItem"></span></h2>
163163
onPlaying={onPlaying}
164164
slideshow={false}
165165
loopPlaylistItems
166+
paused
166167
/>,
167168
driveInEl
168169
);

lib/react-drive-in.jsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class ReactDriveIn extends React.Component {
1111
className: props.className,
1212
mute: props.mute,
1313
loop: props.loop,
14+
playing: !props.paused,
1415
loopPaylistItems: props.loopPlaylistItems,
1516
slideshow: props.slideshow,
1617
volume: props.volume,
@@ -70,7 +71,8 @@ class ReactDriveIn extends React.Component {
7071

7172
this.DI.init({
7273
el: this.getMedia(),
73-
slideshow: this.props.slideshow
74+
slideshow: this.props.slideshow,
75+
startPaused: this.props.paused
7476
});
7577

7678
const options = {
@@ -162,6 +164,7 @@ ReactDriveIn.propTypes = {
162164
showPlaylist: React.PropTypes.oneOfType([React.PropTypes.array]),
163165
poster: React.PropTypes.string,
164166
mute: React.PropTypes.bool,
167+
paused: React.PropTypes.bool,
165168
loop: React.PropTypes.bool,
166169
loopPlaylistItems: React.PropTypes.bool,
167170
playbackRate: React.PropTypes.number,

package.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-drive-in",
3-
"version": "1.7.2",
3+
"version": "1.7.3",
44
"description": "React component supporting background videos and playlists.",
55
"main": "dist/react-drive-in.js",
66
"jsnext:main": "lib/react-drive-in.jsx",
@@ -43,7 +43,6 @@
4343
"babel-preset-es2015-rollup": "^1.0.0",
4444
"babel-preset-react": "^6.1.18",
4545
"browser-sync": "^2.9.7",
46-
"drive-in": "^1.5.1",
4746
"eslint": "^1.7.3",
4847
"eslint-config-defaults": "^7.0.1",
4948
"eslint-plugin-filenames": "^0.2.0",
@@ -76,6 +75,6 @@
7675
},
7776
"homepage": "https://github.com/ronik-design/react-drive-in",
7877
"dependencies": {
79-
"drive-in": "^1.5.0"
78+
"drive-in": "^1.5.2"
8079
}
8180
}

0 commit comments

Comments
 (0)