Combining components in screen and debugging in react native

Поделиться
HTML-код
  • Опубликовано: 20 янв 2025

Комментарии • 43

  • @BoyOfTheFuture4987
    @BoyOfTheFuture4987 Год назад +4

    the hook usePlaybackState() is giving not working. this is what I get "Argument of type 'PlaybackState | { state: undefined; }' is not assignable to parameter of type 'State'.
    Type '{ state: State.None | State.Ready | State.Playing | State.Paused | State.Stopped | State.Loading | State.Buffering | State.Ended; }' is not assignable to type 'State'."

    • @BoyOfTheFuture4987
      @BoyOfTheFuture4987 Год назад

      well I could not find a fix for this, but I did a work around
      previous
      -----------------------------------------------------------------------------------------------------------
      my toggle function
      const togglePlayback = async (playback: State) => {
      const currentTrack = await TrackPlayer.getActiveTrackIndex()
      if (currentTrack !== null) {
      if (playback === State.Paused || playback === State.Ready) {
      await TrackPlayer.play()
      } else {
      await TrackPlayer.pause()
      }
      }
      }
      and my play and pause button
      togglePlayback(playBackState)}>

      Workaround
      -----------------------------------------------------------------------------------------------------------
      const togglePlayback = async (playback: string | undefined) => {
      const togglePlayback = async (playback: State | undefined) => {
      const currentTrack = await TrackPlayer.getActiveTrackIndex()
      if (currentTrack !== null) {
      if (playback === State.Paused || playback === State.Ready) {
      await TrackPlayer.play()
      } else {
      await TrackPlayer.pause()
      }
      }
      }
      and my play and pause button
      togglePlayback(playBackState.state)}>

      But is this even right to do so.

    • @vipulbhardwaj8659
      @vipulbhardwaj8659 11 месяцев назад

      Same error please help me too if you found solution

    • @visheshgupta4990
      @visheshgupta4990 11 месяцев назад

      @@vipulbhardwaj8659 I am also facing this same issue

    • @visheshgupta4990
      @visheshgupta4990 11 месяцев назад

      @@BoyOfTheFuture4987 Thank you so much bro for helping out by giving a workaround solution it helps , now I want to help anyone is facing the same issue this is the solution:-




      togglePlayback(playBackState?.state || State.None)}>

    • @wowstatus3450
      @wowstatus3450 2 месяца назад

      Try this....import { Pressable, StyleSheet, View } from 'react-native';
      import React from 'react';
      import TrackPlayer, { State, usePlaybackState } from 'react-native-track-player';
      import Icon from 'react-native-vector-icons/MaterialIcons';
      const ControlCenter = () => {
      const playBackState = usePlaybackState();
      // next button
      const skipToNext = async ()=>{
      await TrackPlayer.skipToNext();
      };
      // next button
      const skipToPrevious = async ()=>{
      await TrackPlayer.skipToPrevious();
      };
      // play pause
      const togglePlayback = async(playback: State)=>{
      const curruntTrack = await TrackPlayer.getActiveTrackIndex();
      if(curruntTrack !== null){
      if(playback === State.Paused || playback === State.Ready){
      await TrackPlayer.play();
      }else{
      await TrackPlayer.pause();
      }
      }
      };
      return (




      togglePlayback(playBackState.state)}
      >






      );
      };
      export default ControlCenter;
      const styles = StyleSheet.create({
      container: {
      marginBottom: 56,
      flex: 1,
      flexDirection: 'row',
      alignItems: 'center',
      },
      icon: {
      color: '#FFFFFF',
      },
      playButton: {
      marginHorizontal: 24,
      },
      });

  • @solidauto8821
    @solidauto8821 Год назад +1

    Sir i want this app to read audio files from internal storage i have use react-native-fs but it showing only folder not showing any files from storage

  • @shivamparashar330
    @shivamparashar330 8 месяцев назад +1

    Hi sir,
    According to the recent documentation getCurrentTrack is deprecated. Do you have another apporach the play and pause of a track.

    • @Aayyushdhalwal
      @Aayyushdhalwal 2 месяца назад

      use getActiveTrackIndex

    • @Roshan-fy5rk
      @Roshan-fy5rk 16 дней назад

      read the docs of react native Track player you will find it's working alternative!

  • @SaidBourdia
    @SaidBourdia Год назад

    I really like this serie , thank you so much for the effort and the good work .
    While trying to make this project work I failed badly on making the track info appear.
    If anyone had the same problem and got it working I'll appreciate some help.
    Thank you

  • @Roshan-fy5rk
    @Roshan-fy5rk 16 дней назад

    i m having this error constantly :
    TypeError: Cannot read property 'CAPABILITY_PLAY' of null [Component Stack]

  • @anvaymayekar1891
    @anvaymayekar1891 Год назад +1

    Sir it would be great if you'll append one project in this series where you'll elucidate some neumorphic elements and themes!

  • @Karthik-qh4vn
    @Karthik-qh4vn Год назад

    when I run the Application it is showing "react-native-track-player:classpath" getting error I have installed all correctly but why it is showing, with this error I am able to install the app in emulator, it is not running

  • @jackanderson300
    @jackanderson300 Год назад

    Thank you sir for such great playlist on react native😀.

  • @DeepakSankhyan
    @DeepakSankhyan Год назад

    Bit Tough to digest but so happy to complete it thank you .....

  • @vaishakhgk2006
    @vaishakhgk2006 Год назад

    How many videos did you posted today ?

  • @MRWOLF-rd6tm
    @MRWOLF-rd6tm Год назад

    mine player is not working fine it plays first song but whenever i click on next it throws an error of "Asset not found: "

    • @maiharshithu
      @maiharshithu Год назад

      check name and location allocation while import

    • @vipulbhardwaj8659
      @vipulbhardwaj8659 11 месяцев назад

      Hiii Can you please help me with an error in playback state? my player is not at all working with the same code in the video

    • @vipulbhardwaj8659
      @vipulbhardwaj8659 11 месяцев назад

      Hii can you please help me in this project , the code is not working with the same code in the video
      @@maiharshithu

  • @rahul_sidhha
    @rahul_sidhha Год назад

    Thank you so much sir.
    Biggest surprise 15 videos in a day

  • @omyerawar7976
    @omyerawar7976 Год назад

    One suggestion sir : You can also use rafce instead of rfce to generate arrow function component :)

  • @camperschool2191
    @camperschool2191 Год назад

    Why you left this series??😢
    No update since last 2 weeks

    • @HiteshCodeLab
      @HiteshCodeLab  Год назад +1

      It takes time to record videos, along with job 🙂

    • @camperschool2191
      @camperschool2191 Год назад

      @@HiteshCodeLab Why still a job?
      Start something of your own.
      BTW appreciate your knowledge sharing on YT, you're really helping middle class students 👍.

  • @oppomobile-ur4jd
    @oppomobile-ur4jd Год назад +2

    Sir please javascript series finish karado please 😢😢😢😢😢😢😢😢😢😢😢😢😢😢😢😢😢😢

    • @yuvraj1971
      @yuvraj1971 Год назад +3

      kyu ro raha hai documentation padhna sikh lo time bhi bachega aur kisi jarrurat nahi hoga

    • @HiteshCodeLab
      @HiteshCodeLab  Год назад +3

      Very soon and don't worry when I was beginner, I was also looking for resource and didn't knew about learning from docs. No one in their early stage know how to learn directly from docs. Sometime people forget their early days. 🙂

  • @gaganvishwakarma6494
    @gaganvishwakarma6494 10 месяцев назад

    React-Native-Track-Player has been changed so far. Most of the error are occuring due to this . I solved all error by reading documentation . If you need any help feel free to ask me . There are lots of changes which has to change in this project that's why i am making PR.

    • @visheshgupta4990
      @visheshgupta4990 10 месяцев назад

      Hi, Your comment is like a hope for me , I build this project and after build playback - play pause functionality is not working but in development server app is working completely fine can you please help me with that

    • @visheshgupta4990
      @visheshgupta4990 10 месяцев назад

      I also asked this question in hitesh sir discord server in general app dev section

    • @gaganvishwakarma6494
      @gaganvishwakarma6494 10 месяцев назад

      @@visheshgupta4990 Hell yeah , there are many changes which you have to do in ControlCentral.tsx file, so i am sharing the full code of it
      ==================================
      import { View, Pressable } from 'react-native'
      import TrackPlayer, { PlaybackState, State, usePlaybackState } from 'react-native-track-player'
      import Icon from 'react-native-vector-icons/MaterialIcons'
      const ControlCenter = (): JSX.Element => {
      const playerState = usePlaybackState()
      const skipToNext = async () => await TrackPlayer.skipToNext()
      const skipToPrevious = async () => await TrackPlayer.skipToPrevious()
      const togglePlayback = async (playback:PlaybackState) => {
      const currentTrack = await TrackPlayer.getActiveTrack()
      if (currentTrack !== null)
      if (playback.state === State.Paused || playback.state === State.Ready) await TrackPlayer.play()
      else await TrackPlayer.pause()
      }
      return



      togglePlayback(playerState as PlaybackState)}>






      }
      I used Nativewind but you can replace all classname props with style , Home it will work .

    • @jade_warrior
      @jade_warrior 9 месяцев назад +2

      Hi, how did you resolve the getTrack(event.nextTrack) issue?

    • @BowlBoundaries
      @BowlBoundaries 4 месяца назад

      @@jade_warrior I found the solution const MusicPlayer = () => {
      const [track, setTrack] = useState()
      useTrackPlayerEvents([Event.PlaybackTrackChanged], async event => {
      switch (event.type) {
      case Event.PlaybackTrackChanged:
      const playingTrack = await TrackPlayer.getTrack(event.nextTrack)
      setTrack(playingTrack)
      break;
      }
      })

  • @Anonymous1700-m9d
    @Anonymous1700-m9d 10 месяцев назад

    HelpFul

  • @9raian
    @9raian Год назад

    Genius