-
Notifications
You must be signed in to change notification settings - Fork 0
/
cluttermedia.py
86 lines (65 loc) · 1.93 KB
/
cluttermedia.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env python3
# ClutterMedia - A simple media player for clutter
from gi.repository import Gst
from gi.repository import ClutterGst
def init():
#Gst.init()
ClutterGst.init()
gPlayer = None
gPlayType = '?'
gVideoContentUI = None
def play_audio(sFile):
global gPlayer, gPlayType
stop()
print("INFO:CM:PlayA", sFile)
gPlayer = ClutterGst.Playback()
gPlayer.set_filename(sFile)
gPlayer.set_audio_volume(0.6)
gPlayer.set_playing(True)
gPlayType = 'A'
def pause():
if (gPlayer != None) and (gPlayType != '?'):
gPlayer.set_playing(False)
def unpause():
if (gPlayer != None) and (gPlayType != '?'):
gPlayer.set_playing(True)
def stop(cleanup=False):
global gPlayType
if gPlayer != None:
print("INFO:CM:Stop in case")
gPlayer.set_playing(False)
gPlayType = '?'
if cleanup:
pass
def play_video(sFile, ui):
global gPlayer, gPlayType
stop()
print("INFO:CM:PlayV", sFile)
gPlayer = ClutterGst.Playback()
gPlayer.set_filename(sFile)
gPlayer.set_audio_volume(0.6)
cgstContent = ClutterGst.Aspectratio()
cgstContent.set_player(gPlayer)
ui.set_content(cgstContent)
gVideoContentUI = cgstContent
#ui.show()
# default content gravity is resize fill, so things should be fine.
# need to check, if I require to set the scaling filters explicitly or default is good enough.
gPlayer.set_playing(True)
gPlayType = 'V'
def volup():
if (gPlayer != None) and (gPlayType != '?'):
vol = gPlayer.get_audio_volume()
vol += 0.1
if (vol > 1.0):
vol = 1.0
gPlayer.set_audio_volume(vol)
print("INFO:volup:", vol)
def voldown():
if (gPlayer != None) and (gPlayType != '?'):
vol = gPlayer.get_audio_volume()
vol -= 0.1
if (vol < 0):
vol = 0
gPlayer.set_audio_volume(vol)
print("INFO:voldown:", vol)