react-icons/bi#BiPause TypeScript Examples

The following examples show how to use react-icons/bi#BiPause. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Search.tsx    From Intro_to_React with GNU General Public License v2.0 6 votes vote down vote up
Result: FC<{
  setSong: (arg0: song) => void
  album: string
  song: string
  url: string
  state: HTMLMediaState
  controls: HTMLMediaControls
  songInfo: song
}> = ({ album, song, url, setSong, state, controls, songInfo }) => {
  const itIsMe = songInfo != null && songInfo.albumName === album && songInfo.songName === song

  const [myColors] = useState(() => colors[Math.floor(Math.random() * colors.length)])

  const [color1, color2] = myColors
  return (
    <article
      className={styles.track}
      style={{ background: `linear-gradient(90deg, ${color1} 0%, ${color2} 100%)` }}
    >
      <section className={styles.info}>
        <p>{album}</p>
        <h2>{song}</h2>
      </section>

      <div
        className={styles.control}
        onClick={() => {
          if (itIsMe) {
            state.paused ? controls.play() : controls.pause()
          } else {
            setSong({ albumName: album, songName: song, url, needToPlay: true })
          }
        }}
      >
        {itIsMe && !state.paused ? <BiPause /> : <BiPlay />}
      </div>
    </article>
  )
}
Example #2
Source File: Search.tsx    From Intro_to_React with GNU General Public License v2.0 6 votes vote down vote up
Result: FC<{
  setSong: (arg0: song) => void
  album: string
  song: string
  url: string
  state: HTMLMediaState
  controls: HTMLMediaControls
  songInfo: song
}> = ({ album, song, url, setSong, state, controls, songInfo }) => {
  const itIsMe = songInfo != null && songInfo.albumName === album && songInfo.songName === song

  const [myColors] = useState(() => colors[Math.floor(Math.random() * colors.length)])

  const [color1, color2] = myColors
  return (
    <article
      className={styles.track}
      style={{ background: `linear-gradient(90deg, ${color1} 0%, ${color2} 100%)` }}
    >
      <section className={styles.info}>
        <p>{album}</p>
        <h2>{song}</h2>
      </section>

      <div
        className={styles.control}
        onClick={() => {
          if (itIsMe) {
            state.paused ? controls.play() : controls.pause()
          } else {
            setSong({ albumName: album, songName: song, url, needToPlay: true })
          }
        }}
      >
        {itIsMe && !state.paused ? <BiPause /> : <BiPlay />}
      </div>
    </article>
  )
}
Example #3
Source File: Player.tsx    From Intro_to_React with GNU General Public License v2.0 5 votes vote down vote up
Player: React.FC<{
  songInfo: song
  state: HTMLMediaState
  controls: HTMLMediaControls
  audio: HTMLAudioElement | null
}> = ({ songInfo, state, controls, audio }) => {
  const toggle = () => {
    if (state.paused) controls.play()
    else controls.pause()
  }

  const { time, duration } = state

  const percentage = time === 0 && duration === 0 ? 0 : (time / duration) * 100

  return (
    <footer className={styles.player}>
      <div className={styles.time} style={{ width: percentage + "%" }}></div>
      <div className={styles.container}>
        <div className={styles.info}>
          <div className={styles.album}>{songInfo?.albumName}</div>
          <div className={styles.song}>{songInfo?.songName}</div>
        </div>
        <div className={styles.playing} onClick={toggle}>
          {state.paused ? <BiPlay /> : <BiPause />}
        </div>
        <div className={styles.controls}>
          <div
            onClick={() => {
              if (state.muted) controls.unmute()
              else controls.mute()
            }}
          >
            {state.muted ? <BiVolumeMute /> : <BiVolumeFull />}
          </div>
          <div>
            <input
              min="0"
              max="1"
              step="0.01"
              value={state.volume}
              type="range"
              onChange={e => {
                controls.volume(+e.target.value)
              }}
            />
          </div>
        </div>
      </div>
    </footer>
  )
}
Example #4
Source File: Player.tsx    From Intro_to_React with GNU General Public License v2.0 5 votes vote down vote up
Player: React.FC<{
  songInfo: song
  state: HTMLMediaState
  controls: HTMLMediaControls
  audio: HTMLAudioElement | null
}> = ({ songInfo, state, controls, audio }) => {
  const toggle = () => {
    if (state.paused) controls.play()
    else controls.pause()
  }

  const { time, duration } = state

  const percentage = time === 0 && duration === 0 ? 0 : (time / duration) * 100

  return (
    <footer className={styles.player}>
      <div className={styles.time} style={{ width: percentage + "%" }}></div>
      <div className={styles.container}>
        <div className={styles.info}>
          <div className={styles.album}>{songInfo?.albumName}</div>
          <div className={styles.song}>{songInfo?.songName}</div>
        </div>
        <div className={styles.playing} onClick={toggle}>
          {audio?.readyState ? state.paused ? <BiPlay /> : <BiPause /> : <BiLoader className={styles.loading} />}
        </div>
        <div className={styles.controls}>
          <div
            onClick={() => {
              if (state.muted) controls.unmute()
              else controls.mute()
            }}
          >
            {state.muted ? <BiVolumeMute /> : <BiVolumeFull />}
          </div>
          <div>
            <input
              min="0"
              max="1"
              step="0.01"
              value={state.volume}
              type="range"
              onChange={e => {
                controls.volume(+e.target.value)
              }}
            />
          </div>
        </div>
      </div>
    </footer>
  )
}