Skip to content

Commit

Permalink
add video to app
Browse files Browse the repository at this point in the history
  • Loading branch information
joemun committed Jul 12, 2023
1 parent 9910ef5 commit 38efd95
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 75 deletions.
98 changes: 24 additions & 74 deletions examples/fabric/App.tsx
Original file line number Diff line number Diff line change
@@ -1,59 +1,16 @@
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
*/

import React from 'react';
import type {PropsWithChildren} from 'react';
import {
SafeAreaView,
ScrollView,
StatusBar,
StyleSheet,
Text,
useColorScheme,
View,
} from 'react-native';

import {
Colors,
DebugInstructions,
Header,
LearnMoreLinks,
ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen';

type SectionProps = PropsWithChildren<{
title: string;
}>;
import Video from 'react-native-video';

function Section({children, title}: SectionProps): JSX.Element {
const isDarkMode = useColorScheme() === 'dark';
return (
<View style={styles.sectionContainer}>
<Text
style={[
styles.sectionTitle,
{
color: isDarkMode ? Colors.white : Colors.black,
},
]}>
{title}
</Text>
<Text
style={[
styles.sectionDescription,
{
color: isDarkMode ? Colors.light : Colors.dark,
},
]}>
{children}
</Text>
</View>
);
}
import {Colors, Header} from 'react-native/Libraries/NewAppScreen';

function App(): JSX.Element {
const isDarkMode = useColorScheme() === 'dark';
Expand All @@ -76,42 +33,35 @@ function App(): JSX.Element {
style={{
backgroundColor: isDarkMode ? Colors.black : Colors.white,
}}>
<Section title="Step One">
Edit <Text style={styles.highlight}>App.tsx</Text> to change this
screen and then come back to see your edits.
</Section>
<Section title="See Your Changes">
<ReloadInstructions />
</Section>
<Section title="Debug">
<DebugInstructions />
</Section>
<Section title="Learn More">
Read the docs to discover what to do next:
</Section>
<LearnMoreLinks />
<Video
source={{
uri: 'http://d23dyxeqlo5psv.cloudfront.net/big_buck_bunny.mp4',
}}
style={styles.video}
onProgress={(e: {
currentPlaybackTime: number;
currentTime: number;
playableDuration: number;
seekableDuration: number;
}) => {
console.log('Video.onProgress event received', e);
}}
onEnd={() => {
console.log('Video.onEnd event received');
}}
controls
resizeMode="contain"
/>
</View>
</ScrollView>
</SafeAreaView>
);
}

const styles = StyleSheet.create({
sectionContainer: {
marginTop: 32,
paddingHorizontal: 24,
},
sectionTitle: {
fontSize: 24,
fontWeight: '600',
},
sectionDescription: {
marginTop: 8,
fontSize: 18,
fontWeight: '400',
},
highlight: {
fontWeight: '700',
video: {
width: '100%',
height: 202,
},
});

Expand Down
9 changes: 9 additions & 0 deletions examples/fabric/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,11 @@ PODS:
- React-jsinspector (0.72.3)
- React-logger (0.72.3):
- glog
- react-native-video (5.2.1):
- React-Core
- react-native-video/Video (= 5.2.1)
- react-native-video/Video (5.2.1):
- React-Core
- React-NativeModulesApple (0.72.3):
- hermes-engine
- React-callinvoker
Expand Down Expand Up @@ -1112,6 +1117,7 @@ DEPENDENCIES:
- React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`)
- React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`)
- React-logger (from `../node_modules/react-native/ReactCommon/logger`)
- react-native-video (from `../node_modules/react-native-video`)
- React-NativeModulesApple (from `../node_modules/react-native/ReactCommon/react/nativemodule/core/platform/ios`)
- React-perflogger (from `../node_modules/react-native/ReactCommon/reactperflogger`)
- React-RCTActionSheet (from `../node_modules/react-native/Libraries/ActionSheetIOS`)
Expand Down Expand Up @@ -1197,6 +1203,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon/jsinspector"
React-logger:
:path: "../node_modules/react-native/ReactCommon/logger"
react-native-video:
:path: "../node_modules/react-native-video"
React-NativeModulesApple:
:path: "../node_modules/react-native/ReactCommon/react/nativemodule/core/platform/ios"
React-perflogger:
Expand Down Expand Up @@ -1272,6 +1280,7 @@ SPEC CHECKSUMS:
React-jsiexecutor: 59d1eb03af7d30b7d66589c410f13151271e8006
React-jsinspector: b511447170f561157547bc0bef3f169663860be7
React-logger: c5b527272d5f22eaa09bb3c3a690fee8f237ae95
react-native-video: c26780b224543c62d5e1b2a7244a5cd1b50e8253
React-NativeModulesApple: c57f3efe0df288a6532b726ad2d0322a9bf38472
React-perflogger: 6bd153e776e6beed54c56b0847e1220a3ff92ba5
React-RCTActionSheet: c0b62af44e610e69d9a2049a682f5dba4e9dff17
Expand Down
3 changes: 2 additions & 1 deletion examples/fabric/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
},
"dependencies": {
"react": "18.2.0",
"react-native": "0.72.3"
"react-native": "0.72.3",
"react-native-video": "../.."
},
"devDependencies": {
"@babel/core": "^7.20.0",
Expand Down
11 changes: 11 additions & 0 deletions examples/fabric/react-native.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
dependencies: {
'react-native-video': {
platforms: {
android: {
sourceDir: '../node_modules/react-native-video/android-exoplayer',
},
},
},
},
};

0 comments on commit 38efd95

Please sign in to comment.