-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmyvlc.py
More file actions
64 lines (53 loc) · 1.69 KB
/
myvlc.py
File metadata and controls
64 lines (53 loc) · 1.69 KB
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
'''
(*)~----------------------------------------------------------------------------------
Wrapper class for VLC Python API
Author: Jonas Ditz
Date: 21. September 2017
----------------------------------------------------------------------------------~(*)
'''
import vlc
class VLC:
def __init__(self):
"""A simple Media Player using VLC
"""
# creating a basic vlc instance
self.instance = vlc.Instance("--no-xlib")
# creating an empty vlc media player
self.mediaplayer = self.instance.media_player_new()
def play_pause(self):
"""Toggle play/pause status
"""
if self.mediaplayer.is_playing():
self.mediaplayer.pause()
else:
if self.mediaplayer.play() == -1:
return
self.mediaplayer.play()
def play(self):
"""Play player
"""
if self.mediaplayer.is_playing():
return
self.mediaplayer.play()
def pause(self):
"""Pause player
"""
if self.mediaplayer.is_playing():
self.mediaplayer.pause()
def stop(self):
"""Stop player
"""
self.mediaplayer.stop()
def open_file(self, filename = None):
"""Open a video file and load it into the Media Player
"""
if filename == None:
return
# create the media
self.media = self.instance.media_new(filename)
# put the media in the media player
self.mediaplayer.set_media(self.media)
def set_volume(self, Volume):
"""Set the volume
"""
self.mediaplayer.audio_set_volume(Volume)