Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
accessibility_movie_2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
赵心治
accessibility_movie_2
Commits
3c54ca35
Commit
3c54ca35
authored
Sep 05, 2022
by
xuanweiace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
upd 增加 预览视频的时候播放旁白音频
parent
97421bf6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
1 deletion
+32
-1
main_window.py
main_window.py
+32
-1
No files found.
main_window.py
View file @
3c54ca35
...
...
@@ -136,6 +136,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
#在进行redo_undo时,会触发itemchange,但是这时候不能覆写历史。但是需要写入project。(注意命名思路:在进行redo的时候,会有两步操作,写入history和写入project。我们只希望他不写入history,所以命名中要带有history)
self
.
can_write_history
=
True
self
.
previewed_audio
=
{}
# 重写关闭Mmainwindow窗口
def
closeEvent
(
self
,
event
):
...
...
@@ -371,12 +372,42 @@ class MainWindow(QMainWindow, Ui_MainWindow):
# position 取值[0,总时长]
def
changeSlide
(
self
,
position
):
print
(
"position:"
,
position
)
if
not
self
.
sld_video_pressed
:
# 进度条被鼠标点击时不更新
self
.
vidoeLength
=
self
.
player
.
duration
()
+
0.1
self
.
sld_video
.
setValue
(
round
((
position
/
self
.
vidoeLength
)
*
100
))
self
.
lab_video
.
setText
(
utils
.
transfer_second_to_time
(
str
(
position
/
1000
)))
# self.lab_video.setText("%.2f%%" % ((position/self.vidoeLength)*100))
# 播放音频
# 1、先找到要播放的音频
audio_path
=
None
for
i
in
range
(
len
(
self
.
projectContext
.
aside_list
)
-
1
,
-
1
,
-
1
):
print
(
"float(self.projectContext.aside_list[i].st_time_sec), "
,
float
(
self
.
projectContext
.
aside_list
[
i
]
.
st_time_sec
))
if
position
/
1000
>
float
(
self
.
projectContext
.
aside_list
[
i
]
.
st_time_sec
):
audio_path
=
os
.
path
.
dirname
(
self
.
projectContext
.
excel_path
)
+
(
"/
%.2
f.wav"
%
float
(
self
.
projectContext
.
aside_list
[
i
]
.
st_time_sec
))
break
print
(
"audio_path:"
,
audio_path
)
if
audio_path
!=
None
and
os
.
path
.
basename
(
audio_path
)
not
in
self
.
previewed_audio
:
RunThread
(
funcName
=
self
.
play_audio
,
args
=
(
audio_path
,
self
.
previewed_audio
),
name
=
"play_audio"
)
.
start
()
# self.play_audio(audio_path)
@staticmethod
#一条语音的最长播放时间是10秒
def
play_audio
(
path
,
previewed_audio
):
#如果没有该音频,则直接return
if
not
os
.
path
.
exists
(
path
):
return
file
=
QUrl
.
fromLocalFile
(
path
)
# 音频文件路径
print
(
"我要播放的file是"
,
file
)
content
=
QMediaContent
(
file
)
player
=
QMediaPlayer
()
player
.
setMedia
(
content
)
player
.
play
()
previewed_audio
[
os
.
path
.
basename
(
path
)]
=
1
import
time
time
.
sleep
(
10
)
def
openVideoFile
(
self
):
path
=
QFileDialog
.
getOpenFileUrl
()[
0
]
self
.
player
.
setMedia
(
QMediaContent
(
path
))
# 选取视频文件
...
...
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