Merge pull request #1089 from react-native-community/bugfix/exoplayer-progress-playable

ExoPlayer playableDuration incorrect
This commit is contained in:
Hampton Maxwell 2018-06-25 12:27:32 -07:00 committed by GitHub
commit a3732885d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 5 deletions

View File

@ -195,7 +195,6 @@ using System.Collections.Generic;
onFullscreenPlayerDidPresent={this.fullScreenPlayerDidPresent} // Callback after fullscreen started onFullscreenPlayerDidPresent={this.fullScreenPlayerDidPresent} // Callback after fullscreen started
onFullscreenPlayerWillDismiss={this.fullScreenPlayerWillDismiss} // Callback before fullscreen stops onFullscreenPlayerWillDismiss={this.fullScreenPlayerWillDismiss} // Callback before fullscreen stops
onFullscreenPlayerDidDismiss={this.fullScreenPlayerDidDismiss} // Callback after fullscreen stopped onFullscreenPlayerDidDismiss={this.fullScreenPlayerDidDismiss} // Callback after fullscreen stopped
onProgress={this.setTime} // Callback every ~250ms with currentTime
style={styles.backgroundVideo} /> style={styles.backgroundVideo} />
// Later to trigger fullscreen // Later to trigger fullscreen
@ -242,6 +241,7 @@ var styles = StyleSheet.create({
### Event props ### Event props
* [onLoad](#onload) * [onLoad](#onload)
* [onLoadStart](#onloadstart) * [onLoadStart](#onloadstart)
* [onProgress](#onprogress)
* [onTimedMetadata](#ontimedmetadata) * [onTimedMetadata](#ontimedmetadata)
### Methods ### Methods
@ -496,9 +496,9 @@ Payload:
Property | Description Property | Description
--- | --- --- | ---
isNetwork | Boolean indicating if the media is being loaded from the network isNetwork | boolean | Boolean indicating if the media is being loaded from the network
type | Type of the media. Not available on Windows type | string | Type of the media. Not available on Windows
uri | URI for the media source. Not available on Windows uri | string | URI for the media source. Not available on Windows
Example: Example:
``` ```
@ -511,6 +511,24 @@ Example:
Platforms: all Platforms: all
#### onProgress
Callback function that is called every progressInterval seconds with info about which position the media is currently playing.
Property | Description
--- | ---
currentTime | number | Current position in seconds
playableDuration | number | Position to where the media can be played to using just the buffer in seconds
seekableDuration | number | Position to where the media can be seeked to in seconds. Typically, the total length of the media
Example:
```
{
currentTime: 5.2,
playableDuration: 34.6,
seekableDuration: 888
}
```
#### onTimedMetadata #### onTimedMetadata
Callback function that is called when timed metadata becomes available Callback function that is called when timed metadata becomes available

View File

@ -136,7 +136,7 @@ class ReactExoplayerView extends FrameLayout implements
&& player.getPlayWhenReady() && player.getPlayWhenReady()
) { ) {
long pos = player.getCurrentPosition(); long pos = player.getCurrentPosition();
long bufferedDuration = player.getBufferedPercentage() * player.getDuration(); long bufferedDuration = player.getBufferedPercentage() * player.getDuration() / 100;
eventEmitter.progressChanged(pos, bufferedDuration, player.getDuration()); eventEmitter.progressChanged(pos, bufferedDuration, player.getDuration());
msg = obtainMessage(SHOW_PROGRESS); msg = obtainMessage(SHOW_PROGRESS);
sendMessageDelayed(msg, Math.round(mProgressUpdateInterval)); sendMessageDelayed(msg, Math.round(mProgressUpdateInterval));