React实现音频组件

GitHub网址

GitHub - Blue-keykey/react-audio-player-demo: Created with CodeSandboxCreated with CodeSandbox. Contribute to Blue-keykey/react-audio-player-demo development by creating an account on GitHub.https://github.com/Blue-keykey/react-audio-player-demo

 参考样式注解

// :root {
//   --white: #fff;
//   --active-color: #00aeb0;
// }
* {
  box-sizing: border-box;
}

// 控制整个页面样式
// html {
//   font-family: Arial, Helvetica, sans-serif;
//   height: 100%;
//   background: var(--active-color);
//   transition: background 0.4s ease;
// }

// 控制按钮的样式
button {
  background: none;
  border: none;
  cursor: pointer;
}

// 控制进度条的样式
input[type='range'] {
  height: 5px;
  -webkit-appearance: none;
  width: 100%;
  margin-bottom: 10px;
  border-radius: 8px;
  background: #3b7677;
  transition: background 0.2s ease;
  cursor: pointer;
}
// 存放音乐的盒子大小样式
.audio-player {
  max-width: 100%;
  padding: 24px;
  border-radius: 20px;
  box-shadow: 0 28px 28px rgba(0, 0, 0, 0.2);
  margin: auto;
  color: var(--white);
  font-family: Arial, Helvetica, sans-serif;
  height: 100%;
  background: var(--active-color);
  transition: background 0.4s ease;
  --white: #fff;
  --active-color: #00aeb0;
}
// 控制音乐图片
.artwork {
  border-radius: 10rem;
  display: block;
  margin: auto;
  height: 3rem;
  width: 3rem;
  animation: rotation 2s infinite linear;
}

// 控制文本及按钮的位置
.track-info {
  text-align: center;
  z-index: 1;
  // position: relative;
}

// 控制图片底下的文本
// .title {
//   font-weight: 50;
//   font-size: 1rem;
//   margin-bottom: 1rem;
// }

.artist {
  font-weight: 50;
  margin-top: 0;
}
// 控制按钮的位置
.audio-controls {
  display: flex;
  justify-content: space-between;
  width: 75%;
  margin: 0 auto 1rem;
}
// 控制左右按钮的大小
.audio-controls .prev svg,
.audio-controls .next svg {
  width: 1.5rem;
  height: 1.5rem;
}
// 控制中间的播放按钮
.audio-controls .play svg,
.audio-controls .pause svg {
  height: 2rem;
  width: 2rem;
}
// 控制按钮的颜色
.audio-controls path {
  fill: var(--white);
}

// 控制全局样式跟着一起改变
// .color-backdrop {
//   background: linear-gradient(45deg, var(--active-color) 20%, transparent 100%)
//     no-repeat;
//   position: absolute;
//   top: 0;
//   left: 0;
//   right: 0;
//   bottom: 0;
//   z-index: -1;
// }
// 动画效果
// .color-backdrop.playing {
//   animation: colorChange 20s alternate infinite;
// }

// @keyframes colorChange {
//   from {
//     filter: hue-rotate(0deg);
//   }
//   to {
//     filter: hue-rotate(360deg);
//   }
// }

// 实现动画持续旋转效果
@keyframes rotation {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(359deg);
  }
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值