-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexample.py
More file actions
75 lines (64 loc) · 2.61 KB
/
example.py
File metadata and controls
75 lines (64 loc) · 2.61 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
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
# Example module
# Copyright (C) 2014 Musikhin Andrey <melomansegfault@gmail.com>
import atexit
import time
from player import Player, MPLAYER_PATH, STDOUT_PATH, PIPE_PATH, PID_PATH
class ExamplePlayer(object):
"""Example Player class"""
def __init__(self, *arg):
super(ExamplePlayer, self).__init__()
# Initializing the player
player = Player(mplayer=MPLAYER_PATH, pipe=PIPE_PATH,
stdout=STDOUT_PATH, pid=PID_PATH, debug=False)
# Adding the '-nolirc' option to the mplayer start command
player.add_command_option(option='-nolirc')
# Adding the 'equalizer' audio filter to the mplayer start command
player.add_command_option(option='-af',
value='equalizer=-5:-5:-5:8:8:8:-5:-5:-12:-12')
# Create new mplayer process
player.create_new_process()
atexit.register(player.process.terminate)
# Print process name
print 'PROCESS NAME: ', player.process.name
# Print process pid
print 'PROCESS PID: ', player.process.pid
# Print help text for Player class and it's properties
print help(player)
print help(player.properties)
# Call 'loadfile' command
player.loadfile("/home/user/music/sound.ogg") # For Unix
# player.loadfile("C:\music\sound.ogg") # For Windows
# Edit equalizer filter
player.af_cmdline('equalizer', '0:0:0:0:0:0:0:0:0:0')
for i in range(11):
time.sleep(0.5)
print '~'*79
# Get an answer using commands
print player.get_percent_pos()
print player.get_time_pos()
print player.get_time_length()
print player.get_file_name()
print player.get_meta_title()
# Get an answer using properties
print player.properties.volume
print player.properties.audio_bitrate
print player.properties.channels
print player.properties.length
print player.properties.percent_pos
print player.properties.stream_length
# Set player properties
player.properties.volume = i*10
time.sleep(2)
# Unloadi equalizer filter
player.af_del('equalizer')
# Connection to the existing process (Only Unix)
# player.connect_to_process()
# print player.get_percent_pos()
# print player.get_time_pos()
# time.sleep(1)
# Kill mplayer process
player.quit()
if __name__ == '__main__':
example_player = ExamplePlayer()