Touchscreen audio controller for presentation sound

The stop Function

The stop function (lines 52-56) uses the opposite logic from play above, but otherwise they are identical. Line 53 calls self.track.fadeout, which will fade the track over the provided number of milliseconds and then stop – 1000 in this case.

The controls Function

The controls function (lines 58-75) creates the volume buttons used for background sounds. Much of it is code you've seen before. Line 59 creates a list for the buttons to be stored in. Then, lines 61-64 create the "Volume Up" button. It's the same code as the play button above, just with a different label. Lines 67-70 are also the same.

Lines 65 and 71 add a tuple to self.buttons. The first part is the surface of the button itself. The second part is the caption, or a unique identifier indicating which sound this button belongs to. The last part is a string that says which command this button is associated with. Line 73 calls self.drawPlayButton, so calling self.controls will regenerate all of the buttons. Finally, line 75 returns the list of buttons.

Buy this article as PDF

Express-Checkout as PDF

Pages: 2

Price $2.95
(incl. VAT)

Buy Raspberry Pi Geek

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content