doublesymmetry / react-native-track-player

A fully fledged audio module created for music apps. Provides audio playback, external media controls, background mode and more!
https://rntp.dev/
Apache License 2.0
3.25k stars 1k forks source link

[iOS] Stream error on specific audio #2316

Open gh-pro opened 4 months ago

gh-pro commented 4 months ago

Describe the Bug An error occured while playing the current track. {"error": "L’opération n’a pas pu s’achever. (SwiftAudioEx.AudioPlayerError.PlaybackError erreur 1.)", "type": "playback-error"}

Steps To Reproduce After play music an error and no sound only certain audio formats

Code To Reproduce `import React, {useEffect, useState} from 'react'; import { Box, Button, useColorMode, Text, ScrollView, } from 'native-base'; import {useIsFocused, useNavigation} from '@react-navigation/native'; import TrackPlayer, { useTrackPlayerEvents, Event } from 'react-native-track-player';

// Subscribing to the following events inside MyComponent const events = [ Event.PlaybackState, Event.PlaybackError, ]; function HomeScreen() { const {colorMode} = useColorMode(); const isFocused = useIsFocused(); const [radiosList, setRadiosList] = useState([]); const [isLoad, setLoad] = useState(true);

async function trackPlayerInit() { try { await TrackPlayer.setupPlayer(); return true; } catch (error) { return false; } }

async function initTrackPlayer() { await trackPlayerInit(); const radioPLayer = radiosList.map((index, key) => { return { url: index.url, // Load media from the file system title: index.name, }; }); await TrackPlayer.add(radioPLayer); console.warn('ok loaded'); }

useEffect(() => { if (radiosList.length > 0) { console.warn('ok init trackplayer: ');

  initTrackPlayer();
}

return () => {
  TrackPlayer.reset();
};

}, [isFocused, radiosList]);

useTrackPlayerEvents(events, (event) => { if (event.type === Event.PlaybackError) { console.warn('An error occured while playing the current track.', event); } if (event.type === Event.PlaybackState) { // setPlayerState(event.state); } });

useEffect(() => { console.warn('ok focus'); init(); }, [isFocused]);

return ( <Box safeArea bg={colorMode === 'light' ? 'coolGray.50' : 'trueGray.900'} flex={1}>

{!isLoad && ( {radiosList.map((index, key) => { return ( ); })} )}
</Box>

); }

export default HomeScreen; `

Replicable on Example App? Can you replicate this bug in the React Native Track Player Example App? yes i reproduce

Environment Info: Paste the results of `info Fetching system and libraries information... System: OS: macOS 13.6 CPU: (10) arm64 Apple M2 Pro Memory: 139.11 MB / 16.00 GB Shell: version: "5.9" path: /bin/zsh Binaries: Node: version: 21.7.3 path: /opt/homebrew/bin/node Yarn: version: 1.22.19 path: /opt/homebrew/bin/yarn npm: version: 10.5.0 path: /opt/homebrew/bin/npm Watchman: version: 2024.05.06.00 path: /opt/homebrew/bin/watchman Managers: CocoaPods: version: 1.15.2 path: /Users/User1/.rbenv/shims/pod SDKs: iOS SDK: Platforms:

How I can Help What can you do to help resolve this? I don't know... Have you investigated the underlying JS or Swift/Android code causing this bug? No Can you create a Pull Request with a fix? No

lovegaoshi commented 4 months ago

hows anyone supposed to help if u dont post the media source if it happens to that specific media

gh-pro commented 4 months ago

hows anyone supposed to help if u dont post the media source if it happens to that specific media

Hello, yes, is a radio stream link => http://91.121.29.128:8068/stream

lovegaoshi commented 4 months ago

u cant use http in android prod unless apecially configed

On Mon, Jun 3, 2024, 4:14 AM gh-pro @.***> wrote:

hows anyone supposed to help if u dont post the media source if it happens to that specific media

Hello, yes, is a radio stream link => http://91.121.29.128:8068/stream

— Reply to this email directly, view it on GitHub https://github.com/doublesymmetry/react-native-track-player/issues/2316#issuecomment-2144930463, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZMOVVRNZCAM2QPLMJXHVULZFRF3BAVCNFSM6AAAAABIFJNPLKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNBUHEZTANBWGM . You are receiving this because you commented.Message ID: @.*** com>

gh-pro commented 4 months ago

u cant use http in android prod unless apecially configed On Mon, Jun 3, 2024, 4:14 AM gh-pro @.> wrote: hows anyone supposed to help if u dont post the media source if it happens to that specific media Hello, yes, is a radio stream link => http://91.121.29.128:8068/stream — Reply to this email directly, view it on GitHub <#2316 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZMOVVRNZCAM2QPLMJXHVULZFRF3BAVCNFSM6AAAAABIFJNPLKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNBUHEZTANBWGM . You are receiving this because you commented.Message ID: @. com>

its work i add android:usesCleartextTraffic="true"

lovegaoshi commented 4 months ago

oh u meant ios. please tag that either with an issue tag or put that in the issue title. and try the url with https://github.com/DoubleSymmetry/SwiftAudioEx to post/investigate the native error bug first.

marcpassarelli commented 3 months ago

@gh-pro I never tried using an HTTP within react-native-track-player in iOS but I did have problems before in other portions of my app, like calling our dev API or even passing an HTTP link as a Lunch URL in a notification through OneSignal, so maybe it is because of that

can you try doing what's suggested in this stack overflow answer? https://stackoverflow.com/a/32560433/15986662

gh-pro commented 3 months ago

Hello, yes i try, and not success.

gh-pro commented 3 months ago

But i, added this, and its works. "NSAllowsArbitraryLoads"

can you, add this require setting on the repos ? thanks you.

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key><true/>
    <key>NSExceptionDomains</key>
    <dict>
        <key>localhost</key>
        <dict>
            <key>NSExceptionAllowsInsecureHTTPLoads</key>
            <true/>
        </dict>
    </dict>
</dict>
gh-pro commented 3 months ago

Hello, i have same issue on this url https://rereunion.ice.infomaniak.ch/rereunion-64.aac

prateekchachra commented 1 week ago

Hi @gh-pro , I tried replicating the issue with your URL and it works fine with .aac, can you provide more detail on when it happens?