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
5520eebf
Commit
5520eebf
authored
Sep 05, 2022
by
xuanweiace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
upd 增加 预览视频的时候播放旁白音频 修复 暂停中播放音频的问题
parent
3c54ca35
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
8 deletions
+13
-8
main_window.py
main_window.py
+13
-8
No files found.
main_window.py
View file @
5520eebf
...
...
@@ -137,6 +137,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self
.
can_write_history
=
True
self
.
previewed_audio
=
{}
self
.
is_video_playing
=
True
# 重写关闭Mmainwindow窗口
def
closeEvent
(
self
,
event
):
...
...
@@ -346,6 +347,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
# postion 取值[0,100]
def
clickedSlider
(
self
,
position
):
if
self
.
player
.
duration
()
>
0
:
# 开始播放后才允许进行跳转
self
.
init_previewed_audio
()
video_position
=
int
((
position
/
100
)
*
self
.
player
.
duration
())
self
.
player
.
setPosition
(
video_position
)
# print("pos:", position, "总时长:", self.player.duration())
...
...
@@ -358,6 +360,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
def
moveSlider
(
self
,
position
):
self
.
sld_video_pressed
=
True
if
self
.
player
.
duration
()
>
0
:
# 开始播放后才允许进行跳转
self
.
init_previewed_audio
()
video_position
=
int
((
position
/
100
)
*
self
.
player
.
duration
())
self
.
player
.
setPosition
(
video_position
)
# self.lab_video.setText("%.2f%%" % position)
...
...
@@ -365,33 +368,32 @@ class MainWindow(QMainWindow, Ui_MainWindow):
def
pressSlider
(
self
):
self
.
sld_video_pressed
=
True
print
(
"pressed"
)
def
releaseSlider
(
self
):
self
.
sld_video_pressed
=
False
# 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
)))
# 播放音频
# 0、视频必须在播放中
if
self
.
is_video_playing
==
False
:
return
# 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
)
# 2、如果找到了该音频并且该次预览中没有播放过,则新起一个线程播放
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秒
...
...
@@ -400,13 +402,11 @@ class MainWindow(QMainWindow, Ui_MainWindow):
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
]
...
...
@@ -422,12 +422,17 @@ class MainWindow(QMainWindow, Ui_MainWindow):
# self.projectContext.Init(video_dir, video_name)
self
.
projectContext
.
setVideoPath
(
path
)
def
init_previewed_audio
(
self
):
self
.
previewed_audio
=
{}
def
playVideo
(
self
):
self
.
player
.
play
()
self
.
is_video_playing
=
True
self
.
init_previewed_audio
()
def
pauseVideo
(
self
):
self
.
player
.
pause
()
self
.
is_video_playing
=
False
self
.
init_previewed_audio
()
def
videoDoubleClicked
(
self
,
text
):
...
...
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