Skip to content

Commit 2442091

Browse files
committed
android/sound: fix audio volume not implemented. Closes kivy/kivy#1869
1 parent 05cb347 commit 2442091

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

recipes/android/src/android/mixer.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,10 @@ def fadeout(self, time):
131131
self.stop()
132132

133133
def set_volume(self, left, right=None):
134-
# Not implemented.
135-
return
134+
sound.set_volume(self.id, left)
136135

137136
def get_volume(self):
138-
return 1.0
137+
return sound.get_volume(self.id)
139138

140139
def get_busy(self):
141140
return sound.busy(self.id)
@@ -193,6 +192,7 @@ def __init__(self, what):
193192
global sound_serial
194193

195194
self._channel = None
195+
self._volume = 1.
196196
self.serial = str(sound_serial)
197197
sound_serial += 1
198198

@@ -210,6 +210,7 @@ def play(self, loops=0, maxtime=0, fade_ms=0):
210210
if self._channel.get_sound() is self:
211211
return
212212
self._channel = channel = find_channel(True)
213+
channel.set_volume(self._volume)
213214
channel.play(self, loops=loops)
214215
return channel
215216

@@ -223,10 +224,13 @@ def fadeout(self, time):
223224
self.stop()
224225

225226
def set_volume(self, left, right=None):
226-
return
227+
self._volume = left
228+
if self._channel:
229+
if self._channel.get_sound() is self:
230+
self._channel.set_volume(self._volume)
227231

228232
def get_volume(self):
229-
return 1.0
233+
return self._volume
230234

231235
def get_num_channels(self):
232236
rv = 0

0 commit comments

Comments
 (0)