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

[iOS] Stream error on specific audio #2316

Open
gh-pro opened this issue May 23, 2024 · 11 comments
Open

[iOS] Stream error on specific audio #2316

gh-pro opened this issue May 23, 2024 · 11 comments
Labels

Comments

@gh-pro
Copy link

gh-pro commented May 23, 2024

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 (
<Button
onPress={async () => {
await TrackPlayer.skip(key);
console.warn('ok played');
TrackPlayer.play();
const trackIndex = await TrackPlayer.getActiveTrackIndex();
const trackData = await TrackPlayer.getTrack(trackIndex);
console.warn(
'ok track: ',
trackData
);
}}>
{index.name}

);
})}

)}


);
}

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: - DriverKit 23.2 - iOS 17.2 - macOS 14.2 - tvOS 17.2 - visionOS 1.0 - watchOS 10.2 Android SDK: API Levels: - "28" - "29" - "30" - "31" - "32" - "33" - "33" - "33" - "34" Build Tools: - 29.0.2 - 30.0.2 - 30.0.3 - 31.0.0 - 32.0.0 - 33.0.0 - 33.0.1 - 34.0.0 System Images: - android-16 | Intel x86 Atom - android-16 | Google APIs ARM EABI v7a - android-16 | Google APIs Intel x86 Atom - android-29 | Google Play ARM 64 v8a - android-31 | Google TV Intel x86 Atom - android-31 | Google APIs ARM 64 v8a - android-33 | Google APIs ARM 64 v8a - android-33 | Google APIs Intel x86_64 Atom Android NDK: Not Found IDEs: Android Studio: 2023.2 AI-232.10227.8.2321.11479570 Xcode: version: 15.2/15C500b path: /usr/bin/xcodebuild Languages: Java: version: 17.0.10 path: /usr/bin/javac Ruby: version: 2.7.6 path: /Users/User1/.rbenv/shims/ruby npmPackages: "@react-native-community/cli": Not Found react: installed: 18.2.0 wanted: 18.2.0 react-native: installed: 0.72.6 wanted: 0.72.6 react-native-macos: Not Found npmGlobalPackages: "*react-native*": Not Found Android: hermesEnabled: true newArchEnabled: false iOS: hermesEnabled: true newArchEnabled: false
Paste the exact react-native-track-player version you are using 4.1.1
Real device? Or simulator? Real device
What OS are you running? iOS 17.1

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

@gh-pro gh-pro added the Bug label May 23, 2024
@lovegaoshi
Copy link
Contributor

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

@gh-pro
Copy link
Author

gh-pro commented Jun 3, 2024

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
Copy link
Contributor

lovegaoshi commented Jun 3, 2024 via email

@gh-pro
Copy link
Author

gh-pro commented Jun 3, 2024

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
Copy link
Contributor

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.

@gh-pro gh-pro changed the title Stream error on specific audio [iOS] Stream error on specific audio Jun 3, 2024
@marcpassarelli
Copy link

marcpassarelli commented Jun 10, 2024

@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
Copy link
Author

gh-pro commented Jun 16, 2024

Hello, yes i try, and not success.

@gh-pro
Copy link
Author

gh-pro commented Jun 16, 2024

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 gh-pro closed this as completed Jun 16, 2024
@gh-pro
Copy link
Author

gh-pro commented Jun 19, 2024

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

@gh-pro gh-pro reopened this Jun 19, 2024
@prateekchachra
Copy link
Contributor

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?

@jr00n
Copy link

jr00n commented Nov 11, 2024

I had the same issue, but only on the iOS Simulator en TrackPater 4.1.1 not on a real iPhone. When I changed to https:// the error was gone on the simulator with this url https://icecast.omroep.nl/3fm-bb-mp3

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

5 participants