14.9 C
New York
Tuesday, November 19, 2024

React Native Observe Participant ios Troubleshooting constructing 100%


I am growing a React Native app utilizing react-native-track-player for audio playback. The app works completely wonderful on Android, however I am dealing with points on iOS. Particularly, when constructing and operating the app, it freezes at “Constructing 100%” and ultimately crashes with the next error:

com.fb.react.runtime.JavaScript (9): EXC_BAD_ACCESS (code=1, deal with=0x0)

Screenshot
enter image description here

The error happens when i add

await TrackPlayer.setupPlayer(); 

to the code.

That is my code :

import React, { useEffect } from 'react';
import { View, Button } from 'react-native';
import TrackPlayer,{ Functionality } from 'react-native-track-player';

const AudioPlayer: React.FC = () => {
  useEffect(() => {
    const setupPlayer = async () => {
      await TrackPlayer.setupPlayer();

      // Ajout de la piste
      const audioPath = require('../../property/audio/teddy.mp3');
      await TrackPlayer.add({
        id: 'trackId',
        url: audioPath,
        title: 'Teddy Audio',
        artist: 'Inconnu',
        paintings: 'https://www.instance.com/paintings.jpg',
      });

      // Configure les contrôles de notification
      TrackPlayer.updateOptions({
        
        capabilities: [
          Capability.Play,
          Capability.Pause,
          Capability.Stop,
        ],
        compactCapabilities: [
          Capability.Play,
          Capability.Pause,
        ],
        notificationCapabilities: [
          Capability.Play,
          Capability.Pause,
          Capability.Stop,
        ],
      });
    };

    setupPlayer();

    return () => {
      TrackPlayer.cease();
    };
  }, []);

  const playAudio = async () => {
    await TrackPlayer.play();
  };

  const pauseAudio = async () => {
    await TrackPlayer.pause();
  };

  return (
    
      

Has anybody else skilled the same challenge or discovered an answer?

Here’s what I’ve tried to date:

  1. Wrapped the setup in a try-catch block to seize any potential errors.
  2. Verified compatibility with my React Native and react-native-track-player variations.
  3. Ensured needed permissions and configurations are set for Android and iOS.
  4. add dummy.swift file

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles