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

[Question] Use with "react-native-track-player" #31

Closed
Rapsssito opened this issue Aug 5, 2020 · 4 comments
Closed

[Question] Use with "react-native-track-player" #31

Rapsssito opened this issue Aug 5, 2020 · 4 comments
Labels
good first issue Good for newcomers question Question about any part of the module

Comments

@Rapsssito
Copy link
Owner

Rapsssito commented Aug 5, 2020

Thanks for this great library! You comment about of "react-native-track-player", but i dont see any example with this two library together. do you have idea how implement? Thanks

Originally posted by @robertfernanV in #8 (comment)

@Rapsssito Rapsssito added the question Question about any part of the module label Aug 5, 2020
@Rapsssito
Copy link
Owner Author

@robertfernanV, this example might help you:

/**
 * It must be called before the app is in the background so it can register the event listener.
 */
const backgroundTask = async () => {
    await new Promise((resolve) => {
        // Playing listeners
        const listenerChange = TrackPlayer.addEventListener('playback-state', (newState) => {
            // Do stuff
            if (newState.state === TrackPlayer.STATE_PLAYING) {
                // Play button
            } else if (newState.state === TrackPlayer.STATE_PAUSED) {
                // Pause button
            }
        });
    });
};

@robertfernanV
Copy link

robertfernanV commented Aug 5, 2020

@Rapsssito thanks for answering! i going to try it.

@Rapsssito Rapsssito pinned this issue Aug 16, 2020
@Rapsssito Rapsssito changed the title Use with "react-native-track-player" [Question] Use with "react-native-track-player" Aug 16, 2020
@Rapsssito Rapsssito added the good first issue Good for newcomers label Aug 16, 2020
@ntvinhit
Copy link

Hi @robertfernanV and @Rapsssito

Will Apple reject this because we are using the dirty trick to "trick" Apple device?

@Rapsssito
Copy link
Owner Author

@ntvinhit, this will indeed result in a rejection if audio is not necessary for the app. However, the question is about an example code with "react-native-track-player", use it at your own risk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers question Question about any part of the module
Projects
None yet
Development

No branches or pull requests

3 participants