Воспроизведение видео блока - PullRequest
0 голосов
/ 31 марта 2020

Следующая программа в React-Native позволяет воспроизводить видео, но блокирует нажатие кнопки. Я считаю, что это из-за позиции: абсолютное значение, но есть ли способ избежать этой проблемы?

import React, { Component } from 'react';
import Video from 'react-native-video';
import {
  StyleSheet,
  TouchableOpacity,
  Text,
  View,
  Button,
} from 'react-native'

class App extends Component {
  state = {
    count: 0,
    message: 'Hello Everybody'
  }

  onPress = () => {
    this.setState({

      count: this.state.count + 1
    })
  }

 render() {
    return (
      <View style={styles.container}>

          <Button title={'Press me'} 
            onPress={() => {
                console.log('Boton Presionado')
                this.setState({message: 'Presiono'})
              }}
          />
          <Text>{this.state.message}</Text>
          <Video source={{uri: 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4'}}
            ref={(ref) => {
              this.player = ref
            }}                                      // Store reference
            onBuffer={this.onBuffer}                // Callback when remote video is buffering
            onError={this.videoError}               // Callback when video cannot be loaded
            style={styles.backgroundVideo}

          />


      </View>
    )
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
  button: {
    alignItems: 'center',
    backgroundColor: '#DDDDDD',
    padding: 10,
    marginBottom: '10'
  },
  backgroundVideo: {
    position: 'absolute',
    top: 0,
    left: 0,
    bottom: 0,
    right: 0,
  }  
})

export default App;

1 Ответ

0 голосов
/ 31 марта 2020

Я изменил положение: «абсолютное» на положение: «относительное» и добавил значения высоты и ширины.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...