ExoPlayer (#426)

This commit is contained in:
Andrew Jack
2017-01-11 12:51:45 +00:00
committed by Matt Apperson
parent cd53e389a0
commit 9a936c9e8f
32 changed files with 1744 additions and 71 deletions

View File

@@ -19,6 +19,7 @@ class VideoPlayer extends Component {
super(props);
this.onLoad = this.onLoad.bind(this);
this.onProgress = this.onProgress.bind(this);
this.onBuffer = this.onBuffer.bind(this);
}
state = {
rate: 1,
@@ -29,7 +30,8 @@ class VideoPlayer extends Component {
currentTime: 0.0,
controls: false,
paused: true,
skin: 'custom'
skin: 'custom',
isBuffering: false,
};
onLoad(data) {
@@ -41,6 +43,10 @@ class VideoPlayer extends Component {
this.setState({currentTime: data.currentTime});
}
onBuffer({ isBuffering }: { isBuffering: boolean }) {
this.setState({ isBuffering });
}
getCurrentTimePercentage() {
if (this.state.currentTime > 0) {
return parseFloat(this.state.currentTime) / parseFloat(this.state.duration);
@@ -116,6 +122,7 @@ class VideoPlayer extends Component {
muted={this.state.muted}
resizeMode={this.state.resizeMode}
onLoad={this.onLoad}
onBuffer={this.onBuffer}
onProgress={this.onProgress}
onEnd={() => { AlertIOS.alert('Done!') }}
repeat={true}
@@ -175,6 +182,7 @@ class VideoPlayer extends Component {
muted={this.state.muted}
resizeMode={this.state.resizeMode}
onLoad={this.onLoad}
onBuffer={this.onBuffer}
onProgress={this.onProgress}
onEnd={() => { AlertIOS.alert('Done!') }}
repeat={true}