Skip to content

Commit abf6f2a

Browse files
authored
fix: audio for the video muted when the silent mode is on for iOS (#2564)
* fix: audio for the video muted when the silent mode is on for iOS * fix: audio for the video muted when the silent mode is on for iOS
1 parent 4912ce9 commit abf6f2a

File tree

1 file changed

+27
-13
lines changed

1 file changed

+27
-13
lines changed
Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,30 @@
1-
import { VideoComponent } from '../optionalDependencies';
1+
import React, { useEffect } from 'react';
2+
3+
import { AudioComponent, VideoComponent } from '../optionalDependencies';
24

35
export const Video = VideoComponent
4-
? ({ onPlaybackStatusUpdate, paused, resizeMode, style, uri, videoRef }) => (
5-
<VideoComponent
6-
onPlaybackStatusUpdate={onPlaybackStatusUpdate}
7-
ref={videoRef}
8-
resizeMode={resizeMode}
9-
shouldPlay={!paused}
10-
source={{
11-
uri,
12-
}}
13-
style={[style]}
14-
/>
15-
)
6+
? ({ onPlaybackStatusUpdate, paused, resizeMode, style, uri, videoRef }) => {
7+
// This is done so that the audio of the video is not muted when the phone is in silent mode for iOS.
8+
useEffect(() => {
9+
const initializeSound = async () => {
10+
await AudioComponent.setAudioModeAsync({
11+
playsInSilentModeIOS: true,
12+
});
13+
};
14+
initializeSound();
15+
}, []);
16+
17+
return (
18+
<VideoComponent
19+
onPlaybackStatusUpdate={onPlaybackStatusUpdate}
20+
ref={videoRef}
21+
resizeMode={resizeMode}
22+
shouldPlay={!paused}
23+
source={{
24+
uri,
25+
}}
26+
style={[style]}
27+
/>
28+
);
29+
}
1630
: null;

0 commit comments

Comments
 (0)