-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
replace react-native-video with expo-av #18812
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e14fcc5
replace react-native-video with expo-av
songgao 1ff3c4e
story
songgao 80563f0
😢
songgao e60dc3e
remove rnvideo pod
songgao 1f3bdee
use 5.0.1
songgao f98b11e
review feedback from jzila
songgao eacf2b5
fix android
songgao ea9156b
postinstall patch
songgao bf28bb2
remove rnvideo
songgao 5da497c
just copy file instead of patch
songgao c71346d
story
songgao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you switch this to hooks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer to not refactor this whole component for this PR