mirror of
https://github.com/DYefremov/DemonEditor.git
synced 2026-07-04 15:38:14 +02:00
test nso
This commit is contained in:
@@ -11,5 +11,8 @@ Python >= **3.5**, GTK+ >= **3.16**, pygobject3, adwaita-icon-theme, python3-req
|
||||
```brew install python3 gtk+3 pygobject3 adwaita-icon-theme```
|
||||
```pip3 install requests```
|
||||
|
||||
**Optional:**
|
||||
```pip3 install pyobjc```
|
||||
|
||||
### Launching
|
||||
To start the program, just download the archive, unpack and run it from the terminal with the command: ```./start.py```
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import sys
|
||||
|
||||
from app.commons import run_task
|
||||
from app.tools import vlc
|
||||
from app.tools.vlc import EventType
|
||||
@@ -21,12 +23,56 @@ class Player:
|
||||
lambda e, p: position_callback(p.get_time()),
|
||||
self._player)
|
||||
|
||||
@staticmethod
|
||||
def get_vlc_instance():
|
||||
def get_vlc_instance(self):
|
||||
if Player._VLC_INSTANCE:
|
||||
return Player._VLC_INSTANCE
|
||||
_VLC_INSTANCE = vlc.Instance("--quiet --no-xlib").media_player_new()
|
||||
return _VLC_INSTANCE
|
||||
|
||||
if not sys.platform.startswith("darwin"):
|
||||
raise ImportError('This implementation only supported on MacOS')
|
||||
|
||||
try:
|
||||
view = Player.get_nso()
|
||||
except ImportError as e:
|
||||
raise e
|
||||
else:
|
||||
self._VLC_INSTANCE = vlc.Instance().media_player_new()
|
||||
self._VLC_INSTANCE.set_nsobject(view.__c_void_p__())
|
||||
|
||||
return self._VLC_INSTANCE
|
||||
|
||||
@staticmethod
|
||||
def get_nso():
|
||||
""" This code based on pyobjcvlc.py example
|
||||
from here: https://github.com/oaubert/python-vlc/tree/master/examples
|
||||
"""
|
||||
try:
|
||||
from objc import __version__ as __PyObjC__
|
||||
except ImportError:
|
||||
raise ImportError("No PyObjC is installed!")
|
||||
else:
|
||||
from Cocoa import NSBackingStoreBuffered, NSBundle, NSScreen, NSMakeRect, NSView, NSWindow
|
||||
|
||||
try:
|
||||
from Cocoa import NSWindowStyleMaskClosable, NSWindowStyleMaskMiniaturizable, \
|
||||
NSWindowStyleMaskResizable, NSWindowStyleMaskTitled
|
||||
except ImportError as e:
|
||||
raise e
|
||||
|
||||
NSWindowStyleMaskUsual = NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable \
|
||||
| NSWindowStyleMaskResizable | NSWindowStyleMaskTitled
|
||||
frame = NSScreen.mainScreen().frame()
|
||||
w = int(frame.size.width * 0.5)
|
||||
h = int(frame.size.height * w / frame.size.width)
|
||||
frame = NSMakeRect(frame.origin.x + 10, frame.origin.y + 10, w, h)
|
||||
window = NSWindow.alloc().initWithContentRect_styleMask_backing_defer_(frame,
|
||||
NSWindowStyleMaskUsual,
|
||||
NSBackingStoreBuffered,
|
||||
False)
|
||||
view = NSView.alloc().initWithFrame_(frame)
|
||||
window.setContentView_(view)
|
||||
window.setContentAspectRatio_(frame.size)
|
||||
window.makeKeyAndOrderFront_(None)
|
||||
return view
|
||||
|
||||
@run_task
|
||||
def play(self, mrl=None):
|
||||
|
||||
@@ -1561,8 +1561,12 @@ class Application(Gtk.Application):
|
||||
try:
|
||||
self._player = Player(rewind_callback=self.on_player_duration_changed,
|
||||
position_callback=self.on_player_time_changed)
|
||||
except (NameError, AttributeError):
|
||||
self.show_error_dialog("No VLC is found. Check that it is installed!")
|
||||
except (NameError, AttributeError, ImportError) as e:
|
||||
if type(e) is ImportError:
|
||||
self.show_error_dialog(str(e))
|
||||
else:
|
||||
self.show_error_dialog("No VLC is found. Check that it is installed!")
|
||||
log(str(e))
|
||||
return
|
||||
|
||||
self._player_box.set_visible(True)
|
||||
|
||||
Reference in New Issue
Block a user