-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57353 from HezekielT/fix/ios-handle-unsupported-v…
…ideo-formats Fix: Handle unsupported videos in iOS
- Loading branch information
Showing
10 changed files
with
98 additions
and
4 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
diff --git a/node_modules/expo-av/ios/EXAV/EXAVPlayerData.m b/node_modules/expo-av/ios/EXAV/EXAVPlayerData.m | ||
index 99dc808..01e4bb9 100644 | ||
--- a/node_modules/expo-av/ios/EXAV/EXAVPlayerData.m | ||
+++ b/node_modules/expo-av/ios/EXAV/EXAVPlayerData.m | ||
@@ -158,8 +158,16 @@ NSString *const EXAVPlayerDataObserverMetadataKeyPath = @"timedMetadata"; | ||
// unless we preload, the asset will not necessarily load the duration by the time we try to play it. | ||
// http://stackoverflow.com/questions/20581567/avplayer-and-avfoundationerrordomain-code-11819 | ||
EX_WEAKIFY(self); | ||
- [avAsset loadValuesAsynchronouslyForKeys:@[ @"duration" ] completionHandler:^{ | ||
+ [avAsset loadValuesAsynchronouslyForKeys:@[ @"isPlayable", @"duration" ] completionHandler:^{ | ||
EX_ENSURE_STRONGIFY(self); | ||
+ NSError *error = nil; | ||
+ AVKeyValueStatus status = [avAsset statusOfValueForKey:@"isPlayable" error:&error]; | ||
+ | ||
+ if (status == AVKeyValueStatusLoaded && !avAsset.isPlayable) { | ||
+ NSString *errorMessage = @"Load encountered an error: [AVAsset isPlayable:] returned false. The asset does not contains a playable content or is not supported by the device."; | ||
+ [self _finishLoadWithError:errorMessage]; | ||
+ return; | ||
+ } | ||
|
||
// We prepare three items for AVQueuePlayer, so when the first finishes playing, | ||
// second can start playing and the third can start preparing to play. |
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
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
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
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React from 'react'; | ||
import {View} from 'react-native'; | ||
import Icon from '@components/Icon'; | ||
import * as Expensicons from '@components/Icon/Expensicons'; | ||
import Text from '@components/Text'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import useTheme from '@hooks/useTheme'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import variables from '@styles/variables'; | ||
|
||
type VideoErrorIndicatorProps = { | ||
/** Whether it is a preview or not */ | ||
isPreview?: boolean; | ||
}; | ||
|
||
function VideoErrorIndicator({isPreview = false}: VideoErrorIndicatorProps) { | ||
const theme = useTheme(); | ||
const styles = useThemeStyles(); | ||
const {translate} = useLocalize(); | ||
|
||
return ( | ||
<View style={[styles.flexColumn, styles.alignItemsCenter, styles.justifyContentCenter, styles.pAbsolute, styles.h100, styles.w100]}> | ||
<Icon | ||
fill={isPreview ? theme.border : theme.icon} | ||
src={Expensicons.VideoSlash} | ||
width={variables.eReceiptEmptyIconWidth} | ||
height={variables.eReceiptEmptyIconWidth} | ||
/> | ||
{!isPreview && ( | ||
<View> | ||
<Text style={[styles.notFoundTextHeader, styles.ph11]}>{translate('common.errorOccuredWhileTryingToPlayVideo')}</Text> | ||
</View> | ||
)} | ||
</View> | ||
); | ||
} | ||
|
||
VideoErrorIndicator.displayName = 'VideoErrorIndicator'; | ||
|
||
export default VideoErrorIndicator; |
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
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
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
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