Comments (4)
https://docs.expo.dev/versions/latest/sdk/video-av/
The format of the url should contain the .mp4. Something like this https://yourserver.com/path/to/video.mp4
Vimeo or Youtube doesn't support it, if you want to use it from Vimeo, you need to use their API
from aora.
Hi there,
I have the same problem. I don't have a solution for you but it seems like the url videos are broken? I mean i can play them in my browser but for some reasons they are not playing on my device (iPhone 13 Pro Max running ios 18 beta 3), but if I use another url for the videos they work.
from aora.
You can also use react-native-webview if you prefer to use something other than the API route for embedded videos. This allows you to easily use embed videos from platforms like YouTube and Vimeo directly within your React Native application. I implemented logic to detect whether the video URL is a direct or embedded link. Depending on the result, the component renders the Video component (for direct links) or a WebView (for embedded videos).
Additionally, you'll need to apply similar changes to your app's VideoCard
component to handle embedded videos correctly.
- Make sure to install react-native-webview in your terminal. Below is an example of how I implemented this in my Trending component:
import { ResizeMode, Video } from "expo-av";
import * as Animatable from "react-native-animatable";
import {
FlatList,
Image,
ImageBackground,
TouchableOpacity,
View,
Dimensions,
} from "react-native";
import { WebView } from "react-native-webview";
import { icons } from "../constants";
const zoomIn = {
0: {
scale: 0.9,
},
1: {
scale: 1,
},
};
const zoomOut = {
0: {
scale: 1,
},
1: {
scale: 0.9,
},
};
const isEmbeddedVideo = (url) => {
return url.includes("youtube.com") || url.includes("vimeo.com");
};
const TrendingItem = ({ activeItem, item }) => {
const [play, setPlay] = useState(false);
const isEmbedded = isEmbeddedVideo(item.video);
const itemStyle = {
width: Dimensions.get("window").width * 0.55,
height: Dimensions.get("window").height * 0.45,
borderRadius: 33,
overflow: "hidden",
marginTop: 15,
backgroundColor: "rgba(255, 255, 255, 0.1)",
};
return (
<Animatable.View
style={{ marginRight: 20 }}
animation={activeItem === item.$id ? zoomIn : zoomOut}
duration={500}
>
{play ? (
isEmbedded ? (
<View style={itemStyle}>
<WebView
source={{ uri: item.video }}
style={{ flex: 1 }}
allowsInlineMediaPlayback={true}
javaScriptEnabled={true}
allowsFullscreenVideo={true}
scalesPageToFit={true}
startInLoadingState={true}
/>
</View>
) : (
<View style={itemStyle}>
<Video
source={{ uri: item.video }}
style={{ flex: 1 }}
useNativeControls
resizeMode={ResizeMode.COVER}
shouldPlay
onPlaybackStatusUpdate={(status) => {
if (status.didJustFinish) {
setPlay(false);
}
}}
onError={(error) => {
console.error("Video error:", error);
setPlay(false);
}}
/>
</View>
)
) : (
<TouchableOpacity
style={itemStyle}
activeOpacity={0.7}
onPress={() => setPlay(true)}
>
<ImageBackground
source={{ uri: item.thumbnail }}
style={{ width: "100%", height: "100%" }}
resizeMode="cover"
>
<View
style={{
justifyContent: "center",
alignItems: "center",
flex: 1,
}}
>
<Image
source={icons.play}
style={{ width: 48, height: 48 }}
resizeMode="contain"
/>
</View>
</ImageBackground>
</TouchableOpacity>
)}
</Animatable.View>
);
};
const Trending = ({ posts }) => {
const [activeItem, setActiveItem] = useState(posts[0]);
const viewableItemsChanged = ({ viewableItems }) => {
if (viewableItems.length > 0) {
setActiveItem(viewableItems[0].key);
}
};
return (
<FlatList
data={posts}
horizontal
keyExtractor={(item) => item.$id}
renderItem={({ item }) => (
<TrendingItem activeItem={activeItem} item={item} />
)}
onViewableItemsChanged={viewableItemsChanged}
viewabilityConfig={{
itemVisiblePercentThreshold: 70,
}}
contentOffset={{ x: 170 }}
/>
);
};
export default Trending;
from aora.
Weird, for me its any URL, it only works if I download a video and put the file path name as the source.
from aora.
Related Issues (20)
- Font not working properly on android HOT 2
- AppwriteException: Network request failed HOT 3
- recieving this error 'Module "3" is missing from the asset registry' HOT 2
- Render Error Module "23" is missing HOT 8
- [AppwriteException: Network request failed] HOT 1
- fontFamily "Poppins-SemiBold" is not a system font and has not been loaded through expo-font. HOT 2
- Creation of a session is prohibited when a session is active HOT 16
- Warning: Each child in a list should have a unique "key" prop. HOT 2
- AppwiteException:Missing required parameter: "bucketId"
- Can't setup Nativewind for the app! HOT 2
- Video playback error: db.w0: None of the available extractors (c, d, b, g, k, b, a0, d, h0, e, h, b, e, f, b, a) could read the stream. HOT 3
- ' WARN Layout children must be of type Screen, all other children are ignored. To use custom children, create a custom <Layout />. Update Layout Route at: "app/(tabs)/_layout"' HOT 1
- ERROR TypeError: Cannot read property 'username' of null after registration new user and login
- [Error: AppwriteException: User (role: guests) missing scope (account)] HOT 9
- AppwriteException: Searching by attribute "title" requires a fulltext index HOT 1
- Render Error - Cannot read property of "isLoading" of undefined HOT 1
- Expo app crashing after splash / login screen but it's perfectly on expo go development mode
- Property 'setUser' doesn't exist HOT 1
- Black bar above the nav/tab bar.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aora.