4
class BasePlayer(gtk.Object):
5
"""Interfaces between a QL PlaylistModel and a GSt playbin.
8
paused -- True or False, set to pause/unpause the player
9
volume -- current volume, 0.0 to 1.0
11
song -- current song, or None if not playing
12
info -- current stream information, or None if not playing. This is
13
usually the same as song, unless the user is listening to
14
a stream with multiple songs in it.
16
If you're going to show things, use .info. If you're going to
17
change things, use .song.
24
# Replay Gain profiles are a list of values to be tried in order;
25
# Three things can set them: play order, browser, and a default.
26
replaygain_profiles = [None, None, ["none"]]
32
(gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (object,)),
34
(gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (object, bool)),
36
(gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (object, int)),
37
'paused': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
38
'unpaused': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
39
'error': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
44
'volume': (float, 'player volume', 'the volume of the player',
45
0.0, 1.0, 1.0, gobject.PARAM_READWRITE)
48
def __init__(self, *args, **kwargs):
49
super(BasePlayer, self).__init__()
51
def do_song_started(self, song):
52
# Reset Replay Gain levels based on the new song.
53
self.volume = self.volume
55
def do_song_ended(self, song, stopped):
56
self.volume = self.volume
58
def do_get_property(self, property):
59
if property.name == 'volume':
61
else: raise AttributeError
63
def _set_volume(self, v):
64
self.props.volume = min(1.0, max(0.0, v))
65
volume = property(lambda s: s._volume, _set_volume)
67
def setup(self, source, song):
68
"""Connect to a PlaylistModel, and load a song."""
72
def remove(self, song):
82
if self._source.current is not None:
94
# Go back if standing at the beginning of the song,
95
# otherwise restart the current song.
96
if self.get_position() < 500:
97
self._source.previous()
104
def go_to(self, song):
105
print_d("Going to %r" % song, context=self)
106
self._source.go_to(song)
111
super(BasePlayer, self).destroy()