How to use the react-native-track-player.STATE_PAUSED 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 AbelTesfaye / dingo / src / BL / Services / event-handler-service.js View on Github external
this.writeRecentTrack(
							new Date().getTime(),
							track.title,
							track.artist,
							track.artwork,
							track.videoId
						);
					}

					previousPlayingTrack.title = track.title;
					previousPlayingTrack.artist = track.artist;
					previousPlayingTrack.artwork = track.artwork;
				});
			});
		}
		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') {
github PierreBresson / Thinkerview / app / reducers / playerReducer.js View on Github external
import {
    PLAYBACK_INIT,
    PLAYBACK_STATE,
    PLAYBACK_TRACK,
    UPDATE_TRACK_INFO
} from "../actions/types";

import TrackPlayer from 'react-native-track-player';
import config from '../config'

const initialPlayerReducer = {
    init: null,
    player_state: TrackPlayer.STATE_PAUSED,
    track: {
        title: config.strings.podcastScreen.title,
        url: null,
        artwork: null
    }
}

export default playerReducer = (state = initialPlayerReducer, action) => {
    switch(action.type) {
        case PLAYBACK_INIT:
            return {
                ...state,
                init: true
            };
        case PLAYBACK_STATE:
            return {
github react-native-kit / react-native-track-player / example / react / screens / PlaylistScreen.js View on Github external
function getStateName(state) {
  switch (state) {
    case TrackPlayer.STATE_NONE:
      return "None";
    case TrackPlayer.STATE_PLAYING:
      return "Playing";
    case TrackPlayer.STATE_PAUSED:
      return "Paused";
    case TrackPlayer.STATE_STOPPED:
      return "Stopped";
    case TrackPlayer.STATE_BUFFERING:
      return "Buffering";
  }
}
github PierreBresson / Thinkerview / app / screens / podcast / index.js View on Github external
_togglePlayPause = () => {
    if (this.props.player_state == TrackPlayer.STATE_PAUSED) {
      TrackPlayer.play();
    } else {
      TrackPlayer.pause();
    }
  };
github PierreBresson / Thinkerview / app / screens / podcast / index.js View on Github external
renderControls = () => {
    return (
      <View style={styles.controlView}>
        <PlayerButton
          iconName={"replay-10"}
          onPress={() => this._addOrRemoveSeconds(-10)}
        />
        <PlayerButton
          iconName={
            this.props.player_state == TrackPlayer.STATE_PAUSED
              ? "controller-play"
              : "controller-paus"
          }
          onPress={async () => this._togglePlayPause()}
        />
        <PlayerButton
          iconName={"forward-10"}
          onPress={() => this._addOrRemoveSeconds(10)}
        />
      </View>
    );
  };
github m-inan / react-native-music-app / src / components / Icons / Music.js View on Github external
Animated.loop(
					Animated.sequence([
						Animated.timing(slide, {
							toValue: 5,
							duration: 1000
						}),
						Animated.timing(slide, {
							toValue: 0,
							duration: 1000
						})
					])
				).start()
				break

			case TrackPlayer.STATE_STOPPED:
			case TrackPlayer.STATE_PAUSED:
				slide.stopAnimation()
				break
		}
	}, [state])
github PierreBresson / Thinkerview / app / context / index.js View on Github external
async playPause() {
      let state = await player.getState();
      switch (state) {
        case TrackPlayer.STATE_PAUSED:
          player.play()
          break;
        case TrackPlayer.STATE_PLAYING:
          player.pause()
          break;
        default:
          break;
      }
    }
github ThalKod / react-native-music-player / src / screens / NowPlaying.js View on Github external
const togglePlayback = async () => {
    const currentTrack = await TrackPlayer.getCurrentTrack();
    if(currentTrack){
      if (playbackState === TrackPlayer.STATE_PAUSED) {
        await TrackPlayer.play();
      } else {
        await TrackPlayer.pause();
      }
    }
  };
github m-inan / react-native-music-app / src / scenes / Player / Record.js View on Github external
useEffect(() => {
		switch (state) {
			case TrackPlayer.STATE_PLAYING:
				Animated.loop(
					Animated.sequence([
						Animated.timing(spinValue, {
							toValue: 1,
							duration: 10000,
							easing: Easing.linear
						})
					])
				).start()
				break

			case TrackPlayer.STATE_PAUSED:
				spinValue.stopAnimation()
				spinValue.extractOffset()
				break

			case STATE_READY:
				spinValue.flattenOffset()
				break
		}
	}, [state])