Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

229
Views
el sonido nativo de reacción no funciona después de un tiempo

Estoy usando 50 archivos de sonido diferentes. funciona normalmente, pero en mi intento número 14 o 15 ya no reproduce los archivos de audio. (Estoy usando un dispositivo Android)

 const animalSound = new Sound( selectedAnimals.soundUrl ||"snake.mp3", null, error => { if (error) console.log("Can't play sound. ", error); }) const handlePlaySound = () => { animalSound.setVolume(1); animalSound.play(() => { animalSound.release(); }); }; const handleStopSound = id => { animalSound.stop() }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

expo-av para el sonido, que también se puede usar en un proyecto nativo de reacción. ( https://github.com/expo/expo/tree/main/packages/expo-av )

Hice este gancho que te permite reproducir el sonido y también aclara los recursos para que no tengas que preocuparte por eso.

 /* This hooks abstracts away all the logic of loading up and unloading songs. All the hook takes in is the require path of the audio */ import React,{useState,useEffect} from 'react' import { Audio } from 'expo-av'; const useSound = (path) => { /* Sound state */ const [sound, setSound] = useState(); /* Logic to unload sound when screen changes */ useEffect(() => { return sound ? () => { sound.unloadAsync(); } : undefined; }, [sound]); /* Memoize the function so that it does not get recomputed every time that the screen load */ const playSound = React.useCallback(async ()=>{ const { sound } = await Audio.Sound.createAsync(path); setSound(sound); await sound.playAsync(); },[sound]) /* Stop sound */ const stopSound = React.useCallback(async ()=>{ await sound.stopAsync(); },[sound]) return [playSound,stopSound] }

Todo lo que tienes que hacer para usar el sonido es esto

 /* The hooks returns a function to be called when to play a sound, and it abstracts away having to deal with unloading' the sound */ const [playSound,stopSound] = useSound(require("snake.mp3"));
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!