Merge pull request #1039 from shlokamin/master

adds audioOnly option that always displays poster image (if provided)…
This commit is contained in:
Hampton Maxwell 2018-06-20 17:05:13 -07:00 committed by GitHub
commit e4e3ce1877
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View File

@ -218,6 +218,7 @@ var styles = StyleSheet.create({
### Configurable props ### Configurable props
* [allowsExternalPlayback](#allowsexternalplayback) * [allowsExternalPlayback](#allowsexternalplayback)
* [audioOnly](#audioonly)
* [ignoreSilentSwitch](#ignoresilentswitch) * [ignoreSilentSwitch](#ignoresilentswitch)
* [muted](#muted) * [muted](#muted)
* [paused](#paused) * [paused](#paused)
@ -246,6 +247,15 @@ Indicates whether the player allows switching to external playback mode such as
Platforms: iOS Platforms: iOS
#### audioOnly
Indicates whether the player should only play the audio track and instead of displaying the video track, show the poster instead.
* **false (default)** - Display the video as normal
* **true** - Show the poster and play the audio
For this to work, the poster prop must be set.
Platforms: all
#### ignoreSilentSwitch #### ignoreSilentSwitch
Controls the iOS silent switch behavior Controls the iOS silent switch behavior
* **"inherit" (default)** - Use the default AVPlayer behavior * **"inherit" (default)** - Use the default AVPlayer behavior

View File

@ -68,7 +68,7 @@ export default class Video extends Component {
}; };
_onSeek = (event) => { _onSeek = (event) => {
if (this.state.showPoster) { if (this.state.showPoster && !this.props.audioOnly) {
this.setState({showPoster: false}); this.setState({showPoster: false});
} }
@ -132,7 +132,7 @@ export default class Video extends Component {
}; };
_onPlaybackRateChange = (event) => { _onPlaybackRateChange = (event) => {
if (this.state.showPoster && (event.nativeEvent.playbackRate !== 0)) { if (this.state.showPoster && event.nativeEvent.playbackRate !== 0 && !this.props.audioOnly) {
this.setState({showPoster: false}); this.setState({showPoster: false});
} }
@ -307,6 +307,7 @@ Video.propTypes = {
ignoreSilentSwitch: PropTypes.oneOf(['ignore', 'obey']), ignoreSilentSwitch: PropTypes.oneOf(['ignore', 'obey']),
disableFocus: PropTypes.bool, disableFocus: PropTypes.bool,
controls: PropTypes.bool, controls: PropTypes.bool,
audioOnly: PropTypes.bool,
currentTime: PropTypes.number, currentTime: PropTypes.number,
progressUpdateInterval: PropTypes.number, progressUpdateInterval: PropTypes.number,
useTextureView: PropTypes.bool, useTextureView: PropTypes.bool,