refactor: load player on initialization (#4673)

This commit is contained in:
Krzysztof Moch
2025-09-01 13:50:51 +02:00
committed by GitHub
parent 4ed51e14ca
commit f929d56a87
33 changed files with 411 additions and 287 deletions
+2 -2
View File
@@ -1565,7 +1565,7 @@ PODS:
- React-logger (= 0.77.2)
- React-perflogger (= 0.77.2)
- React-utils (= 0.77.2)
- ReactNativeVideo (7.0.0-alpha.3):
- ReactNativeVideo (7.0.0-alpha.4):
- DoubleConversion
- glog
- hermes-engine
@@ -1904,7 +1904,7 @@ SPEC CHECKSUMS:
ReactAppDependencyProvider: f334cebc0beed0a72490492e978007082c03d533
ReactCodegen: 474fbb3e4bb0f1ee6c255d1955db76e13d509269
ReactCommon: 7763e59534d58e15f8f22121cdfe319040e08888
ReactNativeVideo: 213235288864ce876c68a64cc1481fe8a3eae5d5
ReactNativeVideo: f365bc4f1a57ab50ddb655cda2f47bc06698a53b
ReactNativeVideoDrm: 62840ae0e184f711a2e6495c18e342a74cb598f8
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
Yoga: 31a098f74c16780569aebd614a0f37a907de0189
+7 -9
View File
@@ -134,11 +134,13 @@ const VideoDemo = () => {
useEvent(player, 'onVolumeChange', handleVolumeChange);
React.useEffect(() => {
if (!settings.show) return;
player.volume = settings.volume;
player.muted = settings.muted;
player.rate = settings.rate;
if (player.isPlaying) {
player.rate = settings.rate;
}
player.loop = settings.loop;
player.playInBackground = settings.playInBackground;
player.playWhenInactive = settings.playWhenInactive;
@@ -179,18 +181,14 @@ const VideoDemo = () => {
<Slider
style={styles.progressSlider}
minimumValue={0}
maximumValue={
settings.show ? (isNaN(player.duration) ? 1 : player.duration) : 0
}
maximumValue={isNaN(player.duration) ? 1 : player.duration}
value={progress}
onSlidingComplete={handleSeek}
minimumTrackTintColor="#007aff"
maximumTrackTintColor="#e1e1e1"
thumbTintColor="#007aff"
/>
<Text style={styles.timeText}>
{formatTime(settings.show ? player.duration : 0)}
</Text>
<Text style={styles.timeText}>{formatTime(player.duration)}</Text>
</View>
</View>