|
@@ -44,11 +44,19 @@
|
|
|
</view>
|
|
|
<!-- 进度条时间 -->
|
|
|
<view class="progress-container">
|
|
|
- <view class="progress-bar">
|
|
|
- <view class="progress-current"></view>
|
|
|
- </view>
|
|
|
+ <!-- <view class="progress-bar"> -->
|
|
|
+ <!-- <view class="progress-current"></view> -->
|
|
|
+ <input
|
|
|
+ type="range"
|
|
|
+ v-model="currentTime"
|
|
|
+ :max="duration"
|
|
|
+ step="0.1"
|
|
|
+ @input="onSliderChange"
|
|
|
+ class="slider"
|
|
|
+ />
|
|
|
+ <!-- </view> -->
|
|
|
<view class="time-info">
|
|
|
- <text class="current-time">00:00</text>
|
|
|
+ <text class="current-time">{{ audio.startTime }}</text>
|
|
|
<text class="total-time">{{ song.duration }}</text>
|
|
|
</view>
|
|
|
</view>
|
|
@@ -112,7 +120,8 @@
|
|
|
import { ref } from 'vue'
|
|
|
const song = ref({})
|
|
|
const audioSrc = ref('https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3') // 替换为你的音频文件路径
|
|
|
- const isPlaying = ref(false) // 用来标识播放状态
|
|
|
+ const isPlaying = ref(true) // 用来标识播放状态
|
|
|
+ const currentTime = ref(0)
|
|
|
const audio = uni.createInnerAudioContext()
|
|
|
audio.autoplay = true
|
|
|
onLoad((query) => {
|
|
@@ -131,7 +140,9 @@
|
|
|
// 循环播放
|
|
|
const palyCycleBtn = () => {
|
|
|
audio.loop = true
|
|
|
- console.log('循环播放', audio.loop)
|
|
|
+ audio.autoplay = true
|
|
|
+ audio.src = audioSrc.value
|
|
|
+ isPlaying.value = true
|
|
|
}
|
|
|
// 上一曲
|
|
|
const previousSongBtn = () => {
|
|
@@ -146,12 +157,12 @@
|
|
|
if (isPlaying.value) {
|
|
|
audio.autoplay = true
|
|
|
audio.src = audioSrc.value
|
|
|
- console.log('innerAudioContext0', audio)
|
|
|
} else {
|
|
|
audio.autoplay = false
|
|
|
audio.src = audioSrc.value
|
|
|
}
|
|
|
isPlaying.value = !isPlaying.value
|
|
|
+ console.log(audio.currentTime)
|
|
|
}
|
|
|
</script>
|
|
|
|