0

Hello I have a streaming service, (it is an online radio) that I need to stream in my app, the url it is the following

https://cast.uncuartocomunicacion.com:8020/live

I have been using react native sound player to stream it but I had issues with android's performance. So I switched to react native track player, but I haven't been able of playing the streaming service.
the following it is the code I have been using.

const start = async () => {
    await TrackPlayer.setupPlayer();
    await TrackPlayer.add({
      id: 'trackI1',
      url: 'https://cast.uncuartocomunicacion.com:8020/live',
      title: 'Area deportiva',
      artist: 'Area deportiva',
      artwork: {
        uri:
          'https://pbs.twimg.com/profile_images/1480935488232075270/STi9FaUo_400x400.jpg',
      },
    });
    TrackPlayer.updateOptions({
      stopWithApp: false,
    });
    setLoading(false);
  };
  useEffect(() => {
    //let isMounted = true;

    //Alert.alert(audioUrl);
    //getUrl();
    //SoundPlayer.loadUrl('https://cast.uncuartocomunicacion.com:8020/live');
    /*TrackPlayer.setupPlayer()
      .then(() => {
        setLoading(false);
      })
      .catch((e) => {
        setLoading(false);
      });*/
    start()
      .then()
      .catch((e) => {
        Alert.alert('e ' + JSON.stringify(e));
      });
  }, []);

  const handlePlayPause = () => {
    console.warn('asa is playing ', isPlaying);

    /* */
    try {
      /* !isPlaying ? SoundPlayer.resume() : SoundPlayer.pause();*/
      if (!isPlaying) {
        Alert.alert('enre aquiu ');
        TrackPlayer.play()
          .then((r) => {
            Alert.alert('then play' + JSON.stringify(r));
          })
          .catch((e) => {
            Alert.alert('e ' + JSON.stringify(e));
          });
      } else {
        TrackPlayer.pause().then((r) => console.log(r));
      }
    } catch (e) {}

    setIsPlaying(!isPlaying);
  };

I hope someone can help me!!!

Alexc957
  • 61
  • 7

1 Answers1

0

For some reason when you play audio with SSL and use another port (8020) it doesn't work, but you can try using http and add

android:usesCleartextTraffic="true"

in AndroidManifest