Skip to content

Commit

Permalink
Background music added
Browse files Browse the repository at this point in the history
  • Loading branch information
greeshnasarath committed Dec 5, 2023
1 parent 417de96 commit 134f7e9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions MathsTutor/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import threading
import math
import random
import pygame

class MathsTutorWindow(Gtk.Window):
def __init__(self):
Expand All @@ -43,6 +44,14 @@ def __init__(self):
# initialize Gstreamer
Gst.init(None)

# Initialize pygame mixer
pygame.mixer.init()

# Load and play the background music
pygame.mixer.music.load('/usr/share/maths-tutor/sounds/backgroundmusic.ogg')
# Set the volume
pygame.mixer.music.set_volume(0.2)
pygame.mixer.music.play(-1) # -1 will loop the music indefinitely
#Create a vertical box layout
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6)

Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
('share/maths-tutor/images/',['images/wrong-anwser-repeted-1.gif']),
('share/maths-tutor/images/',['images/wrong-anwser-repeted-2.gif']),

('share/maths-tutor/sounds/',['sounds/backgroundmusic.ogg']),
('share/maths-tutor/sounds/',['sounds/coin.ogg']),
('share/maths-tutor/sounds/',['sounds/excellent-1.ogg']),
('share/maths-tutor/sounds/',['sounds/excellent-2.ogg']),
Expand Down
Binary file added sounds/backgroundmusic.ogg
Binary file not shown.

0 comments on commit 134f7e9

Please sign in to comment.