Comments (7)
I am facing the same issue (using react-native: 0.72.15). Downgrading to 4.0.0-rc04
fixes the issue for me which shows it's not a network issue...
from react-native-track-player.
I have the same problem, does the current version work on Android for anyone?
from react-native-track-player.
try snipping the media src network request first with eg HTTPToolkit
from react-native-track-player.
We are having the same problem with RN 0.72.15. 😬 Any updates on this issue?
from react-native-track-player.
@Brightbong92 did you find any solution to this?
from react-native-track-player.
@c-goettert
I am sharing the method that I have solved.
"react-native": "0.74.1",
"react-native-track-player": "^4.1.1",
// useSetupPalyer.ts
import { useEffect, useState } from 'react';
import TrackPlayer from 'react-native-track-player';
import { SetupService } from '@/utils/track-player';
export interface UseSetupPlayerProps {
cb?: () => Promise<void>;
}
export function useSetupPlayer({ cb }: UseSetupPlayerProps) {
const [isPlayerReady, setIsPlayerReady] = useState<boolean>(false);
useEffect(() => {
let unmounted = false;
(async () => {
await SetupService();
if (unmounted) return;
setIsPlayerReady(true);
const queue = await TrackPlayer.getQueue();
if (unmounted) return;
if (queue.length <= 0) {
cb && cb();
}
})();
return () => {
unmounted = true;
};
}, []);
return isPlayerReady;
}
// useHooks.ts
const track1 = {
url, // Load media from the network
title: 'Avaritia',
artist: 'deadmau5',
album: 'while(1<2)',
genre: 'Progressive House, Electro House',
date: '2014-05-20T07:00:00+00:00', // RFC 3339
artwork: 'https://example.com', // Load artwork from the network
duration: 0, // Duration in seconds
};
...
const addPlayer = useCallback(async () => {
await TrackPlayer.add([track1]);
}, []);
const isPlayerReady = useSetupPlayer({ cb: addPlayer });
...
return {
...
isReady: isPlayerReady
...
};
// view.tsx
...
const {isReady} = useHooks();
...
return (
{
isReady ? <Text>show</Text> : <Text>loading...</Text>
}
)
from react-native-track-player.
Thanks for posting you solution @Brightbong92 . Indeed I found out that for me it was something else that has caused the bug: I was calling TrackPlayer.reset()
immediately before starting the Player without waiting for it. Something like:
...
await TrackPlayer.setupPlayer()
...
TrackPlayer.reset()
...
await TrackPlayer.add([track])
TrackPlayer.play()
As the reset call is asynchronous it also removed the track I added to the queue immediately after the call. I could fix it by adding an await
to the reset function (it returns a promise). This issue can be closed from my perspective.
from react-native-track-player.
Related Issues (20)
- App stopped to execute code after reopening HOT 2
- TrackPlayer.reset() giving Error occurred: The operation couldn’t be completed. (OSStatus error -50.) in Xcode Terminal
- Audio stopped playing after 17.5.1 IOS update HOT 11
- Remove currentTrack HOT 4
- [administrative] maintenance status HOT 3
- Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
- [Feature Request] The example code for setting up the player is complicated and docs are insufficient - can you take the example setup code and productize it?
- IOS. Buffering takes too long or ends in an error
- It shows null in notification panel
- Duration return 0 when changing the track get from response on my server in IOS
- Issue with HLS Buffer in TrackPlayer - Playback Starting at Advanced
- [Feature Request] (Question) seekTo without pausing other media? HOT 1
- ERROR TypeError: taskProvider() is not a function (it is undefined), js engine: hermes HOT 1
- [Feature Request] Headless start from aa
- Unable to play and load from url HOT 4
- I face this issue can not play url audio, please help me HOT 2
- API calls on Android fail with "The player is not initialized. Call setupPlayer first." HOT 9
- Notification disappears on Android for HLS tracks
- [iOS] s3 wav audio url is not playing on iOS Simulator HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-track-player.