Skip to content

Commit

Permalink
fix: audio for the video muted when the silent mode is on for iOS (#2564
Browse files Browse the repository at this point in the history
)

* 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
khushal87 authored Jun 20, 2024
1 parent 4912ce9 commit abf6f2a
Showing 1 changed file with 27 additions and 13 deletions.
40 changes: 27 additions & 13 deletions package/expo-package/src/handlers/Video.tsx
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;

0 comments on commit abf6f2a

Please sign in to comment.