Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error => {"extra": -1330794744, "what": -1003} #846

Open
3 of 8 tasks
devnshankar opened this issue Aug 14, 2024 · 1 comment
Open
3 of 8 tasks

Error => {"extra": -1330794744, "what": -1003} #846

devnshankar opened this issue Aug 14, 2024 · 1 comment
Labels

Comments

@devnshankar
Copy link

🪲 This particular error persisting in react native sound

🪲 react-native-sound unable to stream audio from an url

🪲 As usual i used the react-native-sound package with my react native application to play a remote music i had hosted from my node js server using express which was working absolutely fine in postman or any other browser i was using ngrok to make that global so that i can querry from the mobile device but the problem was that i was unable to do so.

🪲 Previously i used to use a local path to the audio file and it used to work just fine but this time i wanted to stream the audio from the internet from a server this is what i was trying to achieve

import React, { useState } from 'react';
import { View, Text, Button, StyleSheet } from 'react-native';
import Sound from 'react-native-sound';

const AudioPlayerCard = () => {
  const [sound, setSound] = useState(null);
  const [isPlaying, setIsPlaying] = useState(false);

  const audioUrl = 'https://marshmello-bubbles.ngrok-free.app/assets/quran.wav';

  const loadSound = () => {
    const newSound = new Sound(audioUrl, Sound.MAIN_BUNDLE, (error) => {
      if (error) {
        console.log('Failed to load the sound', error);
        return;
      }
      setSound(newSound);
      playSound();
    });
  };

  const playSound = () => {
    if (sound) {
      sound.play((success) => {
        if (success) {
          console.log('Successfully finished playing');
        } else {
          console.log('Playback failed due to audio decoding errors');
        }
        setIsPlaying(false);
      });
      setIsPlaying(true);
    } else {
      loadSound();
    }
  };

  const pauseSound = () => {
    if (sound && isPlaying) {
      sound.pause();
      setIsPlaying(false);
    }
  };

  const stopSound = () => {
    if (sound) {
      sound.stop(() => {
        setIsPlaying(false);
      });
    }
  };

  return (
    <View style={styles.card}>
      <Text style={styles.title}>Audio Player</Text>
      <View style={styles.buttonContainer}>
        <Button title="Play" onPress={playSound} />
        <Button title="Pause" onPress={pauseSound} disabled={!isPlaying} />
        <Button title="Stop" onPress={stopSound} />
      </View>
    </View>
  );
};

const styles = StyleSheet.create({
  card: {
    padding: 20,
    margin: 10,
    backgroundColor: '#fff',
    borderRadius: 10,
    elevation: 3,
    shadowColor: '#000',
    shadowOffset: { width: 0, height: 2 },
    shadowOpacity: 0.1,
    shadowRadius: 4,
  },
  title: {
    fontSize: 18,
    marginBottom: 10,
    fontWeight: 'bold',
  },
  buttonContainer: {
    flexDirection: 'row',
    justifyContent: 'space-between',
  },
});

export default AudioPlayerCard;

💡 Does the problem have a test case?

LOG  Failed to load the sound {"extra": -2147483648, "what": 1}
 LOG  Failed to load the sound {"extra": -2147483648, "what": 1}
 LOG  Failed to load the sound {"extra": -2147483648, "what": 1}
 LOG  Failed to load the sound {"extra": -2147483648, "what": 1}
 LOG  Failed to load the sound {"extra": -2147483648, "what": 1}
 LOG  Failed to load the sound {"extra": -2147483648, "what": 1}
 LOG  Failed to load the sound {"extra": -2147483648, "what": 1}


💡 Possible solution

💡 Is there a workaround?

💡 If the bug is confirmed, would you be willing to create a pull request?

Is your issue with...

  • iOS
  • Android
  • Windows

Are you using...

  • React Native CLI (e.g. react-native run-android)
  • Expo
  • Other: (please specify)

Which versions are you using?

  • React Native Sound: "^0.11.2"
  • React Native: "0.74.5"
  • iOS: NA
  • Android: 11
  • Windows: NA
  • Linux(Ubuntu): Ubuntu 24.04 LTS x86_64

Does the problem occur on...

  • Simulator
  • Device

If your problem is happening on a device, which device?

  • Device: SMA50
@Okelm
Copy link

Okelm commented Nov 25, 2024

It seems you want to play a static file from the internet and this should be fine with this library. wav. is not an actual streaming format :) Can you update here where you are with the issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants