Video props not working for expo-video-player

Please provide the following:

  1. SDK Version: 35
  2. Platforms(Android/iOS/web/all): all

I have the following code below. I’d like to get isPlaying working, however it doesn’t seem to work.

<VideoPlayer
    width={screenWidth / 4}
    height={screenWidth / 4}
    videoProps={{
        isPlaying: () => alert("video playing!"),
        shouldPlay: false,
        resizeMode: Video.RESIZE_MODE_CONTAIN,
        source: {
            uri: uri
        }
    }}
    inFullscreen={false}
/>

If I change isPlaying: () => alert("video playing!") to isPlaying: alert("video playing!"), then it prints the alert on load… which is obviously not what I want. What am I doing wrong here?

Hi. It looks like you’re using expo-video-player, which as far as I can tell is not part of Expo, so might be best to move this to the Third Party Software category :slight_smile:

But the following works for me:

import React, { useState } from "react";
import { StyleSheet, Text, View } from "react-native";
import { Video } from "expo-av";
import VideoPlayer from "expo-video-player";

export default () => {
  const [isPlaying, setIsPlaying] = useState(false);
  return (
    <View style={styles.container}>
      <Text>isPlaying: {JSON.stringify(isPlaying)}</Text>
      <VideoPlayer
        videoProps={{
          shouldPlay: true,
          resizeMode: Video.RESIZE_MODE_CONTAIN,
          source: {
            uri: "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"
          }
        }}
        inFullscreen={false}
        playbackCallback={status => {
          if (isPlaying !== status.isPlaying) {
            setIsPlaying(status.isPlaying);
          }
        }}
      />
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: "#fff",
    alignItems: "center",
    justifyContent: "center",
    paddingTop: 80
  }
});

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.