Commit 48cd4c31 authored by Thorfin89's avatar Thorfin89

Création de la fonction switch du bouton Mute

parent 8e569800
...@@ -8,6 +8,11 @@ Pour toute information : thorfin89@free.fr ...@@ -8,6 +8,11 @@ Pour toute information : thorfin89@free.fr
#### Doc python-vlc : #### Doc python-vlc :
- https://www.olivieraubert.net/vlc/python-ctypes/doc/vlc.MediaPlayer-class.html - https://www.olivieraubert.net/vlc/python-ctypes/doc/vlc.MediaPlayer-class.html
- https://stackoverflow.com/questions/46758360/how-to-play-streaming-audio-from-internet-radio-on-python-3-5-3 - https://stackoverflow.com/questions/46758360/how-to-play-streaming-audio-from-internet-radio-on-python-3-5-3
#### Bouton ON/OFF
- https://www.youtube.com/watch?v=DMpq0Cot8YU
- https://www.youtube.com/watch?v=n1ucrkly2nc
#### Doc tkinter : #### Doc tkinter :
- http://tkinter.fdex.eu/index.html - http://tkinter.fdex.eu/index.html
- http://pascal.ortiz.free.fr/contents/tkinter/tkinter/ - http://pascal.ortiz.free.fr/contents/tkinter/tkinter/
archives/icons/408996-200.png

2.24 KB | W: | H:

archives/icons/408996-200.png

6.17 KB | W: | H:

archives/icons/408996-200.png
archives/icons/408996-200.png
archives/icons/408996-200.png
archives/icons/408996-200.png
  • 2-up
  • Swipe
  • Onion skin
archives/icons/408998-200.png

2.54 KB | W: | H:

archives/icons/408998-200.png

6.41 KB | W: | H:

archives/icons/408998-200.png
archives/icons/408998-200.png
archives/icons/408998-200.png
archives/icons/408998-200.png
  • 2-up
  • Swipe
  • Onion skin
archives/icons/408999-200.png

2.05 KB | W: | H:

archives/icons/408999-200.png

6.06 KB | W: | H:

archives/icons/408999-200.png
archives/icons/408999-200.png
archives/icons/408999-200.png
archives/icons/408999-200.png
  • 2-up
  • Swipe
  • Onion skin
archives/icons/409000-200.png

2.15 KB | W: | H:

archives/icons/409000-200.png

6.16 KB | W: | H:

archives/icons/409000-200.png
archives/icons/409000-200.png
archives/icons/409000-200.png
archives/icons/409000-200.png
  • 2-up
  • Swipe
  • Onion skin
archives/icons/409001-200.png

2.2 KB | W: | H:

archives/icons/409001-200.png

6.17 KB | W: | H:

archives/icons/409001-200.png
archives/icons/409001-200.png
archives/icons/409001-200.png
archives/icons/409001-200.png
  • 2-up
  • Swipe
  • Onion skin
archives/icons/409033-200.png

958 Bytes | W: | H:

archives/icons/409033-200.png

5.1 KB | W: | H:

archives/icons/409033-200.png
archives/icons/409033-200.png
archives/icons/409033-200.png
archives/icons/409033-200.png
  • 2-up
  • Swipe
  • Onion skin
archives/icons/409034-200.png

2.06 KB | W: | H:

archives/icons/409034-200.png

6.06 KB | W: | H:

archives/icons/409034-200.png
archives/icons/409034-200.png
archives/icons/409034-200.png
archives/icons/409034-200.png
  • 2-up
  • Swipe
  • Onion skin
archives/icons/409035-200.png

1.6 KB | W: | H:

archives/icons/409035-200.png

5.62 KB | W: | H:

archives/icons/409035-200.png
archives/icons/409035-200.png
archives/icons/409035-200.png
archives/icons/409035-200.png
  • 2-up
  • Swipe
  • Onion skin
archives/icons/409045-200.png

2.07 KB | W: | H:

archives/icons/409045-200.png

6.01 KB | W: | H:

archives/icons/409045-200.png
archives/icons/409045-200.png
archives/icons/409045-200.png
archives/icons/409045-200.png
  • 2-up
  • Swipe
  • Onion skin
archives/icons/409047-200.png

1.94 KB | W: | H:

archives/icons/409047-200.png

5.91 KB | W: | H:

archives/icons/409047-200.png
archives/icons/409047-200.png
archives/icons/409047-200.png
archives/icons/409047-200.png
  • 2-up
  • Swipe
  • Onion skin
archives/icons/409048-200.png

2.18 KB | W: | H:

archives/icons/409048-200.png

6.13 KB | W: | H:

archives/icons/409048-200.png
archives/icons/409048-200.png
archives/icons/409048-200.png
archives/icons/409048-200.png
  • 2-up
  • Swipe
  • Onion skin
archives/icons/409049-200.png

1.97 KB | W: | H:

archives/icons/409049-200.png

5.93 KB | W: | H:

archives/icons/409049-200.png
archives/icons/409049-200.png
archives/icons/409049-200.png
archives/icons/409049-200.png
  • 2-up
  • Swipe
  • Onion skin
archives/icons/409053-200.png

2.07 KB | W: | H:

archives/icons/409053-200.png

6.09 KB | W: | H:

archives/icons/409053-200.png
archives/icons/409053-200.png
archives/icons/409053-200.png
archives/icons/409053-200.png
  • 2-up
  • Swipe
  • Onion skin
archives/icons/409055-200.png

2.33 KB | W: | H:

archives/icons/409055-200.png

6.23 KB | W: | H:

archives/icons/409055-200.png
archives/icons/409055-200.png
archives/icons/409055-200.png
archives/icons/409055-200.png
  • 2-up
  • Swipe
  • Onion skin
archives/icons/409056-200.png

844 Bytes | W: | H:

archives/icons/409056-200.png

4.97 KB | W: | H:

archives/icons/409056-200.png
archives/icons/409056-200.png
archives/icons/409056-200.png
archives/icons/409056-200.png
  • 2-up
  • Swipe
  • Onion skin
archives/icons/409058-200.png

1.46 KB | W: | H:

archives/icons/409058-200.png

5.5 KB | W: | H:

archives/icons/409058-200.png
archives/icons/409058-200.png
archives/icons/409058-200.png
archives/icons/409058-200.png
  • 2-up
  • Swipe
  • Onion skin
archives/icons/409059-200.png

1.39 KB | W: | H:

archives/icons/409059-200.png

5.47 KB | W: | H:

archives/icons/409059-200.png
archives/icons/409059-200.png
archives/icons/409059-200.png
archives/icons/409059-200.png
  • 2-up
  • Swipe
  • Onion skin
archives/icons/410044-200.png

2 KB | W: | H:

archives/icons/410044-200.png

5.99 KB | W: | H:

archives/icons/410044-200.png
archives/icons/410044-200.png
archives/icons/410044-200.png
archives/icons/410044-200.png
  • 2-up
  • Swipe
  • Onion skin
archives/icons/410045-200.png

3.44 KB | W: | H:

archives/icons/410045-200.png

7.16 KB | W: | H:

archives/icons/410045-200.png
archives/icons/410045-200.png
archives/icons/410045-200.png
archives/icons/410045-200.png
  • 2-up
  • Swipe
  • Onion skin
archives/icons/410046-200.png

2.05 KB | W: | H:

archives/icons/410046-200.png

6.08 KB | W: | H:

archives/icons/410046-200.png
archives/icons/410046-200.png
archives/icons/410046-200.png
archives/icons/410046-200.png
  • 2-up
  • Swipe
  • Onion skin
archives/icons/410047-200.png

2.03 KB | W: | H:

archives/icons/410047-200.png

6.05 KB | W: | H:

archives/icons/410047-200.png
archives/icons/410047-200.png
archives/icons/410047-200.png
archives/icons/410047-200.png
  • 2-up
  • Swipe
  • Onion skin
archives/icons/410048-200.png

2.07 KB | W: | H:

archives/icons/410048-200.png

6.08 KB | W: | H:

archives/icons/410048-200.png
archives/icons/410048-200.png
archives/icons/410048-200.png
archives/icons/410048-200.png
  • 2-up
  • Swipe
  • Onion skin
archives/icons/410049-200.png

2.43 KB | W: | H:

archives/icons/410049-200.png

6.34 KB | W: | H:

archives/icons/410049-200.png
archives/icons/410049-200.png
archives/icons/410049-200.png
archives/icons/410049-200.png
  • 2-up
  • Swipe
  • Onion skin
archives/icons/410050-200.png

2.39 KB | W: | H:

archives/icons/410050-200.png

6.36 KB | W: | H:

archives/icons/410050-200.png
archives/icons/410050-200.png
archives/icons/410050-200.png
archives/icons/410050-200.png
  • 2-up
  • Swipe
  • Onion skin
archives/icons/410051-200.png

1.64 KB | W: | H:

archives/icons/410051-200.png

5.54 KB | W: | H:

archives/icons/410051-200.png
archives/icons/410051-200.png
archives/icons/410051-200.png
archives/icons/410051-200.png
  • 2-up
  • Swipe
  • Onion skin
57
\ No newline at end of file
...@@ -30,15 +30,15 @@ class Radio(Pupitre): ...@@ -30,15 +30,15 @@ class Radio(Pupitre):
# on récupère la valeur du potentiomètre de volume # on récupère la valeur du potentiomètre de volume
vol_audio = int(vol_potar) vol_audio = int(vol_potar)
self.player.audio_set_volume(vol_audio) self.player.audio_set_volume(vol_audio)
sauvegarde = open("init", "w") sauvegarde = open("webradiopi.cfg", "w")
sauvegarde.write(vol_potar) sauvegarde.write(vol_potar) # le niveau du volume est enregistré
sauvegarde.close() sauvegarde.close()
def radio_mute(self): def radio_mute(self): # coupure du son
self.player.audio_set_volume(0) self.player.audio_set_volume(0)
def radio_sound(self): def radio_sound(self): # rétablissement du son
lecture = open("init", "r") # on charge configuration sauvegardée lecture = open("webradiopi.cfg", "r") # on charge configuration sauvegardée
volume_init = int(lecture.read()) volume_init = int(lecture.read())
lecture.close() lecture.close()
self.player.audio_set_volume(volume_init) self.player.audio_set_volume(volume_init)
......
...@@ -6,6 +6,9 @@ ...@@ -6,6 +6,9 @@
import tkinter as tk import tkinter as tk
from tkinter import ttk, Scale, HORIZONTAL, CENTER, LEFT, RIGHT, TOP from tkinter import ttk, Scale, HORIZONTAL, CENTER, LEFT, RIGHT, TOP
global mute
mute = False
# classes --------------------------------- # classes ---------------------------------
class Pupitre: class Pupitre:
...@@ -46,7 +49,7 @@ class Pupitre: ...@@ -46,7 +49,7 @@ class Pupitre:
menu.pack(side=RIGHT, expand='True') menu.pack(side=RIGHT, expand='True')
x_menu = 0 x_menu = 0
y_menu = 200 y_menu = 240
style = ttk.Style() style = ttk.Style()
style.configure("BW.TLabel", foreground="black", background="#D9D9D9") style.configure("BW.TLabel", foreground="black", background="#D9D9D9")
...@@ -64,20 +67,30 @@ class Pupitre: ...@@ -64,20 +67,30 @@ class Pupitre:
btn_stop.place(width=30, height=30, x=x_menu + 225, y=y_menu + 0) btn_stop.place(width=30, height=30, x=x_menu + 225, y=y_menu + 0)
# potentiomètre de volume # potentiomètre de volume
lecture = open("init", "r") # on charge configuration sauvegardée lecture = open("webradiopi.cfg", "r") # on charge configuration sauvegardée
volume_init = lecture.read() volume_init = lecture.read()
lecture.close() lecture.close()
vol_potar = Scale(menu, from_=0, to=100, tickinterval=20, orient=HORIZONTAL, length=240, label="Volume", vol_potar = Scale(menu, from_=0, to=100, tickinterval=20, orient=HORIZONTAL, length=200, label="Volume",
command=self.volume) command=self.volume)
vol_potar.set(volume_init) vol_potar.set(volume_init)
vol_potar.place(x=x_menu + 30, y=y_menu + 40) vol_potar.place(x=x_menu + 30, y=y_menu + 40)
# boutons de coupure et rétablissement du son # boutons de coupure et rétablissement du son
btn_stop = ttk.Button(menu, image=self.icon_mute, text="Mute", command=self.radio_mute, style="BW.TLabel") self.btn_mute = ttk.Button(menu, image=self.icon_sound, text="Mute", command=self.switch_sound,
btn_stop.place(width=30, height=30, x=x_menu + 110, y=y_menu + 120) style="BW.TLabel")
btn_stop = ttk.Button(menu, image=self.icon_sound, text="Sound", command=self.radio_sound, style="BW.TLabel") self.btn_mute.place(width=30, height=30, x=x_menu + 245, y=y_menu + 70)
btn_stop.place(width=30, height=30, x=x_menu + 160, y=y_menu + 120)
# info appli # info appli
lbl_info = ttk.Label(menu, text="WebRadioPi @thorfin89", anchor=CENTER) lbl_info = ttk.Label(menu, text="WebRadioPi © Thorfin89", anchor=CENTER)
lbl_info.place(width=300, height=16, x=x_menu + 0, y=y_menu + 170) lbl_info.place(width=300, height=16, x=x_menu + 0, y=y_menu + 140)
def switch_sound(self):
global mute
if not mute:
self.radio_mute()
self.btn_mute.config(image=self.icon_mute)
mute = True
else:
self.radio_sound()
self.btn_mute.config(image=self.icon_sound)
mute = False
68
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment