
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
The expo-av package is part of the Expo ecosystem and provides a comprehensive set of tools for handling audio and video playback in React Native applications. It allows developers to easily integrate multimedia functionalities such as playing, recording, and controlling audio and video files.
Audio Playback
This feature allows you to play audio files in your application. The code sample demonstrates how to load and play an audio file using the Audio module from expo-av.
import { Audio } from 'expo-av';
async function playSound() {
const { sound } = await Audio.Sound.createAsync(
require('./assets/sound.mp3')
);
await sound.playAsync();
}
Video Playback
This feature allows you to play video files in your application. The code sample demonstrates how to render a video component that plays a video from a given URI.
import { Video } from 'expo-av';
<Video
source={{ uri: 'https://www.example.com/video.mp4' }}
rate={1.0}
volume={1.0}
isMuted={false}
resizeMode="cover"
shouldPlay
style={{ width: 300, height: 300 }}
/>
Audio Recording
This feature allows you to record audio within your application. The code sample demonstrates how to request permissions, set the audio mode, and start recording audio using the Audio module from expo-av.
import { Audio } from 'expo-av';
async function recordAudio() {
await Audio.requestPermissionsAsync();
await Audio.setAudioModeAsync({ allowsRecordingIOS: true });
const recording = new Audio.Recording();
await recording.prepareToRecordAsync(Audio.RECORDING_OPTIONS_PRESET_HIGH_QUALITY);
await recording.startAsync();
// You are now recording!
}
react-native-video is a popular package for video playback in React Native applications. It provides a <Video> component that supports various video formats and offers extensive customization options. Compared to expo-av, react-native-video is more focused on video playback and does not include audio recording functionalities.
react-native-sound is a library for playing sound clips in React Native applications. It supports various audio formats and provides simple methods for playing, pausing, and stopping sounds. Unlike expo-av, react-native-sound does not support video playback or audio recording.
react-native-audio-toolkit is a comprehensive library for audio playback and recording in React Native applications. It offers features such as audio streaming, recording, and playback control. While it provides similar functionalities to expo-av, it does not support video playback.
Expo universal module for Audio and Video playback
For managed Expo projects, please follow the installation instructions in the API documentation for the latest stable release.
For bare React Native projects, you must ensure that you have installed and configured the expo
package before continuing.
npx expo install expo-av
Add android.permission.RECORD_AUDIO
permission to your manifest (android/app/src/main/AndroidManifest.xml
):
<uses-permission android:name="android.permission.RECORD_AUDIO" />
Add NSMicrophoneUsageDescription
key to your Info.plist
:
<key>NSMicrophoneUsageDescription</key>
<string>Allow $(PRODUCT_NAME) to access your microphone</string>
Run npx pod-install
after installing the npm package.
Contributions are very welcome! Please refer to guidelines described in the contributing guide.
FAQs
Expo universal module for Audio and Video playback
The npm package expo-av receives a total of 355,564 weekly downloads. As such, expo-av popularity was classified as popular.
We found that expo-av demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 9 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.