Skip to content

Commit

Permalink
setState being called when window off screen #7
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle Milloy committed Nov 29, 2016
1 parent 4a36712 commit b783838
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 29 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
[Seeking before onLoad triggers onEnd](https://github.com/itsnubix/react-native-video-controls/issues/8)
- modified pan handler to also look for if loading state which is set to false on init and changed when onLoad fired.

[setState being called when window off screen](https://github.com/itsnubix/react-native-video-controls/issues/7)
- added componentWillUnmount function to clear controlTimeout
- Note that if using react router componentWillUnmount will not fire unless you configure it to. See [this ticket](https://github.com/aksonov/react-native-router-flux/issues/131)


## 0.9.7 (21-11-2016)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ The `<VideoPlayer>` component can take a number of inputs to customize it as nee

// settings
controlTimeout={ 15000 } // hide controls after ms of inactivity.
navigator={ navigator } // prop from React Native <Navigator> component
videoStyle={ {} } // Style appended to <Video> component
style={ {} } // Style appended to <View> container

Expand Down
30 changes: 1 addition & 29 deletions VideoPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ export default class VideoPlayer extends Component {
let state = this.state;
state.loading = true;
this.loadAnimation();

this.setState( state );
}

Expand All @@ -158,7 +157,6 @@ export default class VideoPlayer extends Component {
state.duration = data.duration;
state.loading = false;


this.setState( state );

if ( state.showControls ) {
Expand All @@ -181,7 +179,6 @@ export default class VideoPlayer extends Component {
this.setSeekerPosition( position );
}


this.setState( state );
}

Expand All @@ -198,12 +195,10 @@ export default class VideoPlayer extends Component {
* the video failed to load.
*/
_onError( err ) {

let state = this.state;
state.error = true;
state.loading = false;


this.setState( state );
}

Expand All @@ -225,7 +220,6 @@ export default class VideoPlayer extends Component {
this.methods.toggleControls();
state.lastScreenPress = time;


this.setState( state );
}

Expand Down Expand Up @@ -350,7 +344,6 @@ export default class VideoPlayer extends Component {
state.showControls = false;
this.hideControlAnimation();


this.setState( state );
}

Expand All @@ -371,7 +364,6 @@ export default class VideoPlayer extends Component {
this.clearControlTimeout();
}


this.setState( state );
}

Expand All @@ -385,7 +377,6 @@ export default class VideoPlayer extends Component {
state.isFullscreen = ! state.isFullscreen;
state.resizeMode = state.isFullscreen === true ? 'cover' : 'contain';


this.setState( state );
}

Expand All @@ -395,7 +386,6 @@ export default class VideoPlayer extends Component {
_togglePlayPause() {
let state = this.state;
state.paused = ! state.paused;

this.setState( state );
}

Expand All @@ -406,7 +396,6 @@ export default class VideoPlayer extends Component {
_toggleTimer() {
let state = this.state;
state.showTimeRemaining = ! state.showTimeRemaining;

this.setState( state );
}

Expand All @@ -420,7 +409,7 @@ export default class VideoPlayer extends Component {
this.props.navigator.pop();
}
else {
console.warn( 'Warning: _onBack requires navigator property to function. Either modify the onBack prop or ' );
console.warn( 'Warning: _onBack requires navigator property to function. Either modify the onBack prop or pass a navigator prop' );
}
}

Expand Down Expand Up @@ -469,7 +458,6 @@ export default class VideoPlayer extends Component {
if ( ! state.seeking ) {
state.seekerOffset = position;
}

this.setState( state );
}

Expand Down Expand Up @@ -512,7 +500,6 @@ export default class VideoPlayer extends Component {
let state = this.state;
state.currentTime = time;
this.player.ref.seek( time );

this.setState( state );
}

Expand All @@ -535,7 +522,6 @@ export default class VideoPlayer extends Component {
state.volumeTrackWidth = 150;
}


this.setState( state );
}

Expand Down Expand Up @@ -599,7 +585,6 @@ export default class VideoPlayer extends Component {
this.setVolumePosition( position );
state.volumeOffset = position;


this.setState( state );
}

Expand Down Expand Up @@ -628,8 +613,6 @@ export default class VideoPlayer extends Component {
let state = this.state;
this.clearControlTimeout();
state.seeking = true;


this.setState( state );
},

Expand All @@ -655,7 +638,6 @@ export default class VideoPlayer extends Component {
this.events.onEnd();
}
this.setControlTimeout();

this.setState( state );
}
});
Expand Down Expand Up @@ -690,8 +672,6 @@ export default class VideoPlayer extends Component {
else {
state.muted = false;
}


this.setState( state );
},

Expand All @@ -702,7 +682,6 @@ export default class VideoPlayer extends Component {
let state = this.state;
state.volumeOffset = state.volumePosition;
this.setControlTimeout();

this.setState( state );
}
});
Expand All @@ -727,13 +706,6 @@ export default class VideoPlayer extends Component {
* wrapper and styling.
*/
renderControl( children, callback, style = {} ) {
callback = callback || function() {

};
if ( typeof callback !== 'function' ) {

}

return (
<TouchableHighlight
underlayColor="transparent"
Expand Down

0 comments on commit b783838

Please sign in to comment.