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 #87

Open
gh-pro opened this issue Jun 3, 2024 · 0 comments
Open

[iOS] Stream error on specific audio #87

gh-pro opened this issue Jun 3, 2024 · 0 comments

Comments

@gh-pro
Copy link

gh-pro commented Jun 3, 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant