From 852c89597b12dcc4589534c1902936722087dcb6 Mon Sep 17 00:00:00 2001
From: SofianeLasri <alasri250@gmail.com>
Date: Wed, 22 Mar 2023 10:28:36 +0100
Subject: [PATCH] =?UTF-8?q?On=20peut=20d=C3=A9sormais=20r=C3=A9gler=20le?=
 =?UTF-8?q?=20volume=20par=20d=C3=A9faut,=20config=20d'exemple.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .gitignore                     | 3 ++-
 defs.py                        | 4 +++-
 config.py => example.config.py | 3 ++-
 radio.py                       | 3 +--
 4 files changed, 8 insertions(+), 5 deletions(-)
 rename config.py => example.config.py (96%)

diff --git a/.gitignore b/.gitignore
index 723ef36..32747a9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
-.idea
\ No newline at end of file
+.idea
+config.py
\ No newline at end of file
diff --git a/defs.py b/defs.py
index 6d6f2e4..71c2adb 100644
--- a/defs.py
+++ b/defs.py
@@ -28,6 +28,7 @@ def playSound(soundFile):
 
     # We will play the sound file
     player = vlc.MediaPlayer(soundFile)
+    player.audio_set_volume(config.volume)
     player.play()
 
     # We will wait for the sound to finish
@@ -69,6 +70,7 @@ def playSoundWithDelayedSecondSound(firstSound, secondSound):
     players[1].set_media(instances[1].media_new(secondSound))
 
     # We will play the first sound
+    players[0].audio_set_volume(config.volume)
     players[0].play()
 
     # We wait
@@ -91,7 +93,7 @@ def playSoundWithDelayedSecondSound(firstSound, secondSound):
         print("Done playing Intro: " + secondSound)
 
     # We will now raise the volume of the first sound
-    players[0].audio_set_volume(100)
+    players[0].audio_set_volume(config.volume)
 
     # We will wait for the first sound to finish
     current_state = players[0].get_state()
diff --git a/config.py b/example.config.py
similarity index 96%
rename from config.py
rename to example.config.py
index 4540550..29b410b 100644
--- a/config.py
+++ b/example.config.py
@@ -1,4 +1,4 @@
-debug = True
+debug = False
 filesExtension = ".wav"
 blankPauseDuration = 0
 musicMinIntroDelay = 5
@@ -6,6 +6,7 @@ musicMaxIntroDelay = 15
 introFolder = "intro"
 adsProbability = 0.25
 newsProbability = 0.25
+volume = 75
 
 # Regex
 idPattern = "((id)|(ID))_([0-9]){2}"
diff --git a/radio.py b/radio.py
index 8c65e98..7e895ca 100644
--- a/radio.py
+++ b/radio.py
@@ -30,7 +30,6 @@ class Radio:
         self.ads = defs.getFilesByRegex(self.adsPath, ".*")
         self.news = defs.getFilesByRegex(self.newsPath, ".*")
 
-
     def startRadio(self):
         while True:
             # Check if we will play an ad or news
@@ -94,4 +93,4 @@ try:
     radio.startRadio()
 except KeyboardInterrupt:
     print("Exiting...")
-    exit(0)
\ No newline at end of file
+    exit(0)
-- 
GitLab