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

Play function stops working after playing multiple videos #825

Open
4 of 5 tasks
chilliapplegit opened this issue Apr 12, 2023 · 1 comment
Open
4 of 5 tasks

Play function stops working after playing multiple videos #825

chilliapplegit opened this issue Apr 12, 2023 · 1 comment
Labels

Comments

@chilliapplegit
Copy link

chilliapplegit commented Apr 12, 2023

🪲 Description

I have a audio tour player which plays multiple audios based on different Components,
The players works perfectly for sometimes nearly 13-15 times it works properly after that, the player breaks down.

🪲 What is the observed behavior?

The callback for play function (enEnd) gets executed without the audio being played.
no actual sounds gets played but the play functions callback occurs and provide true value

🪲 What is the expected behavior?

it should play the audio first and post aying it fully then only it should be proiding the outcome of true or false in callback value

🪲 Please post your code:

const fetchAudiofile = async () => {
    if (currentTour?.data?.advancedSettings.assets?.audio?.name) {
      await Database.getStoredAsset(
        assetPath,
        currentTour.data.advancedSettings.assets.audio.name
      )
        .then((imageURL) => {
          const dataReceived = new Sound(imageURL, "", (error) => {
            if (error) {
              console.log("failed to load the sound", error);
              return;
            }
            setIsPlaying(true);
            setIsFinished(false);

            console.log(
              `duration in seconds: ${dataReceived.getDuration()}number of channels: ${dataReceived.getNumberOfChannels()}`
            );

            setAudioPlayer(dataReceived);

            dataReceived.play((success) => {
              if (success) {
                switch (currentTour.data.advancedSettings.choice_type) {
                  case "choice_single":
                  case "choice_double": {
                    setIsPlaying(false);
                    setIsFinished(true);
                    console.log(
                      "Successfully loaded ADHomeScreen with new audio file :>> "
                    );
                    break;
                  }
                  case "instruction":
                  default: {
                    playPauseAudioAction("stop");
                    loadNextTour(
                      currentTour.data.advancedSettings.listItems[0].link
                    );
                    setAudioPlayer(null);
                    break;
                  }
                }
              } else {
                console.log(
                  "Error loading ADHomeScreen with new audio file :>> "
                );
              }
            });
          });
        })
        .catch((e) => {
          console.log("error with List image: ", e);
        });
    }
  };

💡 Does the problem have a test case?

💡 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

Are you using...

  • React Native CLI (e.g. react-native run-android)

Which versions are you using?

  • React Native Sound: "^0.11.2"
  • React Native: "^0.63.5"
  • Android: 13

Does the problem occur on...

  • Simulator
  • Device

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

  • Device:
    Oneplus Nord Android 12
@chilliapplegit chilliapplegit changed the title play function stop working after playing muktiple videos Play function stops working after playing multiple videos Apr 12, 2023
@kukadiyaAni
Copy link

Same issue for me, any solutions?

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

3 participants
@kukadiyaAni @chilliapplegit and others