How to use the react-native-track-player.skipToNext function in react-native-track-player

To help you get started, we’ve selected a few react-native-track-player examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ferrannp / react-native-spotify-streamer / player-handler.js View on Github external
async function playerHandler(dispatch: DispatchType, data: Data) {
  switch (data.type) {
    // Forward remote events to the player
    case 'remote-play':
      TrackPlayer.play();
      break;
    case 'remote-pause':
      TrackPlayer.pause();
      break;
    case 'remote-stop':
      TrackPlayer.stop();
      break;
    case 'remote-next':
      TrackPlayer.skipToNext();
      break;
    case 'remote-previous':
      TrackPlayer.skipToPrevious();
      break;
    case 'remote-seek':
      TrackPlayer.seekTo(data.position);
      break;
    // You can make ducking smoother by adding a fade in/out
    case 'remote-duck':
      TrackPlayer.setVolume(data.ducking ? 0.5 : 1);
      break;
    // Playback updates
    case 'playback-state': {
      dispatch(playbackState(data.state));
      break;
    }
github AbelTesfaye / dingo / src / BL / Services / event-handler-service.js View on Github external
if (data.state == TrackPlayer.STATE_PAUSED) {
			console.log('STATE_PAUSED');
		}
		if (data.state == TrackPlayer.STATE_STOPPED) {
			console.log('STATE_STOPPED');
		}
		if (data.state == TrackPlayer.STATE_BUFFERING) {
			console.log('STATE_BUFFERING');
			_fetchURLs(false, 1, 1, () => {}, () => {});
		}
	} else if (data.type == 'remote-play') {
		TrackPlayer.play();
	} else if (data.type == 'remote-pause') {
		TrackPlayer.pause();
	} else if (data.type == 'remote-next') {
		TrackPlayer.skipToNext();
	} else if (data.type == 'remote-previous') {
		TrackPlayer.skipToPrevious();
	} else if (data.type == 'remote-seek') {
		TrackPlayer.seekTo(data.position);
	} else if (data.type == 'remote-duck') {
		if (data.paused) TrackPlayer.pause();
		if (data.permanent) TrackPlayer.stop();
		if (data.ducking) {
			const prevVolume = await TrackPlayer.getVolume();
			TrackPlayer.setVolume(0.1);

			BackgroundTimer.setTimeout(() => {
				TrackPlayer.setVolume(prevVolume);
			}, 3 * 1000);
		}
	}
github m-inan / react-native-music-app / src / provider / service.js View on Github external
async function Handler(dispatch) {
	TrackPlayer.addEventListener('remote-play', () =>
		dispatch(setUserPlaying(true))
	)

	TrackPlayer.addEventListener('remote-pause', () =>
		dispatch(setUserPlaying(false))
	)

	TrackPlayer.addEventListener('remote-stop', () => {
		dispatch(setUserPlaying(false))
		TrackPlayer.stop()
	})

	TrackPlayer.addEventListener('remote-next', () => TrackPlayer.skipToNext())

	TrackPlayer.addEventListener('remote-previous', async () => {
		const time = await TrackPlayer.getPosition()

		if (time <= 3) {
			TrackPlayer.skipToPrevious()
		} else {
			TrackPlayer.seekTo(0)
		}
	})

	TrackPlayer.addEventListener('remote-seek', ({ position }) =>
		TrackPlayer.seekTo(position)
	)

	if (Platform.OS !== 'ios') {
github react-native-kit / react-native-track-player / example / react / screens / PlaylistScreen.js View on Github external
async function skipToNext() {
  try {
    await TrackPlayer.skipToNext();
  } catch (_) {}
}
github m-inan / react-native-music-app / src / reducers / Player / handler.js View on Github external
async function Handler(dispatch, data) {
	switch (data.type) {
		case 'remote-play':
			TrackPlayer.play()
			break
		case 'remote-pause':
			TrackPlayer.pause()
			break
		case 'remote-stop':
			TrackPlayer.stop()
			break
		case 'remote-next':
			TrackPlayer.skipToNext()
			break
		case 'remote-previous':
			TrackPlayer.skipToPrevious()
			break
		case 'remote-seek':
			TrackPlayer.seekTo(data.position)
			break
		case 'remote-duck':
			TrackPlayer.setVolume(data.ducking ? 0.5 : 1)
			break
		case 'playback-state':
			dispatch(playbackState(data.state))
			break
		case 'playback-track-changed':
			dispatch(playbackTrack(data.nextTrack))
github react-native-kit / react-native-track-player / example / service.js View on Github external
TrackPlayer.addEventListener('remote-next', () => {
    TrackPlayer.skipToNext()
  });
github ThalKod / react-native-music-player / src / screens / NowPlaying.js View on Github external
const skipToNext = async () => {
    try {
      await TrackPlayer.skipToNext();
    } catch (_) {}
  };