99from mineSweeperGUIEvent import MineSweeperGUIEvent
1010
1111class MineSweeperVideoPlayer (MineSweeperGUIEvent ):
12+ def initVideoPlayer (self ):
13+ self .ui_video_control = videoControl .ui_Form (self .r_path , self .game_setting ,
14+ self .mainWindow )
15+ self .video_time_step = 0.01 # 录像时间的步长,定时器始终是10毫秒
16+
17+ self .ui_video_control .pushButton_play .clicked .connect (self .video_play )
18+ self .ui_video_control .pushButton_replay .clicked .connect (
19+ self .video_replay )
20+ self .ui_video_control .videoSetTime .connect (self .video_set_time )
21+ self .ui_video_control .videoSetTimePeriod .connect (self .video_set_a_time )
22+ self .ui_video_control .label_speed .wEvent .connect (self .video_set_speed )
23+ self .ui_video_control .tabWidget .currentChanged .connect (self .on_tab_changed )
24+ self .timer_video = QTimer ()
25+ self .timer_video .timeout .connect (self .video_playing_step )
26+
1227
1328 # 打开录像文件的回调
1429 def action_OpenFile (self , openfile_name = None ):
15- self .setting_path / 'replay'
30+ # self.setting_path / 'replay'
1631
17- self .ui_video_control = videoControl .ui_Form (self .r_path , self .game_setting ,
18- self .mainWindow )
32+ # self.ui_video_control = videoControl.ui_Form(self.r_path, self.game_setting,
33+ # self.mainWindow)
1934
2035 self .unlimit_cursor ()
2136 if not openfile_name :
@@ -51,6 +66,8 @@ def action_OpenFile(self, openfile_name=None):
5166 return
5267
5368
69+ # 每个标签的数据都存在这里
70+ # self.tab_data = []
5471 if video_set :
5572 # 包含对每个evf的parse
5673 video_set .parse ()
@@ -59,27 +76,45 @@ def action_OpenFile(self, openfile_name=None):
5976 "mouse_trace" , "vision_transfer" , "pluck" ,
6077 "super_fl_local" ])
6178 self .ui_video_control .add_new_video_set_tab (video_set )
79+ self .ui_video_control .videoTabClicked .connect (lambda x : self .play_video (video_set [x ].evf_video ))
80+ self .ui_video_control .videoTabDoubleClicked .connect (lambda x : self .play_video (video_set [x ].evf_video , True ))
81+ # self.tab_data.append(video_set)
6282 video = video_set [0 ].evf_video
6383 else :
64- video .parse_video ()
84+ video .parse ()
6585 video .analyse ()
6686 video .analyse_for_features (["high_risk_guess" , "jump_judge" , "needless_guess" ,
6787 "mouse_trace" , "vision_transfer" , "pluck" ,
6888 "super_fl_local" ])
69- self .ui_video_control .add_new_video_tab (video )
70- self . ui_video_control . videoTabClicked . connect ( lambda x : self .play_video ( video_set [ x ]. evf_video ) )
89+ self .ui_video_control .add_new_video_tab (video )
90+ # self.tab_data.append(video )
7191 self .play_video (video )
7292
7393
7494 # 播放新录像,调整局面尺寸等
7595 # 控制台中,不添加新标签、连接信号。假如关闭就展示
7696 # 播放AvfVideo、RmvVideo、EvfVideo、MvfVideo或BaseVideo
77- def play_video (self , video ):
97+ def play_video (self , video , new_tab = False ):
7898 # if self.game_state == 'display':
7999 # self.ui_video_control.QWidget.close()
80100 # self.game_state = 'display'
101+
81102 if self .game_state != 'display' :
82103 self .game_state = 'display'
104+ self .video_playing = False
105+ self .timer_video .stop ()
106+
107+ # 添加新标签并切换过去
108+ if new_tab :
109+ tab_count = self .ui_video_control .tabWidget .count ()
110+ for index in range (tab_count ):
111+ tab_widget = self .ui_video_control .tabWidget .widget (index )
112+ if video .file_name == tab_widget .file_name :
113+ self .ui_video_control .tabWidget .setCurrentIndex (index )
114+ break
115+ else :
116+ self .ui_video_control .add_new_video_tab (video )
117+ self .ui_video_control .tabWidget .setCurrentIndex (tab_count )
83118
84119
85120 # 检查evf的checksum,其余录像没有鉴定能力
@@ -113,21 +148,26 @@ def play_video(self, video):
113148 self .label_2 .reloadFace (self .pixSize )
114149 self .minimumWindow ()
115150
116- self .timer_video = QTimer ()
117- self .timer_video .timeout .connect (self .video_playing_step )
118151
119- self .ui_video_control .pushButton_play .clicked .connect (self .video_play )
120- self .ui_video_control .pushButton_replay .clicked .connect (
121- self .video_replay )
122- self .ui_video_control .videoSetTime .connect (self .video_set_time )
123- self .ui_video_control .videoSetTimePeriod .connect (self .video_set_a_time )
124- self .ui_video_control .label_speed .wEvent .connect (self .video_set_speed )
152+
153+
125154
126155 self .ui_video_control .QWidget .show ()
156+
157+ t_end = video .video_end_time
158+ t_start = video .video_start_time
159+
160+ # 重新设置进度条的最大值、最小值,要临时屏蔽信号发送
161+ self .ui_video_control .horizontalSlider_time .blockSignals (True )
162+ self .ui_video_control .horizontalSlider_time .setValue (0 )
163+ self .ui_video_control .horizontalSlider_time .setMaximum (
164+ int (t_end * 1000 ))
165+ self .ui_video_control .horizontalSlider_time .setMinimum (
166+ int (t_start * 1000 ))
167+ self .ui_video_control .horizontalSlider_time .blockSignals (False )
127168
128- self .video_time = video .video_start_time # 录像当前时间
129- self .video_stop_time = video .video_end_time # 录像停止时间
130- self .video_time_step = 0.01 # 录像时间的步长,定时器始终是10毫秒
169+ self .video_time = t_start # 录像当前时间
170+ self .video_stop_time = t_end # 录像停止时间
131171 self .label .paint_cursor = True
132172 self .video_playing = True # 录像正在播放
133173 # 禁用双击修改指标名称公式
@@ -142,6 +182,14 @@ def play_video(self, video):
142182 self .set_country_flag (self .label .ms_board .country )
143183
144184 self .timer_video .start (10 )
185+
186+
187+ # 切换标签时,播放标签中的录像
188+ def on_tab_changed (self , idt ):
189+ if isinstance (self .ui_video_control .tabWidget .widget (idt ), videoControl .VideoTabWidget ):
190+ self .play_video (self .ui_video_control .tabWidget .widget (idt ).video )
191+ ...
192+
145193
146194 def video_playing_step (self ):
147195 # 播放录像时定时器的回调
0 commit comments