33 from PyQt5.QtCore import QObject, QThread, pyqtSlot, pyqtSignal, QCoreApplication
36 from classes.app
import get_app
37 from classes.logger
import log
38 from classes
import settings
43 import simplejson
as json
52 self.
parent.movePlayhead(current_frame)
55 if self.
worker.player.Mode() == openshot.PLAYBACK_PLAY
and current_frame >= self.
worker.timeline_length
and self.
worker.timeline_length != -1:
57 self.
parent.actionPlay.trigger()
58 self.
worker.timeline_length = -1
62 log.info(
'onModeChanged')
64 @pyqtSlot(object, object)
65 def Init(self, parent, timeline, video_widget):
75 self.
worker.
Init(parent, timeline, video_widget)
84 self.
parent.previewFrameSignal.connect(self.
worker.previewFrame)
85 self.
parent.refreshFrameSignal.connect(self.
worker.refreshFrame)
102 position_changed = pyqtSignal(int)
103 mode_changed = pyqtSignal(object)
104 finished = pyqtSignal()
106 @pyqtSlot(object, object)
107 def Init(self, parent, timeline, videoPreview):
130 log.info(
"QThread Start Method Invoked")
153 QCoreApplication.processEvents()
162 QCoreApplication.processEvents()
165 log.info(
'exiting thread')
169 log.info(
"initPlayer")
185 log.info(
"previewFrame: %s" % number)
190 log.info(
"self.player.Position(): %s" % self.
player.Position())
195 log.info(
"refreshFrame")
198 self.
parent.LoadFileSignal.emit(
'')
203 log.info(
"self.player.Position(): %s" % self.
player.Position())
213 log.info(
"LoadFile %s" % path)
225 log.info(
"Set timeline reader again in player: %s" % self.
timeline)
236 ext = os.path.splitext(path)
243 fps = project.get([
"fps"])
244 width = project.get([
"width"])
245 height = project.get([
"height"])
246 sample_rate = project.get([
"sample_rate"])
247 channels = project.get([
"channels"])
248 channel_layout = project.get([
"channel_layout"])
251 self.
clip_reader = openshot.Timeline(width, height, openshot.Fraction(fps[
"num"], fps[
"den"]), sample_rate, channels, channel_layout)
252 self.
clip_reader.info.channel_layout = channel_layout
262 new_clip = openshot.Clip(path)
265 log.error(
'Failed to load media file into video player: %s' % path)
283 previous_clip.Close()
285 previous_reader.Close()
288 self.
Seek(seek_position)
292 def Play(self, timeline_length):
298 if self.
parent.initialized:
306 if self.
parent.initialized:
314 if self.
parent.initialized:
322 if self.
parent.initialized:
330 if self.
parent.initialized:
def onPositionChanged(self, current_frame)
def Play(self, timeline_length)
Start playing the video player.
def get_app()
Returns the current QApplication instance of OpenShot.
def onModeChanged(self, current_mode)
def Seek(self, number)
Seek to a specific frame.
def Stop(self)
Stop the video player and terminate the playback threads.
QT Player Worker Object (to preview video on a separate thread)
def LoadFile(self, path=None)
Load a media file into the video player.
def Start(self)
This method starts the video player.
def refreshFrame(self)
Refresh a certain frame.
def Init(self, parent, timeline, video_widget)
def kill(self)
Kill this thread.
def get_settings()
Get the current QApplication's settings instance.
def Init(self, parent, timeline, videoPreview)
def previewFrame(self, number)
Preview a certain frame.
Class which communicates with the PlayerWorker Class (running on a separate thread) ...
def Speed(self, new_speed)
Set the speed of the video player.
def Pause(self)
Pause the video player.