-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replace react-native-video with expo-av (#18812)
* replace react-native-video with expo-av * story * 😢 * remove rnvideo pod * use 5.0.1 * review feedback from jzila * fix android * postinstall patch * remove rnvideo * just copy file instead of patch * story
- Loading branch information
Showing
67 changed files
with
5,004 additions
and
4,877 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
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,83 @@ | ||
buildscript { | ||
repositories { | ||
google() | ||
jcenter() | ||
} | ||
|
||
dependencies { | ||
classpath 'com.android.tools.build:gradle:3.1.3' | ||
} | ||
} | ||
|
||
apply plugin: 'com.android.library' | ||
apply plugin: 'maven' | ||
|
||
group = 'host.exp.exponent' | ||
version = '5.0.2' | ||
|
||
def safeExtGet(prop, fallback) { | ||
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback | ||
} | ||
|
||
// Upload android library to maven with javadoc and android sources | ||
configurations { | ||
deployerJars | ||
} | ||
|
||
// Creating sources with comments | ||
task androidSourcesJar(type: Jar) { | ||
classifier = 'sources' | ||
from android.sourceSets.main.java.srcDirs | ||
} | ||
|
||
// Put the androidSources and javadoc to the artifacts | ||
artifacts { | ||
archives androidSourcesJar | ||
} | ||
|
||
uploadArchives { | ||
repositories { | ||
mavenDeployer { | ||
configuration = configurations.deployerJars | ||
repository(url: mavenLocal().url) | ||
} | ||
} | ||
} | ||
|
||
android { | ||
compileSdkVersion safeExtGet("compileSdkVersion", 28) | ||
|
||
defaultConfig { | ||
minSdkVersion safeExtGet("minSdkVersion", 21) | ||
targetSdkVersion safeExtGet("targetSdkVersion", 28) | ||
versionCode 9 | ||
versionName "5.0.2" | ||
} | ||
lintOptions { | ||
abortOnError false | ||
} | ||
} | ||
|
||
if (new File(rootProject.projectDir.parentFile, 'package.json').exists()) { | ||
apply from: project(":unimodules-core").file("../unimodules-core.gradle") | ||
} else { | ||
throw new GradleException( | ||
"'unimodules-core.gradle' was not found in the usual Flutter or React Native dependency locations. " + | ||
"This package can only be used in such projects. Are you sure you've installed the dependencies properly?") | ||
} | ||
|
||
dependencies { | ||
unimodule "unimodules-core" | ||
unimodule "unimodules-permissions-interface" | ||
implementation 'com.android.support:support-annotations:28.0.0' | ||
// Newer version introduces dependency versions conflict | ||
// on 'com.android.support:support-annotations' | ||
api 'com.google.android.exoplayer:exoplayer:2.9.2' | ||
|
||
api 'com.google.android.exoplayer:extension-okhttp:2.9.2' | ||
|
||
api 'com.yqritc:android-scalablevideoview:1.0.1' | ||
|
||
api "com.squareup.okhttp3:okhttp:3.10.0" | ||
api "com.squareup.okhttp3:okhttp-urlconnection:3.10.0" | ||
} |
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
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 @@ | ||
import * as React from 'react' | ||
import * as Styles from '../styles' | ||
|
||
export type Props = { | ||
autoPlay?: boolean | ||
controls?: boolean | ||
loop?: boolean | ||
muted?: boolean // note that we're keeping playsInSilentModeIOS default which is false | ||
style?: Styles.StylesCrossPlatform | null | ||
url: string | ||
} | ||
|
||
export type VideoState = { | ||
containerHeight: number | ||
containerWidth: number | ||
loadedVideoSize: boolean | ||
videoHeight: number | ||
videoWidth: number | ||
} | ||
|
||
declare class Video extends React.Component<Props> {} | ||
declare class Audio extends React.Component<Props> {} |
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,82 @@ | ||
import * as React from 'react' | ||
import {Props} from './av' | ||
import Box from './box' | ||
import * as Styles from '../styles' | ||
import {useVideoSizer, CheckURL} from './av.shared' | ||
import {Video as ExpoVideo} from 'expo-av' | ||
import {StatusBar} from 'react-native' | ||
import logger from '../logger' | ||
|
||
const Kb = { | ||
Box, | ||
} | ||
|
||
export const Video = (props: Props) => { | ||
const [videoSize, setContainerSize, setVideoNaturalSize] = useVideoSizer() | ||
return ( | ||
<CheckURL url={props.url}> | ||
<Kb.Box | ||
style={styles.container} | ||
onLayout={event => | ||
event && | ||
event.nativeEvent && | ||
event.nativeEvent.layout && | ||
setContainerSize(event.nativeEvent.layout.height, event.nativeEvent.layout.width) | ||
} | ||
> | ||
<ExpoVideo | ||
source={{uri: props.url}} | ||
onError={e => { | ||
logger.error(`Error loading vid: ${JSON.stringify(e)}`) | ||
}} | ||
useNativeControls={!!props.controls} | ||
onFullscreenUpdate={update => | ||
update.fullscreenUpdate === ExpoVideo.FULLSCREEN_UPDATE_PLAYER_WILL_DISMISS && | ||
StatusBar.setHidden(false) | ||
} | ||
onReadyForDisplay={ready => | ||
ready && | ||
ready.naturalSize && | ||
setVideoNaturalSize(ready.naturalSize.height, ready.naturalSize.width) | ||
} | ||
style={videoSize} | ||
isMuted={!!props.muted} | ||
resizeMode={ExpoVideo.RESIZE_MODE_CONTAIN} | ||
shouldPlay={!!props.autoPlay} | ||
isLooping={!!props.loop} | ||
/> | ||
</Kb.Box> | ||
</CheckURL> | ||
) | ||
} | ||
|
||
// TODO we should probalby have custom style here. The controls auto hides on | ||
// Android. | ||
export const Audio = (props: Props) => ( | ||
<ExpoVideo | ||
source={{uri: props.url}} | ||
onError={e => { | ||
logger.error(`Error loading vid: ${JSON.stringify(e)}`) | ||
}} | ||
useNativeControls={!!props.controls} | ||
isMuted={!!props.muted} | ||
shouldPlay={!!props.autoPlay} | ||
isLooping={!!props.loop} | ||
style={styles.audio} | ||
/> | ||
) | ||
|
||
const styles = Styles.styleSheetCreate({ | ||
audio: { | ||
...Styles.globalStyles.fullWidth, | ||
backgroundColor: Styles.globalColors.black, | ||
height: Styles.isAndroid ? 96 : 48, | ||
}, | ||
container: { | ||
...Styles.globalStyles.flexBoxRow, | ||
alignItems: 'center', | ||
height: '100%', | ||
justifyContent: 'center', | ||
width: '100%', | ||
}, | ||
}) |
Oops, something went wrong.