sensible-cinema 0.27.0 → 0.28.0
Sign up to get free protection for your applications and to get access to all the features.
- data/TODO +0 -1
- data/VERSION +1 -1
- data/change_log_with_feature_list.txt +17 -0
- data/vendor/movie-content-editor-read-only/.metadata/.lock +0 -0
- data/vendor/movie-content-editor-read-only/.metadata/.mylyn/.tasks.xml.zip +0 -0
- data/vendor/movie-content-editor-read-only/.metadata/.mylyn/repositories.xml.zip +0 -0
- data/vendor/movie-content-editor-read-only/.metadata/.mylyn/tasks.xml.zip +0 -0
- data/vendor/movie-content-editor-read-only/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version +1 -0
- data/vendor/movie-content-editor-read-only/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index +0 -0
- data/vendor/movie-content-editor-read-only/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version +1 -0
- data/vendor/movie-content-editor-read-only/.metadata/.plugins/org.eclipse.core.resources/.root/2.tree +0 -0
- data/vendor/movie-content-editor-read-only/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources +0 -0
- data/vendor/movie-content-editor-read-only/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs +3 -0
- data/vendor/movie-content-editor-read-only/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs +14 -0
- data/vendor/movie-content-editor-read-only/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.context.core.prefs +3 -0
- data/vendor/movie-content-editor-read-only/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs +5 -0
- data/vendor/movie-content-editor-read-only/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.prefs +3 -0
- data/vendor/movie-content-editor-read-only/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache +0 -0
- data/vendor/movie-content-editor-read-only/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat +0 -0
- data/vendor/movie-content-editor-read-only/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml +2 -0
- data/vendor/movie-content-editor-read-only/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml +2 -0
- data/vendor/movie-content-editor-read-only/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml +10 -0
- data/vendor/movie-content-editor-read-only/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml +11 -0
- data/vendor/movie-content-editor-read-only/.metadata/.plugins/org.eclipse.ui.intro/dialog_settings.xml +4 -0
- data/vendor/movie-content-editor-read-only/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml +10 -0
- data/vendor/movie-content-editor-read-only/.metadata/.plugins/org.eclipse.ui.workbench/workbench.xml +232 -0
- data/vendor/movie-content-editor-read-only/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml +4 -0
- data/vendor/movie-content-editor-read-only/.metadata/version.ini +1 -0
- data/vendor/movie-content-editor-read-only/.project +17 -0
- data/vendor/movie-content-editor-read-only/.pydevproject +11 -0
- data/vendor/movie-content-editor-read-only/.settings/org.eclipse.core.resources.prefs +6 -0
- data/vendor/movie-content-editor-read-only/SubIt.py +171 -0
- data/vendor/movie-content-editor-read-only/VLCMacVideo.py +257 -0
- data/vendor/movie-content-editor-read-only/VideoMac.ui +102 -0
- data/vendor/movie-content-editor-read-only/badwords.txt +4 -0
- data/vendor/movie-content-editor-read-only/blank.srt +4 -0
- data/vendor/movie-content-editor-read-only/edit.py +197 -0
- data/vendor/movie-content-editor-read-only/mergeCommands.py +73 -0
- data/vendor/movie-content-editor-read-only/mute.txt +5 -0
- data/vendor/movie-content-editor-read-only/panda.srt +4235 -0
- data/vendor/movie-content-editor-read-only/panda_custom.txt +3 -0
- data/vendor/movie-content-editor-read-only/panda_edit.srt +4235 -0
- data/vendor/movie-content-editor-read-only/subtitle.py +90 -0
- data/vendor/movie-content-editor-read-only/vlc.py +5579 -0
- data/vendor/movie-content-editor-read-only/vlcwidget.py +154 -0
- metadata +43 -7
- data/legal/control_youtube.html +0 -135
- data/legal/md5s.txt +0 -53
- data/legal/play_with_inserted_scene.bat +0 -8
- data/legal/play_with_overlay.bat +0 -24
- data/legal/serve.rb +0 -6
- data/legal/transcript_mute_vlc.txt +0 -117
@@ -0,0 +1,257 @@
|
|
1
|
+
#! /usr/bin/python
|
2
|
+
|
3
|
+
#import vlc
|
4
|
+
import sys
|
5
|
+
from PyQt4 import QtGui, QtCore, uic
|
6
|
+
from Foundation import *
|
7
|
+
from AppKit import NSView
|
8
|
+
from Quartz import *
|
9
|
+
from CoreFoundation import *
|
10
|
+
import objc
|
11
|
+
from objc import YES, NO, NULL
|
12
|
+
import sip
|
13
|
+
|
14
|
+
#objc.loadBundle("VLCKit",globals(),bundle_path=objc.pathForFramework("/Users/slloyd/Downloads/vlc/projects/macosx/framework/build/Debug/VLCKit.framework"))
|
15
|
+
d='/Users/slloyd/Downloads/vlc/projects/macosx/framework/build/vlc_build_dir'
|
16
|
+
d='/Applications/VLC.app/Contents/MacOS'
|
17
|
+
TIME_RES = 10000
|
18
|
+
|
19
|
+
"""The ideal way to do this would be to use the objc.loadBundle method to import the VLCKit framework already built for VLC.
|
20
|
+
This would ideally build Python wrappers around all of the custom VLC objects we need and allow us to create them in Python
|
21
|
+
directly without having to define the classes ourselves. I wasn't able to get this to work, so for now, I've defined just one
|
22
|
+
of these classes myself (the VLCVideoView class) to allow us to have something that works"""
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
"""Objective C class defined in Python. Lots of signatures to tell objc which methods to call. Some of them are apparently
|
27
|
+
unnecessary, but it wasn't clear to me which were needed and which weren't, so I left them all in. I suspect that they are
|
28
|
+
unnecessary when overriding methods of a parent class, but I haven't confirmed that."""
|
29
|
+
class VLCVideoView(NSView):
|
30
|
+
|
31
|
+
objc.synthesize('delegate', copy=True)
|
32
|
+
objc.synthesize('backColor',copy=True)
|
33
|
+
objc.synthesize('hasVideo', copy=True)
|
34
|
+
|
35
|
+
#Initialize the VLCVideoView object. If running in 64-bit on SnowLeopard, it expects a CGRect rather than an NSRect
|
36
|
+
@objc.signature("@@:{_NSRect={_NSPoint=ff}{_NSSize=ff}}")
|
37
|
+
# @objc.signature("@@:{CGRect={CGPoint=dd}{CGSize=dd}}")
|
38
|
+
def initWithFrame_(self,rect):
|
39
|
+
self = super(VLCVideoView, self).initWithFrame_(rect)
|
40
|
+
if self is None: return None
|
41
|
+
self._delegate = None
|
42
|
+
self._backColor = NSColor.blackColor()
|
43
|
+
self._fillScreen = NO
|
44
|
+
self._hasVideo = NO
|
45
|
+
self.setStretchesVideo_(NO)
|
46
|
+
self.setAutoresizesSubviews_(YES)
|
47
|
+
|
48
|
+
#probably need to figure out how to assign an appropriate layoutManager, but for now it's None
|
49
|
+
self.layoutManager = None
|
50
|
+
return self
|
51
|
+
|
52
|
+
@objc.signature("@@:")
|
53
|
+
def backColor(self):
|
54
|
+
return self._backColor
|
55
|
+
|
56
|
+
@objc.signature("c@:")
|
57
|
+
def hasVideo(self):
|
58
|
+
return self._hasVideo
|
59
|
+
|
60
|
+
@objc.signature("@@:")
|
61
|
+
def delegate(self):
|
62
|
+
return self._delegate
|
63
|
+
|
64
|
+
@objc.signature("v@:")
|
65
|
+
def dealloc(self):
|
66
|
+
self._delegate = None
|
67
|
+
self._backColor = None
|
68
|
+
if self.layoutManager:
|
69
|
+
self.layoutManager.release()
|
70
|
+
super(VLCVideoView,self).dealloc()
|
71
|
+
|
72
|
+
@objc.signature("v@:{_NSRect={_NSPoint=ff}{_NSSize=ff}}")
|
73
|
+
def drawRect_(self,aRect):
|
74
|
+
self.lockFocus()
|
75
|
+
self.backColor().set()
|
76
|
+
NSRectFill(aRect)
|
77
|
+
self.unlockFocus()
|
78
|
+
|
79
|
+
@objc.signature("c@:")
|
80
|
+
def isOpaque(self):
|
81
|
+
return YES
|
82
|
+
|
83
|
+
|
84
|
+
@objc.signature("c@:")
|
85
|
+
def fillScreen(self):
|
86
|
+
if self.layoutManager:
|
87
|
+
return self.layoutManager.fillScreenEntirely()
|
88
|
+
return NO
|
89
|
+
|
90
|
+
@objc.signature("v@:c")
|
91
|
+
def setFillScreen_(self,fillScreen):
|
92
|
+
#need to implement
|
93
|
+
return NO
|
94
|
+
|
95
|
+
|
96
|
+
@objc.signature("v@:{CALayer=#{_CALayerIvars=iII^{__CFArray}@^{_CALayerState}^{_CALayerState}^{_CALayerAnimation}[3^{_CALayerTransaction}]}}")
|
97
|
+
def addVoutLayer_(self, aLayer):
|
98
|
+
CATransaction.begin()
|
99
|
+
self.setWantsLayer_(YES)
|
100
|
+
rootLayer = self.layer()
|
101
|
+
aLayer.name = u"vlcopengllayer"
|
102
|
+
if self.layoutManager:
|
103
|
+
self.layoutManager.setOriginalVideoSize_(aLayer.bounds().size())
|
104
|
+
|
105
|
+
rootLayer.setLayoutManager_(layoutManager)
|
106
|
+
rootLayer.insertSublayer_atIndex_(aLayer, 0)
|
107
|
+
aLayer.setNeedsDisplayOnBoundsChange_(True)
|
108
|
+
|
109
|
+
CATransaction.commit()
|
110
|
+
self._hasVideo = YES
|
111
|
+
|
112
|
+
@objc.signature("v@:@")
|
113
|
+
def removeVoutLayer_(self, voutLayer):
|
114
|
+
CATransaction.begin()
|
115
|
+
voutLayer.removeFromSuperlayer()
|
116
|
+
CATransaction.commit()
|
117
|
+
self._hasVideo = NO
|
118
|
+
|
119
|
+
@objc.signature("v@:c")
|
120
|
+
def setStretchesVideo_(self,value):
|
121
|
+
self._stretchesVideo = value;
|
122
|
+
|
123
|
+
|
124
|
+
@objc.signature("v@:@")
|
125
|
+
def addVoutSubview_(self, aView):
|
126
|
+
aView.setFrame_(self.bounds())
|
127
|
+
self.addSubview_(aView)
|
128
|
+
aView.setAutoresizingMask_((NSViewHeightSizable|NSViewWidthSizable))
|
129
|
+
|
130
|
+
@objc.signature("v@:@")
|
131
|
+
def removeVoutSubview_(self, view):
|
132
|
+
#not doing anything right now
|
133
|
+
pass
|
134
|
+
|
135
|
+
@objc.signature("c@:")
|
136
|
+
def stretchesVideo(self):
|
137
|
+
return self._stretchesVideo
|
138
|
+
|
139
|
+
@objc.signature("v@:@")
|
140
|
+
def didAddSubview_(self, subview):
|
141
|
+
pass
|
142
|
+
# NSLog(u'A subview was added')
|
143
|
+
|
144
|
+
# def __del__(self):
|
145
|
+
# self._delegate = None
|
146
|
+
# self._backColor = None
|
147
|
+
# self.layoutManager = None
|
148
|
+
|
149
|
+
#app = QtGui.QApplication(sys.argv)
|
150
|
+
|
151
|
+
|
152
|
+
"""This is the QtGui widget that will actually hold our video NSView video object defined above"""
|
153
|
+
class MacVideo(QtGui.QWidget):
|
154
|
+
|
155
|
+
def __init__(self, parent=None):
|
156
|
+
super(MacVideo,self).__init__(parent)
|
157
|
+
self.videoLayout = QtGui.QVBoxLayout()
|
158
|
+
self.videoLayout.setContentsMargins(0,0,0,0)
|
159
|
+
self.setLayout(self.videoLayout)
|
160
|
+
|
161
|
+
|
162
|
+
def createVideoWindow(self,media_player):
|
163
|
+
videoWidget = QtGui.QMacCocoaViewContainer(None)
|
164
|
+
self.videoLayout.addWidget(videoWidget)
|
165
|
+
videoView = VLCVideoView.alloc().init()
|
166
|
+
videoWidget.setCocoaView(sip.voidptr(objc.pyobjc_id(videoView)))
|
167
|
+
media_player.set_nsobject(objc.pyobjc_id(videoView))
|
168
|
+
videoView.release()
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
class MacPlayer(QtGui.QWidget):
|
174
|
+
|
175
|
+
|
176
|
+
def __init__(self, player, parent=None):
|
177
|
+
super(MacPlayer,self).__init__(parent)
|
178
|
+
self.media_player = player
|
179
|
+
self.instance = self.media_player.get_instance()
|
180
|
+
self.videoWidget = None
|
181
|
+
|
182
|
+
#import the Qt interface defined in VideoMac.ui
|
183
|
+
self.win = uic.loadUi("VideoMac.ui")
|
184
|
+
|
185
|
+
"""the poller is just a simple way to create an event to update the
|
186
|
+
position slider and do any other interface updates we need"""
|
187
|
+
self.poller = QtCore.QTimer(self)
|
188
|
+
|
189
|
+
#connect all of the buttons and sliders defined in the imported interface
|
190
|
+
self.poller.timeout.connect(self.updateInterface)
|
191
|
+
self.positionSlider = self.win.positionSlider
|
192
|
+
self.positionSlider.setMaximum(TIME_RES)
|
193
|
+
self.positionSlider.sliderPressed.connect(self.positionChanging)
|
194
|
+
self.positionSlider.sliderReleased.connect(self.positionChanged)
|
195
|
+
self.win.pauseButton.clicked.connect(self.play_pause)
|
196
|
+
self.win.stopButton.clicked.connect(self.stop)
|
197
|
+
|
198
|
+
#start the poller and tell it to timeout every .1 s
|
199
|
+
self.poller.start(100)
|
200
|
+
|
201
|
+
#create the actual widget that will hold the vlc video
|
202
|
+
videoWidget = MacVideo()
|
203
|
+
videoWidget.createVideoWindow(self.media_player)
|
204
|
+
self.win.videoLayout.setContentsMargins(0,0,0,0)
|
205
|
+
self.win.videoLayout.addWidget(videoWidget)
|
206
|
+
self.win.show()
|
207
|
+
|
208
|
+
|
209
|
+
def play(self):
|
210
|
+
self.media_player.play()
|
211
|
+
self.show()
|
212
|
+
|
213
|
+
|
214
|
+
# right now if you try to stop the player on a mac, it crashes the program
|
215
|
+
def stop(self, checked):
|
216
|
+
# if self.videoWidget:
|
217
|
+
# self.videoWidget= None
|
218
|
+
# if self.media_player.get_media() is not None and self.media_descr is not None:
|
219
|
+
# self.media_player.stop()
|
220
|
+
# self.isPlaying = False
|
221
|
+
# self.media_player.stop()
|
222
|
+
return
|
223
|
+
|
224
|
+
def changeVolume(self, newVolume):
|
225
|
+
self.instance.audio_set_volume(newVolume)
|
226
|
+
|
227
|
+
def positionChanging(self):
|
228
|
+
self.poller.stop()
|
229
|
+
|
230
|
+
def positionChanged(self):
|
231
|
+
self.changePosition()
|
232
|
+
self.poller.start(100)
|
233
|
+
|
234
|
+
def play_pause(self,checked):
|
235
|
+
if checked or self.media_player.is_playing():
|
236
|
+
self.media_player.pause()
|
237
|
+
else:
|
238
|
+
self.media_player.play()
|
239
|
+
|
240
|
+
def changePosition(self, newPosition=None):
|
241
|
+
if not self.media_player.is_playing():
|
242
|
+
return
|
243
|
+
if self.media_player.get_media() is None:
|
244
|
+
return
|
245
|
+
newPosition = self.positionSlider.sliderPosition()
|
246
|
+
self.media_player.set_position(float(newPosition)/float(TIME_RES))
|
247
|
+
|
248
|
+
|
249
|
+
|
250
|
+
def updateInterface(self):
|
251
|
+
if not self.media_player.is_playing():
|
252
|
+
return
|
253
|
+
if self.media_player.get_media() is None:
|
254
|
+
return
|
255
|
+
a = self.media_player.get_position()
|
256
|
+
self.positionSlider.setValue(self.media_player.get_position()*TIME_RES)
|
257
|
+
|
@@ -0,0 +1,102 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<ui version="4.0">
|
3
|
+
<class>mainLayout</class>
|
4
|
+
<widget class="QWidget" name="mainLayout">
|
5
|
+
<property name="windowModality">
|
6
|
+
<enum>Qt::ApplicationModal</enum>
|
7
|
+
</property>
|
8
|
+
<property name="geometry">
|
9
|
+
<rect>
|
10
|
+
<x>0</x>
|
11
|
+
<y>0</y>
|
12
|
+
<width>639</width>
|
13
|
+
<height>479</height>
|
14
|
+
</rect>
|
15
|
+
</property>
|
16
|
+
<property name="sizePolicy">
|
17
|
+
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
18
|
+
<horstretch>0</horstretch>
|
19
|
+
<verstretch>0</verstretch>
|
20
|
+
</sizepolicy>
|
21
|
+
</property>
|
22
|
+
<property name="mouseTracking">
|
23
|
+
<bool>true</bool>
|
24
|
+
</property>
|
25
|
+
<property name="windowTitle">
|
26
|
+
<string/>
|
27
|
+
</property>
|
28
|
+
<property name="autoFillBackground">
|
29
|
+
<bool>true</bool>
|
30
|
+
</property>
|
31
|
+
<widget class="QPushButton" name="pauseButton">
|
32
|
+
<property name="geometry">
|
33
|
+
<rect>
|
34
|
+
<x>0</x>
|
35
|
+
<y>461</y>
|
36
|
+
<width>81</width>
|
37
|
+
<height>21</height>
|
38
|
+
</rect>
|
39
|
+
</property>
|
40
|
+
<property name="text">
|
41
|
+
<string>Play/Pause</string>
|
42
|
+
</property>
|
43
|
+
<property name="checkable">
|
44
|
+
<bool>true</bool>
|
45
|
+
</property>
|
46
|
+
<property name="flat">
|
47
|
+
<bool>false</bool>
|
48
|
+
</property>
|
49
|
+
</widget>
|
50
|
+
<widget class="QPushButton" name="stopButton">
|
51
|
+
<property name="geometry">
|
52
|
+
<rect>
|
53
|
+
<x>80</x>
|
54
|
+
<y>461</y>
|
55
|
+
<width>51</width>
|
56
|
+
<height>20</height>
|
57
|
+
</rect>
|
58
|
+
</property>
|
59
|
+
<property name="text">
|
60
|
+
<string>Stop</string>
|
61
|
+
</property>
|
62
|
+
<property name="flat">
|
63
|
+
<bool>false</bool>
|
64
|
+
</property>
|
65
|
+
</widget>
|
66
|
+
<widget class="QSlider" name="positionSlider">
|
67
|
+
<property name="geometry">
|
68
|
+
<rect>
|
69
|
+
<x>140</x>
|
70
|
+
<y>462</y>
|
71
|
+
<width>451</width>
|
72
|
+
<height>20</height>
|
73
|
+
</rect>
|
74
|
+
</property>
|
75
|
+
<property name="sizePolicy">
|
76
|
+
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
77
|
+
<horstretch>1</horstretch>
|
78
|
+
<verstretch>0</verstretch>
|
79
|
+
</sizepolicy>
|
80
|
+
</property>
|
81
|
+
<property name="maximum">
|
82
|
+
<number>100</number>
|
83
|
+
</property>
|
84
|
+
<property name="orientation">
|
85
|
+
<enum>Qt::Horizontal</enum>
|
86
|
+
</property>
|
87
|
+
</widget>
|
88
|
+
<widget class="QWidget" name="verticalLayoutWidget">
|
89
|
+
<property name="geometry">
|
90
|
+
<rect>
|
91
|
+
<x>0</x>
|
92
|
+
<y>0</y>
|
93
|
+
<width>641</width>
|
94
|
+
<height>461</height>
|
95
|
+
</rect>
|
96
|
+
</property>
|
97
|
+
<layout class="QVBoxLayout" name="videoLayout"/>
|
98
|
+
</widget>
|
99
|
+
</widget>
|
100
|
+
<resources/>
|
101
|
+
<connections/>
|
102
|
+
</ui>
|
@@ -0,0 +1,197 @@
|
|
1
|
+
#! /usr/bin/python
|
2
|
+
import vlc
|
3
|
+
import sys
|
4
|
+
import time
|
5
|
+
from threading import Thread, Event
|
6
|
+
from bisect import bisect
|
7
|
+
from subtitle import readSrt
|
8
|
+
from mergeCommands import merge
|
9
|
+
|
10
|
+
DEBUG = True
|
11
|
+
|
12
|
+
def sendDebug(msg, newline=1):
|
13
|
+
global DEBUG
|
14
|
+
if DEBUG:
|
15
|
+
if newline:
|
16
|
+
print ' '
|
17
|
+
print msg
|
18
|
+
|
19
|
+
@vlc.callbackmethod
|
20
|
+
def playPauseCallback(event, data):
|
21
|
+
#do we need to do anything else here?
|
22
|
+
sendDebug('Got a callback')
|
23
|
+
thread1.event.set()
|
24
|
+
|
25
|
+
@vlc.callbackmethod
|
26
|
+
def positionCallback(event, data):
|
27
|
+
#should probably do something here
|
28
|
+
thread1.event.set()
|
29
|
+
|
30
|
+
|
31
|
+
# For now I need to define the path, I commented out so it should work for you guys
|
32
|
+
#path = 'C:\Users\cuff\Documents\moonlight\movie-content-editor\movie_editor\\'
|
33
|
+
path = ''
|
34
|
+
|
35
|
+
|
36
|
+
badwordsFile = "badwords.txt"
|
37
|
+
movieFile = "Kung Fu Panda.m4v"
|
38
|
+
subtitleFile = "panda.srt"
|
39
|
+
blankFile = "blank.srt"
|
40
|
+
customFile = "panda_custom.txt"
|
41
|
+
|
42
|
+
# ------ create edited subtitle file ------
|
43
|
+
subtitleEdit = readSrt(path,subtitleFile,badwordsFile)
|
44
|
+
# --------------------------------------------
|
45
|
+
|
46
|
+
# ------- create list of commands ----------
|
47
|
+
commands = merge(path,customFile)
|
48
|
+
# -----------------------------------------
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
# -------- Load and start movie ----------------
|
54
|
+
"""Set up the system independent movie interface. For windows, we can just use the
|
55
|
+
default Qt interface. For mac, we have to use our custom built interface. Nothing is
|
56
|
+
currently implemented for Linux"""
|
57
|
+
|
58
|
+
if sys.platform == 'darwin':
|
59
|
+
d='/Applications/VLC.app/Contents/MacOS'
|
60
|
+
args1 = "-I dummy --verbose=-1 --ignore-config --plugin-path="
|
61
|
+
if sendDebug:
|
62
|
+
args1 = "-I dummy --verbose=1 --ignore-config --plugin-path="
|
63
|
+
vlc_args = (args1 + d + "/modules --vout=minimal_macosx --opengl-provider=minimal_macosx")
|
64
|
+
instance = vlc.Instance(vlc_args)
|
65
|
+
else:
|
66
|
+
instance = vlc.Instance()
|
67
|
+
instance.add_intf("qt")
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
media = instance.media_new(path + movieFile)
|
72
|
+
player = instance.media_player_new()
|
73
|
+
player.set_media(media)
|
74
|
+
|
75
|
+
if sys.platform == 'darwin':
|
76
|
+
from PyQt4 import QtGui
|
77
|
+
from VLCMacVideo import MacPlayer
|
78
|
+
app = QtGui.QApplication(sys.argv)
|
79
|
+
mplayer = MacPlayer(player)
|
80
|
+
|
81
|
+
events = vlc.EventType
|
82
|
+
|
83
|
+
manager = player.event_manager()
|
84
|
+
mediaManager = media.event_manager()
|
85
|
+
manager.event_attach(events.MediaPlayerPaused,playPauseCallback,None)
|
86
|
+
#manager.event_attach(events.MediaPlayerPausableChanged,dummy,None)
|
87
|
+
manager.event_attach(events.MediaPlayerPlaying,playPauseCallback,None)
|
88
|
+
#manager.event_attach(events.MediaPlayerTimeChanged,dummy,None)
|
89
|
+
#mediaManager.event_attach(events.MediaStateChanged,dummy,None)
|
90
|
+
manager.event_attach(events.MediaPlayerPositionChanged,positionCallback,None)
|
91
|
+
player.play()
|
92
|
+
# -------------------------------------------------
|
93
|
+
|
94
|
+
# I use this for testing with Panda
|
95
|
+
player.set_time(33000)
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
# ------------- subclass off of Thread ---------------
|
100
|
+
class editThread (Thread):
|
101
|
+
event = Event()
|
102
|
+
|
103
|
+
def run ( self ):
|
104
|
+
|
105
|
+
sendDebug(commands)
|
106
|
+
#puts the keys in order - the keys are the time stamps of when the player state needs to change
|
107
|
+
sortedKeys = sorted(commands.keys())
|
108
|
+
sendDebug(sortedKeys)
|
109
|
+
currKey = 0.0
|
110
|
+
nextKey = 0.0
|
111
|
+
while True:
|
112
|
+
#if player isn't playing, wait for it to start
|
113
|
+
if not player.is_playing:
|
114
|
+
self.event.clear()
|
115
|
+
self.event.wait()
|
116
|
+
|
117
|
+
#clear any old events so they don't continue to trigger a response
|
118
|
+
self.event.clear()
|
119
|
+
|
120
|
+
now = float(player.get_time())/1000.0
|
121
|
+
|
122
|
+
# find the correct portion of the timeline
|
123
|
+
|
124
|
+
# if we're actually at a new part of the timeline, then change the state
|
125
|
+
if not (currKey<= now <nextKey):
|
126
|
+
nextInd = bisect(sortedKeys,now)
|
127
|
+
nextKey = sortedKeys[nextInd]
|
128
|
+
sendDebug('New State')
|
129
|
+
currInd = nextInd - 1
|
130
|
+
currKey = sortedKeys[currInd]
|
131
|
+
sendDebug(currKey)
|
132
|
+
|
133
|
+
#Get the Playable and MuteOn attributes for the current state and act on them
|
134
|
+
Playable,MuteOn = commands[currKey]
|
135
|
+
if not Playable:
|
136
|
+
skip(nextKey*1000)
|
137
|
+
|
138
|
+
if MuteOn:
|
139
|
+
onMute()
|
140
|
+
else:
|
141
|
+
offMute()
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
# wait for the next portion of the timeline, or for an user event to occur
|
146
|
+
# this is probably unnecessary because the PositionChanged event seems to occur
|
147
|
+
# every 0.5 s or so
|
148
|
+
waitTime = nextKey - float(player.get_time())/1000.0
|
149
|
+
if waitTime > 30.0:
|
150
|
+
self.event.wait(waitTime - 30.0)
|
151
|
+
waitTime = nextKey - float(player.get_time())/1000.0
|
152
|
+
self.event.wait(waitTime)
|
153
|
+
|
154
|
+
|
155
|
+
return
|
156
|
+
|
157
|
+
# ------------------------------------------------------
|
158
|
+
|
159
|
+
# ------- methods -------------------------
|
160
|
+
def onMute ():
|
161
|
+
sendDebug("Muting started %s" % (float(player.get_time())/1000.0))
|
162
|
+
player.video_set_subtitle_file(path + subtitleEdit)
|
163
|
+
instance.audio_set_mute(1)
|
164
|
+
return
|
165
|
+
|
166
|
+
def offMute ():
|
167
|
+
sendDebug("Muting stopped %s" % (float(player.get_time())/1000.0))
|
168
|
+
player.video_set_subtitle_file(path + blankFile)
|
169
|
+
# player.video_set_spu("Testing SPU")
|
170
|
+
instance.audio_set_mute(0)
|
171
|
+
return
|
172
|
+
|
173
|
+
def skip(tSkip):
|
174
|
+
sendDebug('Skipping ahead')
|
175
|
+
player.set_time(long(tSkip))
|
176
|
+
return
|
177
|
+
|
178
|
+
def stop(player):
|
179
|
+
if sys.platform != 'darwin':
|
180
|
+
player.stop()
|
181
|
+
sys.exit()
|
182
|
+
# --------------------------------------------
|
183
|
+
|
184
|
+
thread1 = editThread()
|
185
|
+
thread1.start()
|
186
|
+
|
187
|
+
|
188
|
+
if sys.platform == 'darwin':
|
189
|
+
app.exec_()
|
190
|
+
else:
|
191
|
+
# this is temporary just so player doesn't go on for long time
|
192
|
+
#time.sleep((80-player.get_time()/1000))
|
193
|
+
instance.wait()
|
194
|
+
|
195
|
+
stop(player)
|
196
|
+
|
197
|
+
|