-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
1 changed file
with
27 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,30 @@ | ||
import { VideoComponent } from '../optionalDependencies'; | ||
import React, { useEffect } from 'react'; | ||
|
||
import { AudioComponent, VideoComponent } from '../optionalDependencies'; | ||
|
||
export const Video = VideoComponent | ||
? ({ onPlaybackStatusUpdate, paused, resizeMode, style, uri, videoRef }) => ( | ||
<VideoComponent | ||
onPlaybackStatusUpdate={onPlaybackStatusUpdate} | ||
ref={videoRef} | ||
resizeMode={resizeMode} | ||
shouldPlay={!paused} | ||
source={{ | ||
uri, | ||
}} | ||
style={[style]} | ||
/> | ||
) | ||
? ({ onPlaybackStatusUpdate, paused, resizeMode, style, uri, videoRef }) => { | ||
// This is done so that the audio of the video is not muted when the phone is in silent mode for iOS. | ||
useEffect(() => { | ||
const initializeSound = async () => { | ||
await AudioComponent.setAudioModeAsync({ | ||
playsInSilentModeIOS: true, | ||
}); | ||
}; | ||
initializeSound(); | ||
}, []); | ||
|
||
return ( | ||
<VideoComponent | ||
onPlaybackStatusUpdate={onPlaybackStatusUpdate} | ||
ref={videoRef} | ||
resizeMode={resizeMode} | ||
shouldPlay={!paused} | ||
source={{ | ||
uri, | ||
}} | ||
style={[style]} | ||
/> | ||
); | ||
} | ||
: null; |