Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
AI_BOOK_TOOL
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
template admin
AI_BOOK_TOOL
Commits
d0cb470b
Commit
d0cb470b
authored
May 14, 2025
by
liujiangnan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat
parent
cdcd8a1b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
115 additions
and
33 deletions
+115
-33
index.js
form/index.js
+115
-33
No files found.
form/index.js
View file @
d0cb470b
...
...
@@ -526,31 +526,58 @@ new Vue({
if
(
this
.
currentPlayingRegion
)
{
this
.
stopCurrentPlayback
();
}
this
.
wavesurfer
.
playPause
();
this
.
isPlaying
=
!
this
.
isPlaying
;
// 添加:如果停止播放,强制重绘
if
(
!
this
.
isPlaying
)
{
requestAnimationFrame
(()
=>
{
this
.
wavesurfer
.
drawBuffer
();
});
}
// 如果是锁定状态下的播放,需要在结束位置停止
if
(
this
.
isPageLocked
&&
this
.
isPlaying
)
{
const
remainingTime
=
(
this
.
lockedPageEnd
-
this
.
wavesurfer
.
getCurrentTime
())
*
1000
;
this
.
playTimer
=
setTimeout
(()
=>
{
if
(
this
.
isPlaying
)
{
this
.
wavesurfer
.
pause
();
this
.
isPlaying
=
false
;
// 添加:播放结束后强制重绘
requestAnimationFrame
(()
=>
{
this
.
wavesurfer
.
drawBuffer
();
});
// 如果有选中的组,使用区间播放
if
(
this
.
selectedGroup
!==
null
&&
this
.
currentGroup
)
{
const
regionId
=
`group-
${
this
.
selectedGroup
}
`
;
const
region
=
this
.
audioRegions
[
regionId
];
if
(
region
)
{
// 获取当前时间,如果已经超过结束时间,则重新定位到开始时间
const
currentTime
=
this
.
wavesurfer
.
getCurrentTime
();
if
(
currentTime
>=
this
.
currentGroup
.
end
)
{
this
.
wavesurfer
.
seekTo
(
this
.
currentGroup
.
start
/
this
.
wavesurfer
.
getDuration
());
}
},
remainingTime
);
// 开始播放
this
.
wavesurfer
.
play
();
this
.
isPlaying
=
true
;
this
.
currentPlayingRegion
=
regionId
;
// 设置定时器在结束时间停止
const
remainingTime
=
(
this
.
currentGroup
.
end
-
this
.
wavesurfer
.
getCurrentTime
())
*
1000
;
this
.
playTimer
=
setTimeout
(()
=>
{
if
(
this
.
isPlaying
&&
this
.
currentPlayingRegion
===
regionId
)
{
this
.
wavesurfer
.
pause
();
this
.
isPlaying
=
false
;
this
.
currentPlayingRegion
=
null
;
// 播放结束后强制重绘
requestAnimationFrame
(()
=>
{
this
.
wavesurfer
.
drawBuffer
();
});
}
},
remainingTime
);
}
}
else
{
// 没有选中组,正常播放
this
.
wavesurfer
.
playPause
();
this
.
isPlaying
=
!
this
.
isPlaying
;
// 如果是锁定状态下的播放,需要在结束位置停止
if
(
this
.
isPageLocked
&&
this
.
isPlaying
)
{
const
remainingTime
=
(
this
.
lockedPageEnd
-
this
.
wavesurfer
.
getCurrentTime
())
*
1000
;
this
.
playTimer
=
setTimeout
(()
=>
{
if
(
this
.
isPlaying
)
{
this
.
wavesurfer
.
pause
();
this
.
isPlaying
=
false
;
// 播放结束后强制重绘
requestAnimationFrame
(()
=>
{
this
.
wavesurfer
.
drawBuffer
();
});
}
},
remainingTime
);
}
}
// 播放时保存当前位置作为缩放锚点
...
...
@@ -1394,6 +1421,12 @@ new Vue({
// 直接选中组,不需要取消选中功能
this
.
selectedGroup
=
groupIndex
;
this
.
currentGroup
=
this
.
currentPage
.
groups
[
groupIndex
];
// 只定位到组的开始时间,不自动播放
const
duration
=
this
.
wavesurfer
.
getDuration
();
if
(
duration
&&
this
.
currentGroup
.
start
!==
undefined
)
{
this
.
wavesurfer
.
seekTo
(
this
.
currentGroup
.
start
/
duration
);
}
};
region
.
element
.
removeEventListener
(
'
click
'
,
handleClick
);
...
...
@@ -1715,19 +1748,68 @@ new Vue({
this
.
wavesurfer
.
seekTo
(
this
.
lockedPageStart
/
this
.
wavesurfer
.
getDuration
());
}
}
// 切换播放/暂停状态
this
.
wavesurfer
.
playPause
();
this
.
isPlaying
=
!
this
.
isPlaying
;
// 如果正在区间播放,先清理
if
(
this
.
currentPlayingRegion
)
{
this
.
stopCurrentPlayback
();
}
// 如果有选中的组,使用区间播放
if
(
this
.
selectedGroup
!==
null
&&
this
.
currentGroup
)
{
const
regionId
=
`group-
${
this
.
selectedGroup
}
`
;
const
region
=
this
.
audioRegions
[
regionId
];
if
(
region
)
{
// 获取当前时间,如果已经超过结束时间,则重新定位到开始时间
const
currentTime
=
this
.
wavesurfer
.
getCurrentTime
();
if
(
currentTime
>=
this
.
currentGroup
.
end
)
{
this
.
wavesurfer
.
seekTo
(
this
.
currentGroup
.
start
/
this
.
wavesurfer
.
getDuration
());
}
// 开始播放
this
.
wavesurfer
.
play
();
this
.
isPlaying
=
true
;
this
.
currentPlayingRegion
=
regionId
;
// 设置定时器在结束时间停止
const
remainingTime
=
(
this
.
currentGroup
.
end
-
this
.
wavesurfer
.
getCurrentTime
())
*
1000
;
this
.
playTimer
=
setTimeout
(()
=>
{
if
(
this
.
isPlaying
&&
this
.
currentPlayingRegion
===
regionId
)
{
this
.
wavesurfer
.
pause
();
this
.
isPlaying
=
false
;
this
.
currentPlayingRegion
=
null
;
// 播放结束后强制重绘
requestAnimationFrame
(()
=>
{
this
.
wavesurfer
.
drawBuffer
();
});
}
},
remainingTime
);
}
}
else
{
// 没有选中组,正常播放
this
.
wavesurfer
.
playPause
();
this
.
isPlaying
=
!
this
.
isPlaying
;
// 如果是锁定状态下的播放,需要在结束位置停止
if
(
this
.
isPageLocked
&&
this
.
isPlaying
)
{
const
remainingTime
=
(
this
.
lockedPageEnd
-
this
.
wavesurfer
.
getCurrentTime
())
*
1000
;
this
.
playTimer
=
setTimeout
(()
=>
{
if
(
this
.
isPlaying
)
{
this
.
wavesurfer
.
pause
();
this
.
isPlaying
=
false
;
// 播放结束后强制重绘
requestAnimationFrame
(()
=>
{
this
.
wavesurfer
.
drawBuffer
();
});
}
},
remainingTime
);
}
}
// 如果开始播放,保存当前位置作为缩放锚点
if
(
this
.
isPlaying
)
{
this
.
currentProgress
=
this
.
wavesurfer
.
getCurrentTime
()
/
this
.
wavesurfer
.
getDuration
();
}
else
{
// 如果停止播放,强制重绘
requestAnimationFrame
(()
=>
{
this
.
wavesurfer
.
drawBuffer
();
});
}
}
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment