- setup env. for
Music Player
app ; addedreact-native-track-player
npm pkg ; created folderassets
having few mp3 files - created file
constants.ts
from where we areexporting
an array of objects that contains metadata of audio files ;import { Track } from 'react-native-track-player'
npm pkg - create file
playbackServices.js
inroot dir.
& importTrackPlayer
fromreact-native-track-player
,playListData
fromconstants.ts
and createasync
fnplaybackService()
; inindex.js
importTrackPlayer
&playbackService
& registerAppRegistry.registerComponent()
like this:TrackPlayer.registerPlaybackService(() => playbackService)
- create
musicPlayerServices.js
& add fns. usingasync-await
:setupPlayer()
,addTrack()
,playbackService()
- added
react-native-vector-icons
npm pkg - in
App.tsx
, callmusicPlayerServices
;useState()
,useEffect()
; basic setup on rendering part: intro to<ActivityIndicator />
- create component =>
ControlCenter.tsx
& importusePlaybackState
hook &MaterialIcons
; added fns.skipToNext()
,skipToPrevious()
,togglePlayback()
; rendering them (currently having issues withplayBackState
type) - create component
SongInfo.tsx
; rendertrack
title
&track
artist
&track album
- create component
SongSlider.jsx
; call hookuseProgress()
from'react-native-track-player'
withposition
&duration
; renderSlider
from'@react-native-community/slider'
; js code to show time progressed & time remaining usingDate()
- added screens =>
MusicPlayer.tsx
;useTrackPlayerEvents()
; rendered all components - rendering components in
App.tsx
ReactNativeApp10
Folders and files
Name | Name | Last commit date | ||
---|---|---|---|---|
parent directory.. | ||||