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
83
|
import os
from playlist import Playlist
from abcontroller import ABController
from session_manager import SessionManager
from player_vlc import Player
class SoloTool:
def __init__(self, player=None):
self._player = Player() if player is None else player
self._playlist = Playlist(self._playlistCallback)
self._abController = ABController(enabled=False, callback=self._abControllerCallback)
self._sessionManager = SessionManager(self._playlist, self._abController)
def _playlistCallback(self, path):
self._player.setCurrentSong(path)
self._abController.setCurrentSong(path)
def _abControllerCallback(self, position):
self._player.setPlaybackPosition(position)
def tick(self):
position = self._player.getPlaybackPosition()
self._abController.positionChanged(position)
def addSong(self, path):
if os.path.isfile(path):
self._sessionManager.addSong(path)
def setSong(self, index):
self._playlist.setCurrentSong(index)
# XXX untested
def getSongs(self):
return self._playlist.getSongs()
def addAbLimit(self, aLimit, bLimit):
self._abController.addLimits(aLimit, bLimit)
def setAbLimit(self, index):
self._abController.setCurrentLimits(index)
# XXX untested
def getAbLimits(self):
currentSong = self._playlist.getCurrentSong()
if currentSong is not None:
return self._abController.getLimits(currentSong)
else:
return list()
def setAbLimitEnable(self, enable):
self._abController.setEnable(enable)
def loadSession(self, path):
with open(path, "r") as f:
self._sessionManager.loadSession(f)
def saveSession(self, path):
with open(path, "w") as f:
self._sessionManager.saveSession(f)
def play(self):
self._player.play()
def pause(self):
self._player.pause()
def stop(self):
self._player.stop()
def setPlaybackRate(self, rate):
self._player.setPlaybackRate(rate)
def setPlaybackPosition(self, position):
self._player.setPlaybackPosition(position)
# XXX untested
def getPlaybackPosition(self):
return self._player.getPlaybackPosition()
def setPlaybackVolume(self, volume):
self._player.setPlaybackVolume(volume)
|