How to use the react-native-track-player.CAPABILITY_PLAY 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.

github m-inan / react-native-music-app / src / reducers / Player / actions.js View on Github external
return async (dispatch, getState) => {
		TrackPlayer.updateOptions({
			capabilities: [
				TrackPlayer.CAPABILITY_PLAY,
				TrackPlayer.CAPABILITY_PAUSE,
				TrackPlayer.CAPABILITY_SEEK_TO,
				TrackPlayer.CAPABILITY_SKIP_TO_NEXT,
				TrackPlayer.CAPABILITY_SKIP_TO_PREVIOUS
			]
		})

		await TrackPlayer.setupPlayer({
			maxCacheSize: 1024 * 5 // 5 mb
		})

		setInterval(async () => {
			const [position, duration] = await Promise.all([
				TrackPlayer.getPosition(),
				TrackPlayer.getDuration()
			])
github Musicoin / app / components / Player.js View on Github external
function updateOptions() {
  let options = {
    stopWithApp: true,
    capabilities: [
      TrackPlayer.CAPABILITY_PLAY,
      TrackPlayer.CAPABILITY_PAUSE,
      TrackPlayer.CAPABILITY_SKIP_TO_NEXT,
      TrackPlayer.CAPABILITY_SKIP_TO_PREVIOUS,
    ],
    compactCapabilities: [
      TrackPlayer.CAPABILITY_PLAY,
      TrackPlayer.CAPABILITY_PAUSE,
    ],
  };

  TrackPlayer.updateOptions(options).then(() => console.log('capabilities set'));
}
github PierreBresson / Thinkerview / app / index.js View on Github external
componentDidMount() {
    TrackPlayer.setupPlayer();

    TrackPlayer.updateOptions({
      stopWithApp: true,
      jumpInterval: 15,
      capabilities: [
        TrackPlayer.CAPABILITY_PLAY,
        TrackPlayer.CAPABILITY_PAUSE,
        TrackPlayer.CAPABILITY_SEEK_TO,
        TrackPlayer.CAPABILITY_JUMP_BACKWARD,
        TrackPlayer.CAPABILITY_JUMP_FORWARD,
        TrackPlayer.CAPABILITY_STOP
      ],
      compactCapabilities: [
        TrackPlayer.CAPABILITY_PLAY,
        TrackPlayer.CAPABILITY_PAUSE
      ]
    });
  }
github ThalKod / react-native-music-player / src / screens / NowPlaying.js View on Github external
const setupPlayer = async () => {
    await TrackPlayer.setupPlayer();
    TrackPlayer.updateOptions({
      stopWithApp: false,
      capabilities: [
        TrackPlayer.CAPABILITY_PLAY,
        TrackPlayer.CAPABILITY_PAUSE,
        TrackPlayer.CAPABILITY_SKIP_TO_NEXT,
        TrackPlayer.CAPABILITY_SKIP_TO_PREVIOUS,
        TrackPlayer.CAPABILITY_STOP
      ],
      compactCapabilities: [
        TrackPlayer.CAPABILITY_PLAY,
        TrackPlayer.CAPABILITY_PAUSE
      ]
    });
  };
github d2rivendell / react-native-GCore / app / components / other / timeLine / TimeLine.js View on Github external
if(play.id !== id){
                        this.audioPlayer.terminate()
                        actions.play(false)
                        this.audioPlayer.initializeUrl()
                        this.audioPlayer.playAudio()
                    }
                }else {
                    this.audioPlayer.initializeUrl()
                    this.audioPlayer.playAudio()
                }

            })
            if(Platform.OS != 'android'){
                TrackPlayer.updateOptions({
                    capabilities: [
                        TrackPlayer.CAPABILITY_PLAY,
                        TrackPlayer.CAPABILITY_PAUSE,
                        TrackPlayer.CAPABILITY_SEEK_TO,
                        TrackPlayer.CAPABILITY_STOP

                    ],
                });

                TrackPlayer.registerEventHandler(() => {
                    return async (data) => {
                        if (data.type == 'playback-state') {

                        } else if (data.type == 'remote-play') {
                            this.audioPlayer.playAudio()
                        } else if (data.type == 'remote-stop') {
                            TrackPlayer.stop();
                        } else if (data.type == 'remote-pause') {
github react-native-kit / react-native-track-player / example / react / screens / PlaylistScreen.js View on Github external
useEffect(() => {
    TrackPlayer.setupPlayer();
    TrackPlayer.updateOptions({
      stopWithApp: true,
      capabilities: [
        TrackPlayer.CAPABILITY_PLAY,
        TrackPlayer.CAPABILITY_PAUSE,
        TrackPlayer.CAPABILITY_SKIP_TO_NEXT,
        TrackPlayer.CAPABILITY_SKIP_TO_PREVIOUS,
        TrackPlayer.CAPABILITY_STOP
      ],
      compactCapabilities: [
        TrackPlayer.CAPABILITY_PLAY,
        TrackPlayer.CAPABILITY_PAUSE
      ]
    });
  }, []);
github moonou / siren / src / store / models / index.js View on Github external
.then(() => {
    TrackPlayer.updateOptions({
      capabilities: [
        TrackPlayer.CAPABILITY_PLAY,
        TrackPlayer.CAPABILITY_PAUSE,
        TrackPlayer.CAPABILITY_SKIP_TO_NEXT,
        TrackPlayer.CAPABILITY_SKIP_TO_PREVIOUS
      ]
    })
  })
github m-inan / react-native-music-app / src / Stores / index.js View on Github external
useEffect(() => {
    AppState.addEventListener('change', handleChange);
    TrackPlayer.registerEventHandler(Handler(dispatch));
    TrackPlayer.setupPlayer({})

    TrackPlayer.updateOptions({
      capabilities: [
        TrackPlayer.CAPABILITY_PLAY,
        TrackPlayer.CAPABILITY_PAUSE,
        TrackPlayer.CAPABILITY_SEEK_TO,
        TrackPlayer.CAPABILITY_SKIP_TO_NEXT,
        TrackPlayer.CAPABILITY_SKIP_TO_PREVIOUS
      ]
    })

    return () => {
      AppState.removeEventListener('change', handleChange);
    }
  }, [])