Monolord's Knight
Monolord's Knight

Reputation: 183

Expo- av: Autoplay a video

My purpose is to play a video as background, which will start just after the app loaded,

<Video
  ref={video}
  style={styles.video}
  source={{
    uri: 'http://d23dyxeqlo5psv.cloudfront.net/big_buck_bunny.mp4',
  }}
  isLooping
  resizeMode="contain"
  onPlaybackStatusUpdate={status => setStatus(() => status)}
  onLoad={() => {video.setPositionAsync(0); video.current.playAsync()}}
/>

It worked twice for me. Until then just remained stopped after every compiling.
What change should it require? As a background video there should be no controls visible.

Upvotes: 9

Views: 6538

Answers (1)

Rokas Rudzianskas
Rokas Rudzianskas

Reputation: 998

You can add the property shouldPlay in your code, this will make the video autostart playing, then the app loads. Hope it solved the problem.

Upvotes: 17

Related Questions