Skip to content

Commit 2b75c09

Browse files
authored
Update of cocoavlc.py example (#197)
[PyCocoa 21.11.02](https://github.com/mrJean1/PyCocoa) is required since that includes several updates to run on macOS 12.0.1 Monterey. Added an attempt to force the video to fill the window, see this [PyCocoa issue](mrJean1/PyCocoa#3).
1 parent b2ef0e0 commit 2b75c09

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

examples/cocoavlc.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
1-
#! /usr/bin/env python3
1+
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33

44
# Example of using PyCocoa <https://PyPI.org/project/PyCocoa> to create a
55
# window, table and an application menu to run a video using VLC on macOS.
66
# The Python-VLC binding <https://PyPI.Python.org/pypi/python-vlc> and the
77
# corresponding VLC App, see <https://www.VideoLan.org/index.html>.
88

9-
# PyCocoa version 21.8.18 or later must be installed.
9+
# PyCocoa version 21.11.02 or later must be installed (on macOS Monterey)
1010

11-
# This VLC player has been tested with VLC 3.0.10-12, 3.0.6-8, 3.0.4,
11+
# This VLC player has been tested with VLC 3.0.10-16, 3.0.6-8, 3.0.4,
1212
# 3.0.1-2, 2.2.8 and 2.2.6 and the compatible vlc.py Python-VLC binding
13-
# using 64-bit Python 3.10.0.rc1, 3.9.6, 3.9.0-1, 3.8.10, 3.8.6, 3.7.0-4,
14-
# 3.6.4-5 and 2.7.14-18 on macOS 11.5.2 Big Sur (aka 10.16), 10.15.6
15-
# Catalina, 10.14.6 Mojave and 10.13.4-6 High Sierra. This player
16-
# does not work with PyPy <https://PyPy.org> nor with Intel(R) Python
17-
# <https://Software.Intel.com/en-us/distribution-for-python>. Python
18-
# 3.10.0rc1, 3.9.6 and macOS' Python 2.7.16 run on Apple Silicon (C{arm64}),
19-
# all other Python versions run on Intel (C{x86_64}) or I{emulated} Intel
20-
# (C{"arm64_x86_64"}, see function C{pycocoa.machine}).
13+
# using 64-bit Python 3.10.0, 3.9.6, 3.9.0-1, 3.8.10, 3.8.6, 3.7.0-4,
14+
# 3.6.4-5 and 2.7.14-18 on macOS 12.0.1 Monterey, 11.5.2-6.1 Big Sur
15+
# (aka 10.16), 10.15.6 Catalina, 10.14.6 Mojave and 10.13.4-6 High Sierra.
16+
# This player does not work with PyPy <https://PyPy.org> nor with Intel(R)
17+
# Python <https://Software.Intel.com/en-us/distribution-for-python>.
18+
19+
# Python 3.10.0, 3.9.6 and macOS' Python 2.7.16 run on Apple Silicon
20+
# (C{arm64} I{natively}), all other Python versions run on Intel (C{x86_64})
21+
# or I{emulated} Intel (C{"arm64_x86_64"}, see function C{pycocoa.machine}).
2122

2223
# MIT License <https://OpenSource.org/licenses/MIT>
2324
#
@@ -45,7 +46,7 @@ def _PyPI(package):
4546
return 'see <https://PyPI.org/project/%s>' % (package,)
4647

4748
__all__ = ('AppVLC',) # PYCHOK expected
48-
__version__ = '21.08.18'
49+
__version__ = '21.11.02'
4950

5051
try:
5152
import vlc
@@ -479,11 +480,16 @@ def _resizer(self): # adjust aspect ratio and marquee height
479480
else:
480481
Thread(target=self._sizer).start()
481482

482-
def _sizer(self, secs=0.1):
483+
def _sizer(self, secs=0.25):
483484
while True:
484-
w, h = self.player.video_get_size(0)
485+
p = self.player
486+
# wiggle the video to fill the window
487+
s = p.video_get_scale()
488+
p.video_set_scale(0.0 if s else 1.0)
489+
p.video_set_scale(s)
485490
# the first call(s) returns (0, 0),
486491
# subsequent calls return (w, h)
492+
w, h = p.video_get_size(0)
487493
if h > 0 and w > 0:
488494
# window's contents' aspect ratio
489495
self.window.ratio = self.sized = w, h

0 commit comments

Comments
 (0)