### Install react-native-audiowaveform Source: https://github.com/juananime/react-native-audiowaveform/blob/master/README.md Installs the react-native-audiowaveform package using npm. This is the first step to integrate the audio waveform component into your React Native project. ```bash npm install react-native-audiowaveform --save ``` -------------------------------- ### Enable Auto-Play Functionality for Audio Waveform Source: https://context7.com/juananime/react-native-audiowaveform/llms.txt Configures the WaveForm component to automatically start audio playback once it mounts. This is achieved by setting the `autoPlay` prop to `true`. The example also shows custom waveform colors and styling. ```javascript import React from 'react'; import { View, StyleSheet } from 'react-native'; import WaveForm from 'react-native-audiowaveform'; export default function AutoPlayAudio() { return ( ); } const styles = StyleSheet.create({ container: { flex: 1, padding: 20 }, waveform: { height: 100, backgroundColor: '#2C2C2C' } }); ``` -------------------------------- ### Display Remote Audio Waveform with Network Source Source: https://context7.com/juananime/react-native-audiowaveform/llms.txt Loads and displays an audio waveform from a remote URL. This example demonstrates using the `source` prop with a URI object and customizes the waveform colors for a distinct visual appearance. It supports network-based audio files. ```javascript import React from 'react'; import { View, StyleSheet } from 'react-native'; import WaveForm from 'react-native-audiowaveform'; export default function RemoteAudioPlayer() { return ( ); } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', padding: 20 }, waveform: { height: 120, backgroundColor: '#1E1E1E', borderRadius: 8 } }); ``` -------------------------------- ### Autoplay Waveform Source: https://github.com/juananime/react-native-audiowaveform/blob/master/README.md Enables autoplay for the audio waveform. When `autoPlay` is set to `true`, the audio will start playing automatically once the component mounts. ```javascript ``` -------------------------------- ### Basic Waveform Rendering (Local File) Source: https://github.com/juananime/react-native-audiowaveform/blob/master/README.md Renders the waveform of a local audio file with basic custom styling. The `waveColor` and `scrubColor` props allow customization of the waveform and scrubber colors respectively. ```javascript import WaveForm from 'react-native-audiowaveform'; ``` -------------------------------- ### Display Local Audio Waveform with Custom Styling Source: https://context7.com/juananime/react-native-audiowaveform/llms.txt Renders an audio waveform from a local MP3 file. It utilizes the WaveForm component with custom styling for wave and scrub colors. The component bridges native audio processing with React Native for visualization. ```javascript import React from 'react'; import { View, StyleSheet } from 'react-native'; import WaveForm from 'react-native-audiowaveform'; export default function AudioPlayer() { return ( ); } const styles = StyleSheet.create({ container: { flex: 1, padding: 20 }, waveform: { height: 100, backgroundColor: 'black' } }); ``` -------------------------------- ### Interactive Waveform with Play/Pause Source: https://github.com/juananime/react-native-audiowaveform/blob/master/README.md Creates an interactive waveform that can be played and paused. The `onPress` prop allows defining a callback function to handle touch events, and the `play` prop controls the playback state. ```javascript this.myMethodOnPress() } source={{uri:'https://url/path/to/the/file.mp3'}} play={true} /> ``` -------------------------------- ### Interactive Audio Player with Touch Control (JavaScript) Source: https://context7.com/juananime/react-native-audiowaveform/llms.txt This component demonstrates how to manage audio playback state (playing, stopped) using touch events on a waveform. It requires the react-native-audiowaveform library and basic React Native components. The component takes an audio source URI and controls playback via 'play' and 'stop' props, updating local state based on user interactions. ```javascript import React, { Component } from 'react'; import { View, StyleSheet, TouchableOpacity, Text } from 'react-native'; import WaveForm from 'react-native-audiowaveform'; export default class InteractiveAudioPlayer extends Component { constructor(props) { super(props); this.state = { isPlaying: false, isStopped: false }; } handlePress = () => { this.setState({ isPlaying: !this.state.isPlaying, isStopped: false }); } handleStop = () => { this.setState({ isStopped: true, isPlaying: false }); } render() { return ( Stop & Reset ); } } const styles = StyleSheet.create({ container: { flex: 1, padding: 20, backgroundColor: '#F5F5F5' }, waveform: { height: 120, backgroundColor: 'lightslategray', marginBottom: 20 }, button: { backgroundColor: '#FF4444', padding: 15, borderRadius: 8, alignItems: 'center' }, buttonText: { color: 'white', fontSize: 16, fontWeight: 'bold' } }); ``` -------------------------------- ### Display Multiple Audio Waveforms in Playlist (React Native) Source: https://context7.com/juananime/react-native-audiowaveform/llms.txt This snippet demonstrates how to render multiple audio waveforms for a playlist in a React Native application. It uses the WaveForm component to display audio visualization for each track, allowing users to select and play tracks. The component handles local and remote audio sources and manages playback state to highlight the currently playing track. ```javascript import React, { Component } from 'react'; import { ScrollView, View, StyleSheet, Text } from 'react-native'; import WaveForm from 'react-native-audiowaveform'; export default class AudioPlaylist extends Component { constructor(props) { super(props); this.state = { currentTrack: null, tracks: [ { id: 1, name: 'Track 1', source: require('./audio/track1.mp3') }, { id: 2, name: 'Track 2', source: require('./audio/track2.mp3') }, { id: 3, name: 'Track 3', source: {uri: 'https://example.com/audio/track3.mp3'} } ] }; } handleTrackPress = (trackId) => { this.setState({ currentTrack: trackId }); } render() { const { tracks, currentTrack } = this.state; return ( My Playlist {tracks.map((track) => ( {track.name} this.handleTrackPress(track.id)} source={track.source} play={currentTrack === track.id} stop={currentTrack !== track.id && currentTrack !== null} waveFormStyle={{ waveColor: currentTrack === track.id ? '#FF6B6B' : '#4ECDC4', scrubColor: '#FFE66D' }} /> ))} ); } } const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: '#F7F7F7' }, header: { fontSize: 24, fontWeight: 'bold', padding: 20, textAlign: 'center' }, trackContainer: { marginHorizontal: 15, marginBottom: 20, backgroundColor: 'white', borderRadius: 10, padding: 15, shadowColor: '#000', shadowOffset: { width: 0, height: 2 }, shadowOpacity: 0.1, shadowRadius: 4, elevation: 3 }, trackName: { fontSize: 16, fontWeight: '600', marginBottom: 10, color: '#333' }, waveform: { height: 80, backgroundColor: '#2C2C2C', borderRadius: 5 } }); ``` -------------------------------- ### Complete Audio Player with Play/Pause Toggle (JavaScript) Source: https://context7.com/juananime/react-native-audiowaveform/llms.txt This component provides a full audio player with play/pause toggle and stop functionality, including a visual waveform. It utilizes the react-native-audiowaveform library and manages audio states like playing, stopped, and finished. The component includes a custom audio source and handles playback completion callbacks. ```javascript import React, { Component } from 'react'; import { View, StyleSheet, TouchableOpacity, Text } from 'react-native'; import WaveForm from 'react-native-audiowaveform'; export default class FullAudioPlayer extends Component { constructor(props) { super(props); this.state = { playAudio: false, stopAudio: false, isFinished: false }; } togglePlayPause = () => { this.setState({ playAudio: !this.state.playAudio, stopAudio: false }); } stopAudio = () => { this.setState({ playAudio: false, stopAudio: true }); } handleFinishPlay = () => { this.setState({ playAudio: false, stopAudio: true, isFinished: true }); console.log('Audio playback finished'); } render() { const { playAudio, stopAudio, isFinished } = this.state; return ( Audio Waveform Player {playAudio ? 'Pause' : 'Play'} Stop {isFinished && ( Playback completed )} ); } } const styles = StyleSheet.create({ container: { flex: 1, padding: 20, backgroundColor: '#FFFFFF' }, title: { fontSize: 20, fontWeight: 'bold', marginBottom: 20, textAlign: 'center' }, waveform: { height: 150, backgroundColor: '#2C3E50', borderRadius: 10, marginBottom: 20 }, controls: { flexDirection: 'row', justifyContent: 'space-around' }, button: { paddingVertical: 12, paddingHorizontal: 30, borderRadius: 8, minWidth: 120, alignItems: 'center' }, playButton: { backgroundColor: '#27AE60' }, stopButton: { backgroundColor: '#E74C3C' }, buttonText: { color: 'white', fontSize: 16, fontWeight: '600' }, statusText: { marginTop: 20, textAlign: 'center', fontSize: 14, color: '#7F8C8D' } }); ``` -------------------------------- ### Waveform Rendering (Remote File) Source: https://github.com/juananime/react-native-audiowaveform/blob/master/README.md Renders the waveform of a remote audio file using its URL. The `source` prop accepts an object with a `uri` property for network audio files. ```javascript import WaveForm from 'react-native-audiowaveform'; ``` -------------------------------- ### Stopping Waveform Playback Source: https://github.com/juananime/react-native-audiowaveform/blob/master/README.md Provides functionality to stop and reset audio playback. Setting the `stop` prop to `true` halts the audio and resets its progress. This is typically controlled by component state. ```javascript this.myMethodWhereAfterPressIWillChangeStateStopAudioToTrue() } source={{uri:'https://url/path/to/the/file.mp3'}} stop={this.state.stopAudio? true:false} /> ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.